service

package
v0.0.0-...-ac5decb Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

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"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	Starter
	Stopper
}

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"`
	// Deprecated: please use DevServer
	Prometheus prometheus.Config `json:",optional"`
	Telemetry  trace.Config      `json:",optional"`
	DevServer  devserver.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 {
	Start()
}

Starter is the interface wraps the Start method.

type Stopper

type Stopper interface {
	Stop()
}

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