pkgCtl

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

Package controller

  • a simple golang task controller
go get github.com/RealFax/pkg-ctl

how to use

using pkg-ctl is very simple

  • First add pkg-ctl to your go.mod
  • Then refer to the example code to register your package in pkg-ctl

example

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Bootstrap added in v1.0.0

func Bootstrap(activeFunc func())

func Destroy

func Destroy(cancel context.CancelFunc) (err error)

Destroy unregister all services immediately after calling

Deprecated

func Exit

func Exit() error

Exit unregister all services immediately after calling

this func can only be called when ListenAndDestroy is used, otherwise an error will be return

Deprecated

func ExitWithTimeout

func ExitWithTimeout(d time.Duration) error

ExitWithTimeout

Deprecated

func ForceExit

func ForceExit() error

ForceExit the ListenAndDestroy func

Deprecated

func ListenAndDestroy

func ListenAndDestroy(cancel context.CancelFunc) error

ListenAndDestroy

Deprecated

func RegisterHandler

func RegisterHandler(seq int, name string, handler func(ctx *context.Context) Handler)

func Startup

func Startup(rootCtx *context.Context) error

Startup all registered services in order

Deprecated

Types

type DestroyUnit

type DestroyUnit struct {
	Seq  int
	Name string
	Unit Handler
}

type Handler

type Handler interface {
	Create() error
	Start() error
	Destroy() error
	Async() bool
}

type Root added in v1.1.0

type Root struct {
	Context    context.Context
	CancelFunc context.CancelFunc
	// contains filtered or unexported fields
}

func New added in v1.1.0

func New(ctx context.Context) *Root

func (*Root) Destroy added in v1.1.0

func (r *Root) Destroy() error

func (*Root) Exit added in v1.1.0

func (r *Root) Exit() error

func (*Root) ListenAndDestroy added in v1.1.0

func (r *Root) ListenAndDestroy() error

func (*Root) Startup added in v1.1.0

func (r *Root) Startup() error

func (*Root) Stop added in v1.1.0

func (r *Root) Stop()

type Unit

type Unit struct {
	Seq    int
	Name   string
	Handle func(ctx *context.Context) Handler
}

Jump to

Keyboard shortcuts

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