connector

package
v0.13.0-rc.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const AgentPlatformConnector = "connector"

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	// List lists all containers running on the host.
	List(ctx context.Context) ([]Container, error)
	// Start starts the agent for the container with the given ID.
	Start(ctx context.Context, id string, name string)
	// Stop stops the agent for the container with the given ID.
	Stop(ctx context.Context, id string)
	// Listen listens for events and starts or stops the agent for the container that was created or removed.
	Listen(ctx context.Context) error
}

Connector is an interface that defines the methods that a connector must implement.

func NewDockerConnector

func NewDockerConnector(server string, tenant string, privateKey string) (Connector, error)

NewDockerConnector creates a new Connector that uses Docker as the container runtime.

type Container

type Container struct {
	// ID is the container ID.
	ID string
	// Name is the container name.
	Name string
	// ServerAddress is the ShellHub address of the server that the agent will connect to.
	ServerAddress string
	// Tenant is the tenant ID of the namespace that the agent belongs to.
	Tenant string
	// PrivateKey is the private key of the device. Specify the path to store the container private key. If not
	// provided, the agent will generate a new one. This is required.
	PrivateKey string
	// Cancel is a function that is used to stop the goroutine that is running the agent for this container.
	Cancel context.CancelFunc
}

Container is a struct that represents a container that will be managed by the connector.

type DockerConnector

type DockerConnector struct {
	// contains filtered or unexported fields
}

DockerConnector is a struct that represents a connector that uses Docker as the container runtime.

func (*DockerConnector) List

func (d *DockerConnector) List(ctx context.Context) ([]Container, error)

func (*DockerConnector) Listen

func (d *DockerConnector) Listen(ctx context.Context) error

Listen listens for events and starts or stops the agent for the containers.

func (*DockerConnector) Start

func (d *DockerConnector) Start(ctx context.Context, id string, name string)

Start starts the agent for the container with the given ID.

func (*DockerConnector) Stop

func (d *DockerConnector) Stop(_ context.Context, id string)

Stop stops the agent for the container with the given ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL