v0.0.2 Latest Latest

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 9 Imported by: 0




View Source
const (
	// DevMode means development mode.
	DevMode = "dev"
	// TestMode means test mode.
	TestMode = "test"
	// RtMode means regression test mode.
	RtMode = "rt"
	// PreMode means pre-release mode.
	PreMode = "pre"
	// ProMode means production mode.
	ProMode = "pro"


This section is empty.


This section is empty.


type Service

type Service interface {

Service is the interface that groups Start and Stop methods.

func WithStart

func WithStart(start func()) Service

WithStart wraps a start func as a Service.

func WithStarter

func WithStarter(start Starter) Service

WithStarter wraps a Starter as a Service.

type ServiceConf

type ServiceConf struct {
	Name       string
	Log        logx.LogConf
	Mode       string            `json:",default=pro,options=dev|test|rt|pre|pro"`
	MetricsUrl string            `json:",optional"`
	Prometheus prometheus.Config `json:",optional"`
	Telemetry  trace.Config      `json:",optional"`

A ServiceConf is a service config.

func (ServiceConf) MustSetUp

func (sc ServiceConf) MustSetUp()

MustSetUp sets up the service, exits on error.

func (ServiceConf) SetUp

func (sc ServiceConf) SetUp() error

SetUp sets up the service.

type ServiceGroup

type ServiceGroup struct {
	// contains filtered or unexported fields

A ServiceGroup is a group of services. Attention: the starting order of the added services is not guaranteed.

func NewServiceGroup

func NewServiceGroup() *ServiceGroup

NewServiceGroup returns a ServiceGroup.

func (*ServiceGroup) Add

func (sg *ServiceGroup) Add(service Service)

Add adds service into sg.

func (*ServiceGroup) Start

func (sg *ServiceGroup) Start()

Start starts the ServiceGroup. There should not be any logic code after calling this method, because this method is a blocking one. Also, quitting this method will close the logx output.

func (*ServiceGroup) Stop

func (sg *ServiceGroup) Stop()

Stop stops the ServiceGroup.

type Starter

type Starter interface {

Starter is the interface wraps the Start method.

type Stopper

type Stopper interface {

Stopper is the interface wraps the Stop method.

Jump to

Keyboard shortcuts

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