aiicy

package module
v0.0.0-...-d840a7c Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 7 Imported by: 1

README

aiicy-go

GitHub Actions codecov License

Go SDK for Aiicy

The design of service management, instance control and wrapper for mqtt comes from baetyl, it's license at LICENSES/baetyl.

License

Apache 2.0

Copyright (c) 2019-present Codist

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateComposeAppConfigCompatible

func CreateComposeAppConfigCompatible(cfg ComposeAppConfig, configFile string) error

TODO: need test CreateComposeAppConfigCompatible create compose app config

Types

type BackoffInfo

type BackoffInfo struct {
	Min    time.Duration `yaml:"min" json:"min" default:"1s" validate:"min=1000000000"`
	Max    time.Duration `yaml:"max" json:"max" default:"5m" validate:"min=1000000000"`
	Factor float64       `yaml:"factor" json:"factor" default:"2" validate:"min=1"`
}

BackoffInfo holds backoff value

type CPU

type CPU struct {
	Cpus    float64 `yaml:"cpus" json:"cpus"`
	SetCPUs string  `yaml:"setcpus" json:"setcpus"`
}

CPU cpu config

type Command

type Command struct {
	Cmd []string `yaml:"cmd" json:"cmd" default:"[]"`
}

Command command configuration of the service

func (Command) MarshalYAML

func (c Command) MarshalYAML() (interface{}, error)

func (*Command) UnmarshalJSON

func (c *Command) UnmarshalJSON(b []byte) error

UnmarshalJSON customize Command unmarshal

func (*Command) UnmarshalYAML

func (c *Command) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML customize Command unmarshal

type ComposeAppConfig

type ComposeAppConfig struct {
	// specifies the version of compose file
	Version string `yaml:"version,omitempty" json:"version,omitempty"`
	// specifies name of the application
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	// specifies the app version of the application configuration
	AppVersion string `yaml:"app_version,omitempty" json:"app_version,omitempty"`
	// specifies the service information of the application
	Services map[string]ComposeService `yaml:"services,omitempty" json:"services,omitempty" default:"{}"`
	// specifies the storage volume information of the application
	Volumes map[string]ComposeVolume `yaml:"volumes,omitempty" json:"volumes,omitempty" default:"{}"`
	// specifies the network information of the application
	Networks map[string]ComposeNetwork `yaml:"networks,omitempty" json:"networks,omitempty" default:"{}"`
}

ComposeAppConfig application configuration of compose

func LoadComposeAppConfigCompatible

func LoadComposeAppConfigCompatible(configFile string) (cfg ComposeAppConfig, err error)

LoadComposeAppConfigCompatible load compose app config

type ComposeNetwork

type ComposeNetwork struct {
	// specifies driver for network
	Driver string `yaml:"driver,omitempty" json:"driver,omitempty" default:"bridge"`
	// specified driver options for network
	DriverOpts map[string]string `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" default:"{}"`
	// specifies labels to add metadata
	Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty" default:"{}"`
}

ComposeNetwork

ComposeNetwork network configuration

type ComposeService

type ComposeService struct {
	// specifies the unique name of the service
	ContainerName string `yaml:"container_name,omitempty" json:"container_name,omitempty"`
	// specifies the hostname of the service
	Hostname string `yaml:"hostname,omitempty" json:"hostname,omitempty"`
	// specifies the image of the service, usually using the Docker image name
	Image string `yaml:"image,omitempty" json:"image,omitempty" validate:"nonzero"`
	// specifies the number of instances started
	Replica int `yaml:"replica,omitempty" json:"replica,omitempty" validate:"min=0"`
	// specifies the storage volumes that the service needs, map the storage volume to the directory in the container
	Volumes []ServiceVolume `yaml:"volumes,omitempty" json:"volumes,omitempty"`
	// specifies the network mode of the service
	NetworkMode string `yaml:"network_mode,omitempty" json:"network_mode,omitempty" validate:"regexp=^(bridge|host|none)?$"`
	// specifies the network that the service needs
	Networks NetworksInfo `yaml:"networks,omitempty" json:"networks,omitempty"`
	// specifies the port bindings which exposed by the service, only for Docker container mode
	Ports []string `yaml:"ports,omitempty" json:"ports,omitempty" default:"[]"`
	// specifies the device bindings which used by the service, only for Docker container mode
	Devices []string `yaml:"devices,omitempty" json:"devices,omitempty" default:"[]"`
	// specified other depended services
	DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty" default:"[]"`
	// specifies the startup arguments of the service program, but does not include `arg[0]`
	Command Command `yaml:"command,omitempty" json:"command,omitempty" default:"{}"`
	// specifies the environment variable of the service program
	Environment Environment `yaml:"environment,omitempty" json:"environment,omitempty" default:"{}"`
	// specifies the restart policy of the instance of the service
	Restart RestartPolicyInfo `yaml:"restart,omitempty" json:"restart,omitempty"`
	// specifies resource limits for a single instance of the service,  only for Docker container mode
	Resources Resources `yaml:"resources,omitempty" json:"resources,omitempty"`
	// specifies runtime to use, only for Docker container mode
	Runtime string `yaml:"runtime,omitempty" json:"runtime,omitempty"`
}

ComposeService

ComposeService service configuration of compose

type ComposeVolume

type ComposeVolume struct {
	// specified driver for the storage volume
	Driver string `yaml:"driver,omitempty" json:"driver,omitempty" default:"local"`
	// specified driver options for the storage volume
	DriverOpts map[string]string `yaml:"driver_opts,omitempty" json:"driver_opts,omitempty" default:"{}"`
	// specified labels for the storage volume
	Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty" default:"{}"`
}

ComposeVolume

ComposeVolume volume configuration of compose

type Environment

type Environment struct {
	Envs map[string]string `yaml:"envs" json:"envs" default:"{}"`
}

Environment environment

func (Environment) MarshalYAML

func (e Environment) MarshalYAML() (interface{}, error)

func (*Environment) UnmarshalJSON

func (e *Environment) UnmarshalJSON(b []byte) error

func (*Environment) UnmarshalYAML

func (e *Environment) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML customize unmarshal

type FunctionClientConfig

type FunctionClientConfig struct {
	Address string `yaml:"address" json:"address"`
	Message struct {
		Length utils.Length `yaml:"length" json:"length" default:"{\"max\":4194304}"`
	} `yaml:"message" json:"message"`
	Backoff struct {
		Max time.Duration `yaml:"max" json:"max" default:"1m"`
	} `yaml:"backoff" json:"backoff"`
	Timeout time.Duration `yaml:"timeout" json:"timeout" default:"30s"`
}

FunctionClientConfig function client config

type Memory

type Memory struct {
	Limit int64 `yaml:"limit" json:"limit"`
	Swap  int64 `yaml:"swap" json:"swap"`
}

Memory memory config

func (*Memory) UnmarshalYAML

func (m *Memory) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML customizes unmarshal

type Meta

type Meta struct {
	URL     string `yaml:"url" json:"url"`
	MD5     string `yaml:"md5" json:"md5"`
	Version string `yaml:"version" json:"version"`
}

type NetworksInfo

type NetworksInfo struct {
	ServiceNetworks map[string]ServiceNetwork `yaml:"networks" json:"networks"`
}

NetworksInfo network configurations of service

func (*NetworksInfo) UnmarshalYAML

func (sn *NetworksInfo) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML customizes unmarshal

type Pids

type Pids struct {
	Limit int64 `yaml:"limit" json:"limit"`
}

Pids pids config

type Resources

type Resources struct {
	CPU    CPU    `yaml:"cpu" json:"cpu"`
	Pids   Pids   `yaml:"pids" json:"pids"`
	Memory Memory `yaml:"memory" json:"memory"`
}

Resources resources config

type RestartPolicyInfo

type RestartPolicyInfo struct {
	Retry struct {
		Max int `yaml:"max" json:"max"`
	} `yaml:"retry" json:"retry"`
	Policy  string      `yaml:"policy" json:"policy" default:"always"`
	Backoff BackoffInfo `yaml:"backoff" json:"backoff"`
}

RestartPolicyInfo holds the policy of a module

type ServiceNetwork

type ServiceNetwork struct {
	Aliases     []string `yaml:"aliases" json:"aliases"`
	Ipv4Address string   `yaml:"ipv4_address" json:"ipv4_address"`
}

ServiceNetwork specific network configuration of service

type ServiceVolume

type ServiceVolume struct {
	// specifies type of volume
	Type string `yaml:"type,omitempty" json:"type,omitempty" validate:"regexp=^(volume|bind)?$"`
	// specifies source of volume
	Source string `yaml:"source,omitempty" json:"source,omitempty"`
	// specifies target of volume
	Target string `yaml:"target,omitempty" json:"target,omitempty"`
	// specifies if the volume is read-only
	ReadOnly bool `yaml:"read_only,omitempty" json:"read_only,omitempty"`
}

ServiceVolume specific volume configuration of service

func (ServiceVolume) MarshalYAML

func (sv ServiceVolume) MarshalYAML() (interface{}, error)

MarshalYAML customize ServiceVolume marshal

func (*ServiceVolume) UnmarshalYAML

func (sv *ServiceVolume) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML customize ServiceVolume unmarshal

type VolumeInfo

type VolumeInfo struct {
	// specifies a unique name for the storage volume
	Name string `yaml:"name" json:"name" validate:"regexp=^[a-zA-Z0-9][a-zA-Z0-9_-]{0\\,63}$"`
	// specifies the directory where the storage volume is on the host
	Path string `yaml:"path" json:"path" validate:"nonzero"`
	// specifies the metadata of the storage volume
	Meta Meta `yaml:"meta" json:"meta"`
}

VolumeInfo storage volume configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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