service

package
v0.0.0-...-a5cc226 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const PriorityMax = 5

Variables

This section is empty.

Functions

func Add

func Add(priority int, factory Factory)

Global service manager apis

func Run

func Run(server string, opts map[string]interface{}) error

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

type Factory

type Factory interface {
	Create(map[string]interface{}) (Service, error)
}

type Lifecycle

type Lifecycle struct {
	Listener        net.Listener
	Server          *grpc.Server
	RegisterService func()
}

Lifecycle implements the lifecycle operations for microservice including dynamic service registration.

func (*Lifecycle) GetListenerAddress

func (s *Lifecycle) GetListenerAddress() string

GetListenerAddress will get the address and port the service is listening. Returns the empty string if the service is not running but the method is invoked.

func (*Lifecycle) Start

func (s *Lifecycle) Start(port int, background bool)

Start will start a gRPC microservice on a given port and run it either in foreground or background.

func (*Lifecycle) Stop

func (s *Lifecycle) Stop()

Stop will stop the gRPC microservice and the socket.

type LifecycleHandler

type LifecycleHandler interface {
	Start(port int, background bool)
	Stop()
	GetListenerAddress() string
}

LifecycleHandler provides basic lifecycle methods that each microservice has to implement.

type Service

type Service interface {
	Name() string
	Start() error
	Shutdown()
}

func GetService

func GetService(name string) Service

type ServiceManager

type ServiceManager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *ServiceManager

func (*ServiceManager) Add

func (s *ServiceManager) Add(priority int, factory Factory)

func (*ServiceManager) GetService

func (p *ServiceManager) GetService(name string) Service

GetService return service instance by name, or matched by part of name

func (*ServiceManager) Run

func (s *ServiceManager) Run(server string, opts map[string]interface{}) error

func (*ServiceManager) Shutdown

func (s *ServiceManager) Shutdown(code int, reason string)

Shutdown

Jump to

Keyboard shortcuts

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