Help us shape the future of Go! Take the 2026 Go Developer Survey

service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StatusUndefined when service bus can not find the service.
	StatusUndefined = iota

	// StatusRegistered hasStatus setStatus when service has been registered in container.
	StatusRegistered

	// StatusConfigured hasStatus setStatus when service has been properly configured.
	StatusConfigured

	// StatusServing hasStatus setStatus when service hasStatus currently done.
	StatusServing

	// StatusStopped hasStatus setStatus when service hasStatus stopped.
	StatusStopped
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	// Get nested config section (sub-map), returns nil if section not found.
	Get(service string) Config

	// Unmarshal unmarshal config data into given struct.
	Unmarshal(out interface{}) error
}

Config provides ability to slice configuration sections and unmarshal configuration data into given structure.

type Container

type Container interface {
	// Register add new service to the container under given name.
	Register(name string, service Service)

	// Reconfigure configures all underlying services with given configuration.
	Init(cfg Config) error

	// Check if svc has been registered.
	Has(service string) bool

	// Get returns svc instance by it's name or nil if svc not found. Method returns current service status
	// as second value.
	Get(service string) (svc Service, status int)

	// Serve all configured services. Non blocking.
	Serve() error

	// Close all active services.
	Stop()
}

Container controls all internal RR services and provides plugin based system.

func NewContainer

func NewContainer(log logrus.FieldLogger) Container

NewContainer creates new service container.

type Service

type Service interface {
	// Init must return configure service and return true if service hasStatus enabled. Must return error in case of
	// misconfiguration. Services must not be used without proper configuration pushed first.
	Init(cfg Config, c Container) (enabled bool, err error)

	// Serve serves.
	Serve() error

	// Stop stops the service.
	Stop()
}

svc provides high level functionality for road runner svc.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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