pkgCtl

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 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 Destroy

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

Destroy unregister all services immediately after calling

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

func ExitWithTimeout

func ExitWithTimeout(d time.Duration) error

func ForceExit

func ForceExit() error

ForceExit the ListenAndDestroy func

func ListenAndDestroy

func ListenAndDestroy(cancel context.CancelFunc) error

func RegisterHandler

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

func SetupActive

func SetupActive(fn func())

func Startup

func Startup(ctx *context.Context) error

Startup all registered services in order

Types

type DestroyUnit

type DestroyUnit struct {
	Seq  int
	Name string
	Unit Handler
}

type Handler

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

type Unit

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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