daemon

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

daemon

lifecycle encapsulation for sync services

Documentation

Index

Constants

View Source
const (
	DefaultAppletClosureMaxRetry = 5
	DefaultAppletRestartInterval = time.Second
)
View Source
const ErrTextUnspecifiedError = "(unspecified error)"

Variables

View Source
var (
	ErrDaemonIsInitialized      = fmt.Errorf("daemon is initialized")
	ErrDaemonNotInitialized     = fmt.Errorf("daemon not initialized")
	ErrDaemonRegisterIsFrozen   = fmt.Errorf("daemon register is frozen")
	ErrAppletIdentityConflict   = fmt.Errorf("applet identity conflict")
	ErrAppletQuitsWithoutReason = fmt.Errorf("applet quits without reason")
)
View Source
var ErrAlreadyServing = errors.New("already serving")

Functions

This section is empty.

Types

type Applet

type Applet[id ID] interface {
	Identity() id
	Initialize() (err error)
	OnQuit(ctx CtxAppletOnQuit)
	Serve(func()) (err error)
	Serving() bool
	Shutdown(ctx context.Context) (err error)
	Depends() []id
}

func NewCancelableApplet added in v0.0.6

func NewCancelableApplet[id ID](core cancelableCore, appId id, deps ...id) Applet[id]

type CtxAppletOnQuit

type CtxAppletOnQuit interface {
	ReInitialize(do bool)
	ReStart(do bool)
	Fail(do bool, filter func(err error) error)
}

type Daemon

type Daemon[id ID] struct {
	// contains filtered or unexported fields
}

func NewDaemon

func NewDaemon[id ID](opts ...OptionPayload[id]) *Daemon[id]

func (*Daemon[id]) Halt

func (d *Daemon[id]) Halt()

func (*Daemon[id]) Init

func (d *Daemon[id]) Init() error

func (*Daemon[id]) Register

func (d *Daemon[id]) Register(applets ...Applet[id]) error

func (*Daemon[id]) Serve

func (d *Daemon[id]) Serve() (err error)

func (*Daemon[id]) Shutdown

func (d *Daemon[id]) Shutdown(ctx context.Context) (err error)

type ID added in v0.0.4

type ID interface {
	comparable
	fmt.Stringer
}

type OptionPayload

type OptionPayload[id ID] interface {
	// contains filtered or unexported methods
}

func OptContext

func OptContext[id ID](ctx context.Context) OptionPayload[id]

func OptLogger

func OptLogger[id ID](logger logger) OptionPayload[id]

func OptMaxRetry

func OptMaxRetry[id ID](serve, closure int) OptionPayload[id]

Jump to

Keyboard shortcuts

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