service

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: MIT Imports: 20 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(app Service)

Run runs the service

func Since added in v0.0.18

func Since() time.Duration

Since returns duration since started time

Types

type BaseService

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

BaseService implements Service

func NewBaseService

func NewBaseService(self Service, cfg config.Configurator) *BaseService

NewBaseService creates a BaseService

func (*BaseService) AddModule added in v0.0.18

func (app *BaseService) AddModule(mod module.Module) module.Module

AddModule adds a module to service

func (*BaseService) Busy added in v0.0.18

func (app *BaseService) Busy() bool

Busy implements Service Busy method

func (*BaseService) Discovery added in v0.0.18

func (app *BaseService) Discovery() discovery.Discovery

Discovery returns the discovery engine

func (*BaseService) ID

func (app *BaseService) ID() int64

ID implements Service ID method

func (*BaseService) Init

func (app *BaseService) Init() error

Init implements Service Init method

func (*BaseService) MQ added in v0.0.18

func (app *BaseService) MQ() mq.Conn

MQ returns the mq engine

func (*BaseService) Name

func (app *BaseService) Name() string

Name implements Service Name method

func (*BaseService) SetState added in v0.0.18

func (app *BaseService) SetState(state State) error

SetState implements Service SetState method

func (*BaseService) Shutdown

func (app *BaseService) Shutdown() error

Shutdown implements Service Shutdown method

func (*BaseService) Start

func (app *BaseService) Start() error

Start implements Service Start method

func (*BaseService) State added in v0.0.18

func (app *BaseService) State() State

State returns state of service

func (*BaseService) UUID added in v0.0.18

func (app *BaseService) UUID() string

UUID implements service UUID method

func (*BaseService) Update

func (app *BaseService) Update(now time.Time, dt time.Duration)

Update updates per frame

type ConfigRewriter added in v0.0.18

type ConfigRewriter interface {
	RewriteConfig(unsafe.Pointer)
}

ConfigRewriter rewrites Config

type DiscoveryContent added in v0.0.18

type DiscoveryContent struct {
	Config any `json:"config"` // config of service
	State  struct {
		Updated int64  `json:"updated"`
		PID     int    `json:"pid"`   // process id
		State   State  `json:"state"` // run state
		UUID    string `json:"uuid"`  // instance uuid
	} `json:"state"` // runtime state of service
}

DiscoveryContent is the content for registering

type Meta added in v0.0.18

type Meta interface {
	// ID returns id of service
	ID() int64
	// Name of service
	Name() string
	// Global unique instance id of service
	UUID() string
	// Busy reports whether the service is busy
	Busy() bool
	// State returns state of service
	State() State
}

Meta represents metadata of service

type Service

type Service interface {
	Meta

	// SetState sets state of service
	SetState(state State) error
	// Init initializes the service
	Init() error
	// Start starts the service
	Start() error
	// Shutdown shutdowns the service
	Shutdown() error
}

Service represents a process

type State added in v0.0.18

type State int

State represents service state

const (
	Closed   State = iota // Closed service
	Running               // Running service
	Stopping              // Stopping service
)

func (State) String added in v0.0.18

func (state State) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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