service

package
v0.0.0-...-f0a2dc7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Once

func Once(fn func()) func()

Types

type Group

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

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

func NewServiceGroup

func NewServiceGroup() *Group

NewServiceGroup returns a ServiceGroup.

func (*Group) Add

func (sg *Group) Add(service Service)

Add adds service into sg.

func (*Group) Start

func (sg *Group) 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 (*Group) Stop

func (sg *Group) Stop()

Stop stops the ServiceGroup.

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