service

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command added in v0.1.0

type Command interface {
	ExecuteContext(ctx context.Context) error
}

Command is a CLI command interface. The cobra.Command fits, see: https://github.com/spf13/cobra

type NopCommand added in v0.1.0

type NopCommand struct {
	Executed bool
}

NopCommand is a Command doing nothing.

func (*NopCommand) ExecuteContext added in v0.1.0

func (c *NopCommand) ExecuteContext(ctx context.Context) error

type NopRouter added in v0.1.0

type NopRouter struct{}

NopRouter is a Router doing nothing.

func (*NopRouter) RunWithContext added in v0.1.0

func (r *NopRouter) RunWithContext(ctx context.Context) error

type Router added in v0.1.0

type Router interface {
	RunWithContext(ctx context.Context) error
}

Router interface. The graceful.Graceful gin's wrapper fits: https://github.com/gin-contrib/graceful.

type Runner

type Runner interface {
	// Run runs the Runner.
	Run(ctx context.Context, ctn *di.Container) error
}

Runner is an interface for a service's runner, such as gin or something else.

func NewCommandRunner added in v0.1.0

func NewCommandRunner(command Command) Runner

NewCommandRunner creates new CLI command Service Runner.

func NewCustomRunner added in v0.1.2

func NewCustomRunner(fn RunnerRunFn) Runner

NewCustomRunner returns a Runner executing the custom function.

func NewRouterRunner added in v0.1.0

func NewRouterRunner(router Router) Runner

NewRouterRunner creates new Runner executing the given http Router.

type RunnerRunFn added in v0.1.2

type RunnerRunFn func(ctx context.Context, ctn *di.Container) error

RunnerRunFn is a custom function to run in runner.

type Service

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

Service is an application based on core2go kit.

func New

func New(ctn *di.Container, log *zap.Logger) *Service

New creates new Service instance with the specified DI container.

func (*Service) RegisterRunner added in v0.1.0

func (s *Service) RegisterRunner(runners ...Runner)

RegisterRunner register the Runner instances in the Service.

func (*Service) Run

func (s *Service) Run(ctx context.Context) int

Run starts the Service. Returns the exist code.

Jump to

Keyboard shortcuts

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