func NewTaskClient(client interface{}) (v2.TaskService, error)
NewTaskClient returns a new task client interface which handles both GRPC and TTRPC servers depending on the client object type passed in.
Supported client types are: - *ttrpc.Client - grpc.ClientConnInterface
In 1.7 we support TaskService v2 (for backward compatibility with existing shims) and GRPC TaskService v3. In 2.0 we'll switch to TaskService v3 only for both TTRPC and GRPC, which will remove overhead of mapping v2 structs to v3 structs.
Bundle represents an OCI bundle
type Bundle struct { // ID of the bundle ID string // Path to the bundle Path string // Namespace of the bundle Namespace string }
func LoadBundle(ctx context.Context, root, id string) (*Bundle, error)
LoadBundle loads an existing bundle from disk
func NewBundle(ctx context.Context, root, state, id string, spec typeurl.Any) (b *Bundle, err error)
NewBundle returns a new bundle on disk
func (b *Bundle) Delete() error
Delete a bundle atomically
Config for the v2 runtime
type Config struct { // Supported platforms Platforms []string `toml:"platforms"` // SchedCore enabled linux core scheduling SchedCore bool `toml:"sched_core"` }
type ManagerConfig struct { Root string State string Store containers.Store Events *exchange.Exchange Address string TTRPCAddress string SchedCore bool SandboxStore sandbox.Store }
ShimInstance represents running shim process managed by ShimManager.
type ShimInstance interface { io.Closer // ID of the shim. ID() string // Namespace of this shim. Namespace() string // Bundle is a file system path to shim's bundle. Bundle() string // Client returns the underlying TTRPC or GRPC client object for this shim. // The underlying object can be either *ttrpc.Client or grpc.ClientConnInterface. Client() any // Delete will close the client and remove bundle from disk. Delete(ctx context.Context) error }
ShimManager manages currently running shim processes. It is mainly responsible for launching new shims and for proper shutdown and cleanup of existing instances. The manager is unaware of the underlying services shim provides and lets higher level services consume them, but don't care about lifecycle management.
type ShimManager struct {
// contains filtered or unexported fields
}
func NewShimManager(ctx context.Context, config *ManagerConfig) (*ShimManager, error)
NewShimManager creates a manager for v2 shims
func (m *ShimManager) Delete(ctx context.Context, id string) error
Delete a runtime task
func (m *ShimManager) Get(ctx context.Context, id string) (ShimInstance, error)
func (m *ShimManager) ID() string
ID of the shim manager
func (m *ShimManager) Start(ctx context.Context, id string, opts runtime.CreateOpts) (_ ShimInstance, retErr error)
Start launches a new shim instance
TaskManager wraps task service client on top of shim manager.
type TaskManager struct {
// contains filtered or unexported fields
}
func NewTaskManager(shims *ShimManager) *TaskManager
NewTaskManager creates a new task manager instance.
func (m *TaskManager) Create(ctx context.Context, taskID string, opts runtime.CreateOpts) (runtime.Task, error)
Create launches new shim instance and creates new task
func (m *TaskManager) Delete(ctx context.Context, taskID string) (*runtime.Exit, error)
Delete deletes the task and shim instance
func (m *TaskManager) Get(ctx context.Context, id string) (runtime.Task, error)
Get a specific task
func (m *TaskManager) ID() string
ID of the task manager
func (m *TaskManager) Tasks(ctx context.Context, all bool) ([]runtime.Task, error)
Tasks lists all tasks