cores

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 18 Imported by: 5

README

cores

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(srv *CoreService) error

func Start

func Start[T listenEntry](srv *CoreService, addr T) error

func StructName

func StructName(i any) string

Types

type CoreService

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

func NewPuzzleCore

func NewPuzzleCore(opts ...ServiceOption) *CoreService

func (*CoreService) GracefulStopPuzzle

func (c *CoreService) GracefulStopPuzzle()

type Options

type Options struct {
	Ctx          context.Context
	ListenerAddr string
	ServiceName  string
	Tags         []string
	Cmux         cmux.CMux
	// contains filtered or unexported fields
}

func (*Options) RegisterPuzzle

func (o *Options) RegisterPuzzle(p Puzzle)

RegisterPuzzle will put Puzzle into cores service It replaces the previously registered Puzzle with the same name

type Puzzle

type Puzzle interface {
	Name() string
	StartPuzzle(context.Context, *Options) error
	Stop() error
}

type ServiceOption

type ServiceOption func(*Options)

func WithCronWorker

func WithCronWorker(cron string, fn WorkerFunc) ServiceOption

func WithDaemonWorker

func WithDaemonWorker(fn WorkerFunc) ServiceOption

func WithNameWorker

func WithNameWorker(name string, fn WorkerFunc) ServiceOption

func WithService added in v1.0.5

func WithService(name string) ServiceOption

func WithTag added in v1.0.5

func WithTag(tag string) ServiceOption

func WithWorker

func WithWorker(fn WorkerFunc) ServiceOption

type Worker

type Worker interface {
	Name() string
	Fn(ctx context.Context) error
}

type WorkerFunc

type WorkerFunc func(ctx context.Context) error

Directories

Path Synopsis
puzzles

Jump to

Keyboard shortcuts

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