openedge

package
v0.0.0-...-53e3d08 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RestartNo        = "no"
	RestartAlways    = "always"
	RestartOnFailure = "on-failure"
)

RestartPolicies

View Source
const (
	ModeNative = "native"
	ModeDocker = "docker"
)

Mode keys

View Source
const (
	EnvHostOSKey                 = "OPENEDGE_HOST_OS"
	EnvMasterAPIKey              = "OPENEDGE_MASTER_API"
	EnvMasterAPIVersionKey       = "OPENEDGE_MASTER_API_VERSION"
	EnvRunningModeKey            = "OPENEDGE_RUNNING_MODE"
	EnvServiceNameKey            = "OPENEDGE_SERVICE_NAME"
	EnvServiceTokenKey           = "OPENEDGE_SERVICE_TOKEN"
	EnvServiceAddressKey         = "OPENEDGE_SERVICE_ADDRESS" // deprecated
	EnvServiceInstanceNameKey    = "OPENEDGE_SERVICE_INSTANCE_NAME"
	EnvServiceInstanceAddressKey = "OPENEDGE_SERVICE_INSTANCE_ADDRESS"

	EnvMasterHostSocketKey = "OPENEDGE_MASTER_HOST_SOCKET"
)

Env keys

View Source
const (
	// AppConfFileName application config file name
	AppConfFileName = "application.yml"
	// AppBackupFileName application backup configuration file
	AppBackupFileName = "application.yml.old"
	// AppStatsFileName application stats file name
	AppStatsFileName = "application.stats"
	// DefaultSockFile sock file of openedge by default
	DefaultSockFile = "var/run/openedge.sock"
	// DefaultPidFile pid file of openedge by default
	DefaultPidFile = "/var/run/openedge.pid"
	// DefaultConfFile config path of the service by default
	DefaultConfFile = "etc/openedge/service.yml"
	// DefaultDBDir db dir of the service by default
	DefaultDBDir = "var/db/openedge"
	// DefaultRunDir  run dir of the service by default
	DefaultRunDir = "var/run/openedge"
	// DefaultLogDir  log dir of the service by default
	DefaultLogDir = "var/log/openedge"
)

Path keys

Variables

This section is empty.

Functions

func RegisterFunctionServer

func RegisterFunctionServer(s *grpc.Server, srv FunctionServer)

func Run

func Run(handle func(Context) error)

Run service

Types

type AppConfig

type AppConfig struct {
	// specifies the version of the application configuration
	Version string `yaml:"version" json:"version"`
	// specifies the service information of the application
	Services []ServiceInfo `yaml:"services" json:"services" default:"[]"`
	// specifies the storage volume information of the application
	Volumes []VolumeInfo `yaml:"volumes" json:"volumes" default:"[]"`
}

AppConfig application configuration

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 Call

Call message handler

type Client

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

Client client of api server

func NewClient

func NewClient(c http.ClientInfo, ver string) (*Client, error)

NewClient creates a new client

func NewEnvClient

func NewEnvClient() (*Client, error)

NewEnvClient creates a new client by env

func (*Client) GetAvailablePort

func (c *Client) GetAvailablePort() (string, error)

GetAvailablePort gets available port

func (*Client) InspectSystem

func (c *Client) InspectSystem() (*Inspect, error)

InspectSystem inspect all stats

func (*Client) ReportInstance

func (c *Client) ReportInstance(serviceName, instanceName string, stats map[string]interface{}) error

ReportInstance reports the stats of the instance of the service

func (*Client) StartInstance

func (c *Client) StartInstance(serviceName, instanceName string, dynamicConfig map[string]string) error

StartInstance starts a new service instance with dynamic config

func (*Client) StopInstance

func (c *Client) StopInstance(serviceName, instanceName string) error

StopInstance stops a service instance

func (*Client) UpdateSystem

func (c *Client) UpdateSystem(path string) error

UpdateSystem updates and reloads config

type Context

type Context interface {
	// returns the system configuration of the service, such as hub and logger
	Config() *ServiceConfig
	// loads the custom configuration of the service
	LoadConfig(interface{}) error
	// creates a Client that connects to the Hub through system configuration,
	// you can specify the Client ID and the topic information of the subscription.
	NewHubClient(string, []mqtt.TopicInfo) (*mqtt.Dispatcher, error)
	// returns logger interface
	Log() logger.Logger
	// check running mode
	IsNative() bool
	// waiting to exit, receiving SIGTERM and SIGINT signals
	Wait()
	// returns wait channel
	WaitChan() <-chan os.Signal

	// updates system and
	UpdateSystem(string) error
	// inspects system stats
	InspectSystem() (*Inspect, error)
	// gets an available port of the host
	GetAvailablePort() (string, error)
	// reports the stats of the instance of the service
	ReportInstance(stats map[string]interface{}) error
	// starts an instance of the service
	StartInstance(serviceName, instanceName string, dynamicConfig map[string]string) error
	// stop the instance of the service
	StopInstance(serviceName, instanceName string) error
}

Context of service

type FClient

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

FClient client of functions server

func NewFClient

func NewFClient(cc FunctionClientConfig) (*FClient, error)

NewFClient creates a new client of functions server

func (*FClient) Call

func (c *FClient) Call(msg *FunctionMessage) (*FunctionMessage, error)

Call sends request to functions server

func (*FClient) Close

func (c *FClient) Close() error

Close closes the client

type FServer

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

FServer functions server to handle message

func NewFServer

func NewFServer(c FunctionServerConfig, call Call) (*FServer, error)

NewFServer creates a new functions server

func (*FServer) Call

Call handles message

func (*FServer) Close

func (s *FServer) Close()

Close closes server

type FunctionClient

type FunctionClient interface {
	Call(ctx context.Context, in *FunctionMessage, opts ...grpc.CallOption) (*FunctionMessage, error)
}

FunctionClient is the client API for Function service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewFunctionClient

func NewFunctionClient(cc *grpc.ClientConn) FunctionClient

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 FunctionMessage

type FunctionMessage struct {
	ID                   uint64   `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	QOS                  uint32   `protobuf:"varint,2,opt,name=QOS,proto3" json:"QOS,omitempty"`
	Topic                string   `protobuf:"bytes,3,opt,name=Topic,proto3" json:"Topic,omitempty"`
	Payload              []byte   `protobuf:"bytes,4,opt,name=Payload,proto3" json:"Payload,omitempty"`
	Timestamp            int64    `protobuf:"zigzag64,10,opt,name=Timestamp,proto3" json:"Timestamp,omitempty"`
	FunctionName         string   `protobuf:"bytes,11,opt,name=FunctionName,proto3" json:"FunctionName,omitempty"`
	FunctionInvokeID     string   `protobuf:"bytes,12,opt,name=FunctionInvokeID,proto3" json:"FunctionInvokeID,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

FunctionMessage function message

func (*FunctionMessage) Descriptor

func (*FunctionMessage) Descriptor() ([]byte, []int)

func (*FunctionMessage) GetFunctionInvokeID

func (m *FunctionMessage) GetFunctionInvokeID() string

func (*FunctionMessage) GetFunctionName

func (m *FunctionMessage) GetFunctionName() string

func (*FunctionMessage) GetID

func (m *FunctionMessage) GetID() uint64

func (*FunctionMessage) GetPayload

func (m *FunctionMessage) GetPayload() []byte

func (*FunctionMessage) GetQOS

func (m *FunctionMessage) GetQOS() uint32

func (*FunctionMessage) GetTimestamp

func (m *FunctionMessage) GetTimestamp() int64

func (*FunctionMessage) GetTopic

func (m *FunctionMessage) GetTopic() string

func (*FunctionMessage) ProtoMessage

func (*FunctionMessage) ProtoMessage()

func (*FunctionMessage) Reset

func (m *FunctionMessage) Reset()

func (*FunctionMessage) String

func (m *FunctionMessage) String() string

func (*FunctionMessage) XXX_DiscardUnknown

func (m *FunctionMessage) XXX_DiscardUnknown()

func (*FunctionMessage) XXX_Marshal

func (m *FunctionMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FunctionMessage) XXX_Merge

func (m *FunctionMessage) XXX_Merge(src proto.Message)

func (*FunctionMessage) XXX_Size

func (m *FunctionMessage) XXX_Size() int

func (*FunctionMessage) XXX_Unmarshal

func (m *FunctionMessage) XXX_Unmarshal(b []byte) error

type FunctionServer

type FunctionServer interface {
	Call(context.Context, *FunctionMessage) (*FunctionMessage, error)
}

FunctionServer is the server API for Function service.

type FunctionServerConfig

type FunctionServerConfig struct {
	Address string        `yaml:"address" json:"address"`
	Timeout time.Duration `yaml:"timeout" json:"timeout" default:"2m"`
	Message struct {
		Length utils.Length `yaml:"length" json:"length" default:"{\"max\":4194304}"`
	} `yaml:"message" json:"message"`
	Concurrent struct {
		Max uint32 `yaml:"max" json:"max"`
	} `yaml:"concurrent" json:"concurrent"`
	// for python function server
	Workers struct {
		Max uint32 `yaml:"max" json:"max"`
	} `yaml:"workers" json:"workers"`
	utils.Certificate `yaml:",inline" json:",inline"`
}

FunctionServerConfig function server config

type Hardware

type Hardware struct {
	// host information
	HostInfo *utils.HostInfo `json:"host_stats,omitempty"`
	// net information of host
	NetInfo *utils.NetInfo `json:"net_stats,omitempty"`
	// memory usage information of host
	MemInfo *utils.MemInfo `json:"mem_stats,omitempty"`
	// CPU usage information of host
	CPUInfo *utils.CPUInfo `json:"cpu_stats,omitempty"`
	// disk usage information of host
	DiskInfo *utils.DiskInfo `json:"disk_stats,omitempty"`
	// CPU usage information of host
	GPUInfo *utils.GPUInfo `json:"gpu_stats,omitempty"`
}

Hardware hardware information

type Inspect

type Inspect struct {
	// exception information
	Error string `json:"error,omitempty"`
	// inspect time
	Time time.Time `json:"time,omitempty"`
	// software information
	Software Software `json:"software,omitempty"`
	// hardware information
	Hardware Hardware `json:"hardware,omitempty"`
	// service information, including service name, instance running status, etc.
	Services Services `json:"services,omitempty"`
	// storage volume information, including name and version
	Volumes Volumes `json:"volumes,omitempty"`
}

Inspect all openedge information and status inspected

func NewInspect

func NewInspect() *Inspect

NewInspect create a new information inspected

type InstanceStatus

type InstanceStatus map[string]interface{}

InstanceStatus service instance status

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 MountInfo

type MountInfo struct {
	// specifies the name of the mapped 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 in the container
	Path string `yaml:"path" json:"path" validate:"nonzero"`
	// specifies the operation permission of the storage volume, read-only or writable
	ReadOnly bool `yaml:"readonly" json:"readonly"`
}

MountInfo storage volume mapping configuration

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 ServiceConfig

type ServiceConfig struct {
	Hub    mqtt.ClientInfo `yaml:"hub" json:"hub"`
	Logger logger.LogInfo  `yaml:"logger" json:"logger"`
}

ServiceConfig base config of service

type ServiceInfo

type ServiceInfo struct {
	// specifies the unique name of the service
	Name string `yaml:"name" json:"name" validate:"regexp=^[a-zA-Z0-9][a-zA-Z0-9_-]{0\\,63}$"`
	// specifies the image of the service, usually using the Docker image name
	Image string `yaml:"image" json:"image" validate:"nonzero"`
	// specifies the number of instances started
	Replica int `yaml:"replica" json:"replica" validate:"min=0"`
	// specifies the storage volumes that the service needs, map the storage volume to the directory in the container
	Mounts []MountInfo `yaml:"mounts" json:"mounts" default:"[]"`
	// specifies the port bindings which exposed by the service, only for Docker container mode
	Ports []string `yaml:"ports" json:"ports" default:"[]"`
	// specifies the device bindings which used by the service, only for Docker container mode
	Devices []string `yaml:"devices" json:"devices" default:"[]"`
	// specifies the startup arguments of the service program, but does not include `arg[0]`
	Args []string `yaml:"args" json:"args" default:"[]"`
	// specifies the environment variable of the service program
	Env map[string]string `yaml:"env" json:"env" default:"{}"`
	// specifies the restart policy of the instance of the service
	Restart RestartPolicyInfo `yaml:"restart" json:"restart"`
	// specifies resource limits for a single instance of the service,  only for Docker container mode
	Resources Resources `yaml:"resources" json:"resources"`
	// specifies runtime to use, only for Docker container mode
	Runtime string `yaml:"runtime" json:"runtime"`
}

ServiceInfo service configuration

type ServiceStatus

type ServiceStatus struct {
	Name      string           `json:"name,omitempty"`
	Instances []InstanceStatus `json:"instances,omitempty"`
}

ServiceStatus service status

func NewServiceStatus

func NewServiceStatus(name string) ServiceStatus

NewServiceStatus create a new service status

type Services

type Services []ServiceStatus

Services all services' information

type Software

type Software struct {
	// operating system information of host
	OS string `json:"os,omitempty"`
	// CPU information of host
	Arch string `json:"arch,omitempty"`
	// OpenEdge process work directory
	PWD string `json:"pwd,omitempty"`
	// OpenEdge running mode of application services
	Mode string `json:"mode,omitempty"`
	// OpenEdge compiled Golang version
	GoVersion string `json:"go_version,omitempty"`
	// OpenEdge release version
	BinVersion string `json:"bin_version,omitempty"`
	// OpenEdge loaded application configuration version
	ConfVersion string `json:"conf_version,omitempty"`
}

Software software information

type UnimplementedFunctionServer

type UnimplementedFunctionServer struct {
}

UnimplementedFunctionServer can be embedded to have forward compatible implementations.

func (*UnimplementedFunctionServer) Call

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 struct {
		URL     string `yaml:"url" json:"url"`
		MD5     string `yaml:"md5" json:"md5"`
		Version string `yaml:"version" json:"version"`
	} `yaml:"meta" json:"meta"`
}

VolumeInfo storage volume configuration

type VolumeStatus

type VolumeStatus struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

VolumeStatus volume status

type Volumes

type Volumes []VolumeStatus

Volumes all volumes' information

Jump to

Keyboard shortcuts

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