Documentation
¶
Index ¶
- Constants
- type Candidate
- type ChunkInfo
- type DefaultFramework
- func (df *DefaultFramework) RegisterPlugins(fns []RegisterFunc) error
- func (df *DefaultFramework) RunFilterPlugins(ctx context.Context, chunk ChunkInfo, nodeInfo *NodeInfo, ...) (candidates []Candidate)
- func (df *DefaultFramework) RunScorePlugins(ctx context.Context, chunk ChunkInfo, nodeInfo *NodeInfo, ...) []Candidate
- type Download
- type FilterPlugin
- type Framework
- type NodeInfo
- type Plugin
- type PreFilterPlugin
- type RegisterFunc
- type Registry
- type ScoreCandidate
- type ScorePlugin
- type Status
- type StatusCode
- type Sync
Constants ¶
const ( MaxScore = 100 MinScore = 0 SuccessStatus StatusCode = "success" UnschedulableStatus StatusCode = "Unschedulable" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶ added in v0.0.2
type Candidate struct {
// Node represents the candidate nodeTracker.
Node api.NodeTracker
// Only set after scoring.
Score float32
}
Candidate will be used as the result of Filter extension point and input/output of Score extension point.
type DefaultFramework ¶
type DefaultFramework struct {
// contains filtered or unexported fields
}
func (*DefaultFramework) RegisterPlugins ¶
func (df *DefaultFramework) RegisterPlugins(fns []RegisterFunc) error
func (*DefaultFramework) RunFilterPlugins ¶
func (df *DefaultFramework) RunFilterPlugins(ctx context.Context, chunk ChunkInfo, nodeInfo *NodeInfo, nodeTrackers []api.NodeTracker, cache *cache.Cache) (candidates []Candidate)
type Download ¶
type Download interface {
Framework
}
Download represents the methods to download a chunk.
type FilterPlugin ¶
type Framework ¶
type Framework interface {
// RegisterPlugins will register the plugins to run.
RegisterPlugins([]RegisterFunc) error
// RunFilterPlugins will filter out unsatisfied peers.
// NodeInfo refers to the source node in syncing tasks, it must not be nil in syncing,
// on the contrary, it must be nil in downloading tasks.
RunFilterPlugins(context.Context, ChunkInfo, *NodeInfo, []api.NodeTracker, *cache.Cache) []Candidate
// RunScorePlugins will calculate the scores of all the peers.
// NodeInfo refers to the source node in syncing tasks, it must not be nil in syncing,
// on the contrary, it must be nil in downloading tasks.
RunScorePlugins(context.Context, ChunkInfo, *NodeInfo, []Candidate, *cache.Cache) []Candidate
}
Framework represents the algo about how to pick the candidates among all the peers.
type Plugin ¶
type Plugin interface {
Name() string
}
Plugin is the parent type for all the framework plugins. the same time.
type PreFilterPlugin ¶
type RegisterFunc ¶
type Registry ¶
Registry is a collection of all available plugins. The framework uses a registry to enable and initialize configured plugins.
func (Registry) Register ¶
func (r Registry) Register(fn RegisterFunc) error
Register adds a new plugin to the registry. If a plugin with the same name exists, it returns an error.
func (Registry) Unregister ¶
Unregister removes an existing plugin from the registry. If no plugin with the provided name exists, it returns an error.
type ScoreCandidate ¶ added in v0.0.2
type ScoreCandidate struct {
// SourceNodeName represents the the source node name in syncing tasks.
// It's empty once in downloading tasks.
SourceNodeName string
// CandidateNodeName represents the target node name.
CandidateNodeName string
// Score for candidate node.
Score float32
}
ScoreCandidate will be used after Score extension point for picking best effort nodes.
type ScorePlugin ¶
type Status ¶
type Status struct {
Code StatusCode
}
type StatusCode ¶
type StatusCode string