pkgCtl

package module
v1.3.0 Latest Latest
Warning

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

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

README

Package controller

  • a modular project management (startup) framework
go get github.com/RealFax/pkg-ctl@latest

how to use

  • 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

View Source
var DefaultLogger = defaultLogger{
	log.New(os.Stderr, "", log.LstdFlags),
}

Functions

func Bootstrap added in v1.0.0

func Bootstrap(activeFunc func())

func RegisterHandler

func RegisterHandler(seq int, name string, handler HandlerFunc)

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 HandlerFunc added in v1.2.0

type HandlerFunc func(*context.Context) Handler

type Logger added in v1.2.0

type Logger interface {
	Debug(v ...any)
	Info(v ...any)
	Error(v ...any)
}

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, logger Logger) *Root

func Self added in v1.3.0

func Self(ctx context.Context) (*Root, bool)

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

Jump to

Keyboard shortcuts

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