drivers

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package drivers implements common interfaces and utilities for Apoxy service drivers

Index

Constants

View Source
const (
	// APIServerStdoutLogFile is the name of the apiserver stdout log file
	APIServerStdoutLogFile = "apiserver.stdout.log"
	// APIServerStderrLogFile is the name of the apiserver stderr log file
	APIServerStderrLogFile = "apiserver.stderr.log"
	// APIServerProcessName is used to identify the apiserver process
	APIServerProcessName = "apiserver"
)
View Source
const (
	// DefaultLogsDir is the default directory for logs
	DefaultLogsDir = "/var/log/apoxy"
	// BackplaneStdoutLogFile is the name of the backplane stdout log file
	BackplaneStdoutLogFile = "backplane.stdout.log"
	// BackplaneStderrLogFile is the name of the backplane stderr log file
	BackplaneStderrLogFile = "backplane.stderr.log"
	// BackplaneProcessName is used to identify the backplane process
	BackplaneProcessName = "backplane"
)
View Source
const (
	// BackplaneService represents the backplane service.
	BackplaneService ServiceType = "backplane"
	// APIServerService represents the apiserver service.
	APIServerService ServiceType = "apiserver"
	// TunnelProxyService represents the tunnel proxy service.
	TunnelProxyService ServiceType = "tunnelproxy"

	// DockerMode represents the docker driver mode.
	DockerMode DriverMode = "docker"
	// SupervisorMode represents the supervisor driver mode.
	SupervisorMode DriverMode = "supervisor"
)
View Source
const (
	// DefaultTunnelProxyLogsDir is the default directory for logs
	DefaultTunnelProxyLogsDir = "/var/log/apoxy"
	// TunnelProxyStdoutLogFile is the name of the tunnelproxy stdout log file
	TunnelProxyStdoutLogFile = "tunnelproxy.stdout.log"
	// TunnelProxyStderrLogFile is the name of the tunnelproxy stderr log file
	TunnelProxyStderrLogFile = "tunnelproxy.stderr.log"
	// TunnelProxyProcessName is used to identify the tunnelproxy process
	TunnelProxyProcessName = "tunnelproxy"
)

Variables

This section is empty.

Functions

func ForwardTCP

func ForwardTCP(
	stopCh <-chan struct{},
	cname string,
	localPort, remotePort int,
) error

ForwardTCP forwards localPort on host to a remotePort on a container cname.

func WithLogsDir

func WithLogsDir(logsDir string) func(*BackplaneSupervisorDriver)

WithLogsDir sets the logs directory for the supervisor driver.

func WithTunnelProxyLogsDir

func WithTunnelProxyLogsDir(logsDir string) func(*TunnelProxySupervisorDriver)

WithTunnelProxyLogsDir sets the logs directory for the supervisor driver.

Types

type APIServerDockerDriver

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

APIServerDockerDriver implements the Driver interface for Docker.

func NewAPIServerDockerDriver

func NewAPIServerDockerDriver() *APIServerDockerDriver

NewAPIServerDockerDriver creates a new Docker driver for apiserver.

func (*APIServerDockerDriver) GetAddr

func (d *APIServerDockerDriver) GetAddr(ctx context.Context) (string, error)

GetAddr implements the Driver interface.

func (*APIServerDockerDriver) ImageRef added in v0.8.4

func (db *APIServerDockerDriver) ImageRef(repo string) string

func (*APIServerDockerDriver) Init added in v0.8.4

func (db *APIServerDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*APIServerDockerDriver) PullPolicy added in v0.8.4

func (db *APIServerDockerDriver) PullPolicy() string

func (*APIServerDockerDriver) Start

func (d *APIServerDockerDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	serviceName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*APIServerDockerDriver) Stop

func (d *APIServerDockerDriver) Stop(orgID uuid.UUID, serviceName string)

Stop implements the Driver interface.

type APIServerSupervisorDriver

type APIServerSupervisorDriver struct {
	// LogsDir is the directory where logs will be written
	LogsDir string
	// contains filtered or unexported fields
}

APIServerSupervisorDriver implements the Driver interface for process supervision.

func NewAPIServerSupervisorDriver

func NewAPIServerSupervisorDriver() *APIServerSupervisorDriver

NewAPIServerSupervisorDriver creates a new Supervisor driver with default configuration.

func (*APIServerSupervisorDriver) GetAddr

GetAddr implements the Driver interface.

func (*APIServerSupervisorDriver) Start

func (d *APIServerSupervisorDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	serviceName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*APIServerSupervisorDriver) Stop

func (d *APIServerSupervisorDriver) Stop(orgID uuid.UUID, serviceName string)

Stop implements the Driver interface.

type BackplaneDockerDriver

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

BackplaneDockerDriver implements the Driver interface for Docker.

func NewBackplaneDockerDriver

func NewBackplaneDockerDriver() *BackplaneDockerDriver

NewBackplaneDockerDriver creates a new Docker driver for backplane.

func (*BackplaneDockerDriver) GetAddr

func (d *BackplaneDockerDriver) GetAddr(ctx context.Context) (string, error)

GetAddr implements the Driver interface.

func (*BackplaneDockerDriver) ImageRef added in v0.8.4

func (db *BackplaneDockerDriver) ImageRef(repo string) string

func (*BackplaneDockerDriver) Init added in v0.8.4

func (db *BackplaneDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*BackplaneDockerDriver) PullPolicy added in v0.8.4

func (db *BackplaneDockerDriver) PullPolicy() string

func (*BackplaneDockerDriver) Start

func (d *BackplaneDockerDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*BackplaneDockerDriver) Stop

func (d *BackplaneDockerDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type BackplaneSupervisorDriver

type BackplaneSupervisorDriver struct {
	// LogsDir is the directory where logs will be written
	LogsDir string
	// contains filtered or unexported fields
}

BackplaneSupervisorDriver implements the Driver interface for process supervision.

func NewBackplaneSupervisorDriver

func NewBackplaneSupervisorDriver() *BackplaneSupervisorDriver

NewBackplaneSupervisorDriver creates a new Supervisor driver with default configuration.

func (*BackplaneSupervisorDriver) GetAddr

GetAddr implements the Driver interface.

func (*BackplaneSupervisorDriver) Start

func (d *BackplaneSupervisorDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*BackplaneSupervisorDriver) Stop

func (d *BackplaneSupervisorDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type Driver

type Driver interface {
	// Start deploys and starts the service.
	Start(ctx context.Context, orgID uuid.UUID, serviceName string, opts ...Option) (string, error)
	// Stop stops the service.
	Stop(orgID uuid.UUID, serviceName string)
	// GetAddr returns the address of the service.
	GetAddr(ctx context.Context) (string, error)
}

Driver is the interface that all service drivers must implement.

func GetAPIServerDriver

func GetAPIServerDriver(driver DriverMode) (Driver, error)

GetAPIServerDriver returns an apiserver driver by name.

func GetBackplaneDriver

func GetBackplaneDriver(driver DriverMode) (Driver, error)

GetBackplaneDriver returns a backplane driver by name.

func GetDriver

func GetDriver(driverType DriverMode, serviceType ServiceType) (Driver, error)

GetDriver returns a driver by name for the specified service type.

func GetTunnelProxyDriver

func GetTunnelProxyDriver(driver DriverMode) (Driver, error)

GetTunnelProxyDriver returns a tunnel proxy driver by name.

type DriverMode

type DriverMode string

DriverMode represents the mode in which the driver is running.

type Option

type Option func(*Options)

Option is a function that configures driver options.

func WithAPIServerAddr

func WithAPIServerAddr(addr string) Option

WithAPIServerAddr sets the apiserver address.

func WithArgs

func WithArgs(args ...string) Option

WithArgs sets the arguments for the driver.

type Options

type Options struct {
	Args          []string
	APIServerAddr string
}

Options contains common options for all drivers.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns the default options.

type ServiceType

type ServiceType string

ServiceType represents the type of service being managed by a driver.

type TunnelProxyDockerDriver

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

TunnelProxyDockerDriver implements the Driver interface for Docker.

func NewTunnelProxyDockerDriver

func NewTunnelProxyDockerDriver() *TunnelProxyDockerDriver

NewTunnelProxyDockerDriver creates a new Docker driver for tunnelproxy.

func (*TunnelProxyDockerDriver) GetAddr

func (d *TunnelProxyDockerDriver) GetAddr(ctx context.Context) (string, error)

GetAddr implements the Driver interface.

func (*TunnelProxyDockerDriver) ImageRef added in v0.8.4

func (db *TunnelProxyDockerDriver) ImageRef(repo string) string

func (*TunnelProxyDockerDriver) Init added in v0.8.4

func (db *TunnelProxyDockerDriver) Init(
	ctx context.Context,
	opts ...Option,
) error

Init initializes the Docker driver.

func (*TunnelProxyDockerDriver) PullPolicy added in v0.8.4

func (db *TunnelProxyDockerDriver) PullPolicy() string

func (*TunnelProxyDockerDriver) Start

func (d *TunnelProxyDockerDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*TunnelProxyDockerDriver) Stop

func (d *TunnelProxyDockerDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

type TunnelProxySupervisorDriver

type TunnelProxySupervisorDriver struct {
	// LogsDir is the directory where logs will be written
	LogsDir string
	// contains filtered or unexported fields
}

TunnelProxySupervisorDriver implements the Driver interface for process supervision.

func NewTunnelProxySupervisorDriver

func NewTunnelProxySupervisorDriver() *TunnelProxySupervisorDriver

NewTunnelProxySupervisorDriver creates a new Supervisor driver with default configuration.

func (*TunnelProxySupervisorDriver) GetAddr

GetAddr implements the Driver interface.

func (*TunnelProxySupervisorDriver) Start

func (d *TunnelProxySupervisorDriver) Start(
	ctx context.Context,
	orgID uuid.UUID,
	proxyName string,
	opts ...Option,
) (string, error)

Start implements the Driver interface.

func (*TunnelProxySupervisorDriver) Stop

func (d *TunnelProxySupervisorDriver) Stop(orgID uuid.UUID, proxyName string)

Stop implements the Driver interface.

Jump to

Keyboard shortcuts

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