Documentation ¶
Index ¶
Constants ¶
View Source
const (
// SchedulerCallback ...
SchedulerCallback = "P2PPreheatCallback"
)
Variables ¶
View Source
var ( // Ctl is a global preheat controller instance Ctl = NewController() )
View Source
var ( // Enf default enforcer Enf = NewEnforcer() )
View Source
var ErrorConflict = errors.New("resource conflict")
ErrorConflict for handling conflicts
View Source
var ErrorUnhealthy = errors.New("instance unhealthy")
ErrorUnhealthy for unhealthy
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface { // Get all the supported distribution providers // // If succeed, an metadata of provider list will be returned. // Otherwise, a non nil error will be returned // GetAvailableProviders() ([]*provider.Metadata, error) // CountInstance all the setup instances of distribution providers // // params *q.Query : parameters for querying // // If succeed, matched provider instance count will be returned. // Otherwise, a non nil error will be returned // CountInstance(ctx context.Context, query *q.Query) (int64, error) // ListInstance all the setup instances of distribution providers // // params *q.Query : parameters for querying // // If succeed, matched provider instance list will be returned. // Otherwise, a non nil error will be returned // ListInstance(ctx context.Context, query *q.Query) ([]*providerModels.Instance, error) // GetInstance the metadata of the specified instance // // id string : ID of the instance being deleted // // If succeed, the metadata with nil error are returned // Otherwise, a non nil error is returned // GetInstance(ctx context.Context, id int64) (*providerModels.Instance, error) // GetInstance the metadata of the specified instance GetInstanceByName(ctx context.Context, name string) (*providerModels.Instance, error) // Create a new instance for the specified provider. // // If succeed, the ID of the instance will be returned. // Any problems met, a non nil error will be returned. // CreateInstance(ctx context.Context, instance *providerModels.Instance) (int64, error) // Delete the specified provider instance. // // id string : ID of the instance being deleted // // Any problems met, a non nil error will be returned. // DeleteInstance(ctx context.Context, id int64) error // Update the instance with incremental way; // Including update the enabled flag of the instance. // // id string : ID of the instance being updated // properties ...string : The properties being updated // // Any problems met, a non nil error will be returned // UpdateInstance(ctx context.Context, instance *providerModels.Instance, properties ...string) error // CountPolicy returns the total count of the policy. CountPolicy(ctx context.Context, query *q.Query) (int64, error) // CreatePolicy creates the policy. CreatePolicy(ctx context.Context, schema *policyModels.Schema) (int64, error) // GetPolicy gets the policy by id. GetPolicy(ctx context.Context, id int64) (*policyModels.Schema, error) // GetPolicyByName gets the policy by name. GetPolicyByName(ctx context.Context, projectID int64, name string) (*policyModels.Schema, error) // UpdatePolicy updates the policy. UpdatePolicy(ctx context.Context, schema *policyModels.Schema, props ...string) error // DeletePolicy deletes the policy by id. DeletePolicy(ctx context.Context, id int64) error // ListPolicies lists policies by query. ListPolicies(ctx context.Context, query *q.Query) ([]*policyModels.Schema, error) // ListPoliciesByProject lists policies by project. ListPoliciesByProject(ctx context.Context, project int64, query *q.Query) ([]*policyModels.Schema, error) // CheckHealth checks the instance health, for test connection CheckHealth(ctx context.Context, instance *providerModels.Instance) error // DeletePoliciesOfProject delete all policies under one project DeletePoliciesOfProject(ctx context.Context, project int64) error }
Controller defines related top interfaces to handle the workflow of the image distribution.
type Enforcer ¶
type Enforcer interface { // Enforce preheating action by the given policy. // For manual and scheduled preheating scenarios. // // Arguments: // ctx context.Context : system context // policyID int64 : ID of the being enforced policy // // Returns: // - ID of the execution // - non-nil error if any error occurred during the enforcement EnforcePolicy(ctx context.Context, policyID int64) (int64, error) // Enforce preheating action by the given artifact. // For event-based cases. // Using the given artifact to located the matched preheat policy and bound this action // with the located preheat policy. // // Arguments: // ctx context.Context : system context // art *artifact.Artifact: Artifact contained in the occurred events. // // Returns: // - IDs of the executions // - non-nil error if any error occurred during the enforcement // // Notes: // The current design is artifact central mode (identified by digest). All the tags of // the artifact are kept together. However, the preheating action is based on the specified // tag and we need to split the all-tags-in-one artifact to one-tag artifacts here. PreheatArtifact(ctx context.Context, art *artifact.Artifact) ([]int64, error) }
Enforcer defines preheat policy enforcement operations.
Click to show internal directories.
Click to hide internal directories.