context

package
v0.1.92 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EnvKeyConfFile    = "BAETYL_CONF_FILE"
	EnvKeyNodeName    = "BAETYL_NODE_NAME"
	EnvKeyAppName     = "BAETYL_APP_NAME"
	EnvKeyServiceName = "BAETYL_SERVICE_NAME"
	EnvKeyCodePath    = "BAETYL_CODE_PATH"
)

Env keys

Variables

This section is empty.

Functions

func Run

func Run(handle func(Context) error)

Run service

Types

type Context

type Context interface {
	// NodeName returns node name.
	NodeName() string
	// AppName returns app name.
	AppName() string
	// ServiceName returns service name.
	ServiceName() string
	// ConfFile returns config file.
	ConfFile() string
	// ServiceConfig returns service config.
	ServiceConfig() ServiceConfig

	// 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{})

	// LoadCustomConfig loads custom config, if path is empty, will load config from default path.
	LoadCustomConfig(cfg interface{}, files ...string) error
	// 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
}

Context of service

func NewContext added in v0.1.12

func NewContext(confFile string) Context

NewContext creates a new context

type ServiceConfig

type ServiceConfig struct {
	HTTP   http.ClientConfig `yaml:"http,omitempty" json:"http,omitempty"`
	MQTT   mqtt.ClientConfig `yaml:"mqtt,omitempty" json:"mqtt,omitempty"`
	Logger log.Config        `yaml:"logger,omitempty" json:"logger,omitempty"`
}

ServiceConfig base config of service

Jump to

Keyboard shortcuts

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