package stub
import "github.com/containerd/nri/pkg/stub"
Index ¶
- Constants
- Variables
- type ConfigureInterface
- type CreateContainerInterface
- type EventMask
- type Option
- func WithConnection(conn stdnet.Conn) Option
- func WithDialer(d func(string) (stdnet.Conn, error)) Option
- func WithOnClose(onClose func()) Option
- func WithPluginIdx(idx string) Option
- func WithPluginName(name string) Option
- func WithSocketPath(path string) Option
- func WithTTRPCOptions(clientOpts []ttrpc.ClientOpts, serverOpts []ttrpc.ServerOpt) Option
- type Plugin
- type PostCreateContainerInterface
- type PostStartContainerInterface
- type PostUpdateContainerInterface
- type RemoveContainerInterface
- type RemovePodInterface
- type RunPodInterface
- type ShutdownInterface
- type StartContainerInterface
- type StopContainerInterface
- type StopPodInterface
- type Stub
- type SynchronizeInterface
- type UpdateContainerInterface
Constants ¶
const ( // DefaultRegistrationTimeout is the default plugin registration timeout. DefaultRegistrationTimeout = api.DefaultPluginRegistrationTimeout // DefaultRequestTimeout is the default plugin request processing timeout. DefaultRequestTimeout = api.DefaultPluginRequestTimeout )
Variables ¶
var ( // ErrNoService indicates that the stub has no runtime service/connection, // for instance by UpdateContainers on a stub which has not been started. ErrNoService = errors.New("stub: no service/connection") )
Types ¶
type ConfigureInterface ¶
type ConfigureInterface interface { // Configure the plugin with the given NRI-supplied configuration. // If a non-zero EventMask is returned, the plugin will be subscribed // to the corresponding. Configure(ctx context.Context, config, runtime, version string) (api.EventMask, error) }
ConfigureInterface handles Configure API request.
type CreateContainerInterface ¶
type CreateContainerInterface interface { // CreateContainer relays a CreateContainer request to the plugin. // The plugin can request adjustments to the container being created // and updates to other unstopped containers in response. CreateContainer(context.Context, *api.PodSandbox, *api.Container) (*api.ContainerAdjustment, []*api.ContainerUpdate, error) }
CreateContainerInterface handles CreateContainer API requests.
type EventMask ¶
EventMask holds a mask of events for plugin subscription.
type Option ¶
type Option func(*stub) error
Option to apply to a plugin during its creation.
func WithConnection ¶
WithConnection sets an existing NRI connection to use.
func WithDialer ¶
WithDialer sets the dialer to use.
func WithOnClose ¶
func WithOnClose(onClose func()) Option
WithOnClose sets a notification function to call if the ttRPC connection goes down.
func WithPluginIdx ¶
WithPluginIdx sets the index to use in plugin registration.
func WithPluginName ¶
WithPluginName sets the name to use in plugin registration.
func WithSocketPath ¶
WithSocketPath sets the NRI socket path to connect to.
func WithTTRPCOptions ¶
func WithTTRPCOptions(clientOpts []ttrpc.ClientOpts, serverOpts []ttrpc.ServerOpt) Option
WithTTRPCOptions sets extra client and server options to use for ttrpc .
type Plugin ¶
type Plugin interface{}
Plugin can implement a number of interfaces related to Pod and Container lifecycle events. No any single such interface is mandatory, therefore the Plugin interface itself is empty. Plugins are required to implement at least one of these interfaces and this is verified during stub creation. Trying to create a stub for a plugin violating this requirement will fail with and error.
type PostCreateContainerInterface ¶
type PostCreateContainerInterface interface { // PostCreateContainer relays a PostCreateContainer event to the plugin. PostCreateContainer(context.Context, *api.PodSandbox, *api.Container) error }
PostCreateContainerInterface handles PostCreateContainer API events.
type PostStartContainerInterface ¶
type PostStartContainerInterface interface { // PostStartContainer relays a PostStartContainer event to the plugin. PostStartContainer(context.Context, *api.PodSandbox, *api.Container) error }
PostStartContainerInterface handles PostStartContainer API events.
type PostUpdateContainerInterface ¶
type PostUpdateContainerInterface interface { // PostUpdateContainer relays a PostUpdateContainer event to the plugin. PostUpdateContainer(context.Context, *api.PodSandbox, *api.Container) error }
PostUpdateContainerInterface handles PostUpdateContainer API events.
type RemoveContainerInterface ¶
type RemoveContainerInterface interface { // RemoveContainer relays a RemoveContainer event to the plugin. RemoveContainer(context.Context, *api.PodSandbox, *api.Container) error }
RemoveContainerInterface handles RemoveContainer API events.
type RemovePodInterface ¶
type RemovePodInterface interface { // RemovePodSandbox relays a RemovePodSandbox event to the plugin. RemovePodSandbox(context.Context, *api.PodSandbox) error }
RemovePodInterface handles RemovePodSandbox API events.
type RunPodInterface ¶
type RunPodInterface interface { // RunPodSandbox relays a RunPodSandbox event to the plugin. RunPodSandbox(context.Context, *api.PodSandbox) error }
RunPodInterface handles RunPodSandbox API events.
type ShutdownInterface ¶
type ShutdownInterface interface { // Shutdown notifies the plugin about the runtime shutting down. Shutdown(context.Context) }
ShutdownInterface handles a Shutdown API request.
type StartContainerInterface ¶
type StartContainerInterface interface { // StartContainer relays a StartContainer event to the plugin. StartContainer(context.Context, *api.PodSandbox, *api.Container) error }
StartContainerInterface handles StartContainer API requests.
type StopContainerInterface ¶
type StopContainerInterface interface { // StopContainer relays a StopContainer request to the plugin. // The plugin can request updates to unstopped containers in response. StopContainer(context.Context, *api.PodSandbox, *api.Container) ([]*api.ContainerUpdate, error) }
StopContainerInterface handles StopContainer API requests.
type StopPodInterface ¶
type StopPodInterface interface { // StopPodSandbox relays a StopPodSandbox event to the plugin. StopPodSandbox(context.Context, *api.PodSandbox) error }
StopPodInterface handles StopPodSandbox API events.
type Stub ¶
type Stub interface { // Run starts the plugin then waits for the plugin service to exit, either due to a // critical error or an explicit call to Stop(). Once Run() returns, the plugin can be // restarted by calling Run() or Start() again. Run(context.Context) error // Start the plugin. Start(context.Context) error // Stop the plugin. Stop() // Wait for the plugin to stop. Wait() // UpdateContainer requests unsolicited updates to containers. UpdateContainers([]*api.ContainerUpdate) ([]*api.ContainerUpdate, error) // RegistrationTimeout returns the registration timeout for the stub. // This is the default timeout if the plugin has not been started or // the timeout received in the Configure request otherwise. RegistrationTimeout() time.Duration // RequestTimeout returns the request timeout for the stub. // This is the default timeout if the plugin has not been started or // the timeout received in the Configure request otherwise. RequestTimeout() time.Duration }
Stub is the interface the stub provides for the plugin implementation.
func New ¶
New creates a stub with the given plugin and options.
type SynchronizeInterface ¶
type SynchronizeInterface interface { // Synchronize the state of the plugin with the runtime. // The plugin can request updates to containers in response. Synchronize(context.Context, []*api.PodSandbox, []*api.Container) ([]*api.ContainerUpdate, error) }
SynchronizeInterface handles Synchronize API requests.
type UpdateContainerInterface ¶
type UpdateContainerInterface interface { // UpdateContainer relays an UpdateContainer request to the plugin. // The plugin can request updates both to the container being updated // (which then supersedes the original update) and to other unstopped // containers in response. UpdateContainer(context.Context, *api.PodSandbox, *api.Container, *api.LinuxResources) ([]*api.ContainerUpdate, error) }
UpdateContainerInterface handles UpdateContainer API requests.
Source Files ¶
- Version
- v0.9.0 (latest)
- Published
- Dec 12, 2024
- Platform
- linux/amd64
- Imports
- 14 packages
- Last checked
- 2 months ago –
Tools for package owners.