context

package
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: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKeyConfFile               = "AIICY_CONF_FILE"
	EnvKeyServiceMode            = "AIICY_SERVICE_MODE"
	EnvKeyServiceName            = "AIICY_SERVICE_NAME"
	EnvKeyServiceInstanceName    = "AIICY_SERVICE_INSTANCE_NAME"
	EnvKeyServiceInstanceAddress = "AIICY_SERVICE_INSTANCE_ADDRESS"
)

Env keys

View Source
const (
	DefaultHubAddressTCP = "tcp://aiicy-hub:1883"
	DefaultHubAddressSSL = "ssl://aiicy-hub:8883"
)

API keys

View Source
const (
	// DefaultConfFile config path of the service by default
	DefaultConfFile = "etc/aiicy/service.yml"
)

Path keys

Variables

This section is empty.

Functions

func Run

func Run(handle func(Context) error)

Run service

Types

type Context

type Context interface {
	// InstanceName returns instance name.
	InstanceName() string
	// ServiceName returns service name.
	ServiceName() string
	// ConfFile returns config file.
	ConfFile() string
	// ServiceConfig returns service config.
	ServiceConfig() ServiceConfig
	// LoadCustomConfig loads custom config, if path is empty, will load config from default path.
	LoadCustomConfig(cfg interface{}, files ...string) error
	// returns logger interface
	Log() *logger.Logger
	// waiting to exit, receiving SIGTERM and SIGINT signals
	Wait()
	// returns wait channel
	WaitChan() <-chan os.Signal
}

Context of service

func NewContext

func NewContext(confFile string) Context

NewContext creates a new context

type ServiceConfig

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

ServiceConfig base config of service

Jump to

Keyboard shortcuts

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