本小结主要分析 registry/interface.go
pkg/registry/interfaces.go
// TaskRegistry is an interface implemented by things that know how to store Task objects
type TaskRegistry interface {
// ListTasks obtains a list of tasks that match query.
// Query may be nil in which case all tasks are returned.
ListTasks(query *map[string]string) ([]api.Task, error)
// Get a specific task
GetTask(taskId string) (*api.Task, error)
// Create a task based on a specification, schedule it onto a specific machine.
CreateTask(machine string, task api.Task) error
// Update an existing task
UpdateTask(task api.Task) error
// Delete an existing task
DeleteTask(taskId string) error
}
// ControllerRegistry is an interface for things that know how to store Controllers
type ControllerRegistry interface {
ListControllers() ([]api.ReplicationController, error)
GetController(controllerId string) (*api.ReplicationController, error)
CreateController(controller api.ReplicationController) error
UpdateController(controller api.ReplicationController) error
DeleteController(controllerId string) error
}
regitry 中提供了两个接口:
这两个接口提供的方法差不多,对 Task/Controller 处理的封装;
在 pkg/registry/task/task_registry.go 中对 TaskRegistry 接口的实现;
在 pkg/registry/controller/controller_registry.go 中对 ControllerRegistry 接口的实现;
下面来详细分析这些接口的实现:
pkg/registry/task_registry.go
// TaskRegistryStorage implements the RESTStorage interface in terms of a TaskRegistry
type TaskRegistryStorage struct {
registry TaskRegistry
containerInfo client.ContainerInfo
scheduler Scheduler
}
TaskRegistryStorage 结构体中有三个成员变量:
该结构体有五个成员方法:
queryMap := client.DecodeLabelQuery(url.Query().Get("labels"))
根据输入的 URL 中的 labels 参数,返回 labels 的 map;
labels 中的标签值:key1=value1,key2=value2 的形式;
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。