Documentation
¶
Index ¶
- Variables
- type Config
- type Connector
- type Container
- type DockerConnector
- func (d *DockerConnector) CheckUpdate() (*semver.Version, error)
- func (d *DockerConnector) List(ctx context.Context) ([]Container, error)
- func (d *DockerConnector) Listen(ctx context.Context) error
- func (d *DockerConnector) Start(ctx context.Context, id string, name string)
- func (d *DockerConnector) Stop(_ context.Context, id string)
Constants ¶
This section is empty.
Variables ¶
var ConnectorVersion string
ConnectorVersion stores the version of the ShellHub Instane that is running the connector. It is used in the ShellHub Agents initialized by the connector when a container is started.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.16.0
type Config struct {
// Set the ShellHub server address the agent will use to connect.
// This is required.
ServerAddress string `env:"SERVER_ADDRESS,required"`
// Specify the path to store the devices/containers private keys.
// If not provided, the agent will generate a new one.
// This is required.
PrivateKeys string `env:"PRIVATE_KEYS,required"`
// Sets the account tenant id used during communication to associate the
// devices to a specific tenant.
// This is required.
TenantID string `env:"TENANT_ID,required"`
// Determine the interval to send the keep alive message to the server. This
// has a direct impact of the bandwidth used by the device when in idle
// state. Default is 30 seconds.
KeepAliveInterval int `env:"KEEPALIVE_INTERVAL,overwrite,default=30"`
// Label is the label used to identify the containers managed by the ShellHub agent.
Label string `env:"CONNECTOR_LABEL,default="`
}
Config provides the configuration for the agent connector service.
func LoadConfigFromEnv ¶ added in v0.16.0
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
// Checks for Connector's update.
CheckUpdate() (*semver.Version, error)
}
Connector is an interface that defines the methods that a connector must implement.
func NewDockerConnector ¶
NewDockerConnector creates a new Connector that uses Docker as the container runtime.
func NewDockerConnectorWithClient ¶ added in v0.17.0
func NewDockerConnectorWithClient(cli *dockerclient.Client, config *Config) Connector
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 {
// Label is the label used to identify the containers managed by the ShellHub agent.
Label string
// contains filtered or unexported fields
}
DockerConnector is a struct that represents a connector that uses Docker as the container runtime.
func (*DockerConnector) CheckUpdate ¶ added in v0.18.0
func (d *DockerConnector) CheckUpdate() (*semver.Version, error)
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.