context

package
v2.0.31 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2020 License: Apache-2.0 Imports: 14 Imported by: 40

Documentation

Index

Constants

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"
	KeyBrokerHost          = "BAETYL_BROKER_HOST"
	KeyBrokerPort          = "BAETYL_BROKER_PORT"
	KeyFunctionHost        = "BAETYL_FUNCTION_HOST"
	KeyFunctionHttpPort    = "BAETYL_FUNCTION_HTTP_PORT"
	KeyEdgeNamespace       = "BAETYL_EDGE_NAMESPACE"
	KeyEdgeSystemNamespace = "BAETYL_EDGE_SYSTEM_NAMESPACE"

	BaetylEdgeNamespace          = "baetyl-edge"
	BaetylEdgeSystemNamespace    = "baetyl-edge-system"
	BaetylBrokerSystemPort       = "50010"
	BaetylFunctionSystemHttpPort = "50011"
	BaetylFunctionSystemGrpcPort = "50012"

	RunModeKube   = "kube"
	RunModeNative = "native"
)

All keys

Variables

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

Functions

func Run

func Run(handle func(Context) error)

Run service

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
	// RunMode return run mode.
	RunMode() string
	// BrokerHost return broker host.
	BrokerHost() string
	// BrokerPort return broker port.
	BrokerPort() string
	// FunctionHost return function host.
	FunctionHost() string
	// FunctionHttpPort return http port of function.
	FunctionHttpPort() string
	// EdgeNamespace return namespace of edge.
	EdgeNamespace() string
	// EdgeSystemNamespace return system namespace of edge.
	EdgeSystemNamespace() 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)
}

Context of service

func NewContext

func NewContext(confFile string) Context

NewContext creates a new context

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