context

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 16 Imported by: 40

Documentation

Index

Constants

View Source
const (
	SystemCertCA   = "ca.pem"
	SystemCertCrt  = "crt.pem"
	SystemCertKey  = "key.pem"
	SystemCertPath = "var/lib/baetyl/system/certs"
)
View Source
const (
	KeyBaetyl             = "BAETYL"
	KeyConfFile           = "BAETYL_CONF_FILE"
	KeyNodeName           = "BAETYL_NODE_NAME"
	KeyAppName            = "BAETYL_APP_NAME"
	KeyAppVersion         = "BAETYL_APP_VERSION"
	KeySvcName            = "BAETYL_SERVICE_NAME"
	KeySysConf            = "BAETYL_SYSTEM_CONF"
	KeyRunMode            = "BAETYL_RUN_MODE"
	KeyServiceDynamicPort = "BAETYL_SERVICE_DYNAMIC_PORT"
	KeyBaetylHostPathLib  = "BAETYL_HOST_PATH_LIB"
)

All keys

View Source
const (
	RunModeKube   = "kube"
	RunModeNative = "native"
)

Variables

View Source
var (
	ErrSystemCertInvalid  = errors.New("system certificate is invalid")
	ErrSystemCertNotFound = errors.New("system certificate is not found")
)

Functions

func BrokerHost added in v2.0.55

func BrokerHost() string

BrokerHost return broker host.

func BrokerPort added in v2.0.55

func BrokerPort() string

BrokerPort return broker port.

func EdgeNamespace added in v2.0.55

func EdgeNamespace() string

EdgeNamespace return namespace of edge.

func EdgeSystemNamespace added in v2.0.55

func EdgeSystemNamespace() string

EdgeSystemNamespace return system namespace of edge.

func FunctionHost added in v2.0.55

func FunctionHost() string

FunctionHost return function host.

func FunctionHttpPort added in v2.0.55

func FunctionHttpPort() string

FunctionPort return http port of function.

func HostPathLib added in v2.0.54

func HostPathLib() (string, error)

HostPathLib return HostPathLib

func PlatformString added in v2.0.36

func PlatformString() string

func Run

func Run(handle func(Context) error)

Run service

func RunMode added in v2.0.36

func RunMode() string

RunMode return run mode of edge.

Types

type Context

type Context interface {
	// NodeName returns node name from data.
	NodeName() string
	// AppName returns app name from data.
	AppName() string
	// AppVersion returns application version from data.
	AppVersion() string
	// ServiceName returns service name from data.
	ServiceName() string
	// ConfFile returns config file from data.
	ConfFile() string

	// SystemConfig returns the config of baetyl system from data.
	SystemConfig() *SystemConfig

	// Log returns logger interface.
	Log() *log.Logger

	// Wait waits until exit, receiving SIGTERM and SIGINT signals.
	Wait()
	// WaitChan returns wait channel.
	WaitChan() <-chan os.Signal

	// Load returns the value stored in the map for a key, or nil if no value is present.
	// The ok result indicates whether value was found in the map.
	Load(key interface{}) (value interface{}, ok bool)
	// Store sets the value for a key.
	Store(key, value interface{})
	// LoadOrStore returns the existing value for the key if present.
	// Otherwise, it stores and returns the given value.
	// The loaded result is true if the value was loaded, false if stored.
	LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
	// Delete deletes the value for a key.
	Delete(key interface{})

	// CheckSystemCert checks system certificate, if certificate is not found or invalid, returns an error.
	CheckSystemCert() error
	// LoadCustomConfig loads custom config.
	// If 'files' is empty, will load config from default path,
	// else the first file path will be used to load config from.
	LoadCustomConfig(cfg interface{}, files ...string) error
	// NewFunctionHttpClient creates a new function http client.
	NewFunctionHttpClient() (*http.Client, error)
	// NewSystemBrokerClientConfig creates the system config of broker
	NewSystemBrokerClientConfig() (mqtt.ClientConfig, error)
	// NewBrokerClient creates a new broker client.
	NewBrokerClient(mqtt.ClientConfig) (*mqtt.Client, error)
	// NewSystemBrokerClient creates a new system broker client.
	NewSystemBrokerClient([]mqtt.QOSTopic) (*mqtt.Client, error)
}

Context of service

func NewContext

func NewContext(confFile string) Context

NewContext creates a new context

type PlatformInfo added in v2.0.36

type PlatformInfo = specs.Platform

func Platform added in v2.0.36

func Platform() PlatformInfo

type SystemConfig added in v2.0.21

type SystemConfig struct {
	Certificate utils.Certificate `` /* 198-byte string literal not displayed */
	Function    http.ClientConfig `yaml:"function,omitempty" json:"function,omitempty"`
	Broker      mqtt.ClientConfig `yaml:"broker,omitempty" json:"broker,omitempty"`
	Logger      log.Config        `yaml:"logger,omitempty" json:"logger,omitempty"`
}

SystemConfig config of baetyl system

Jump to

Keyboard shortcuts

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