context

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

Context is a small service wrapper that handles the startup/shutdown of services.

func NewCtx

func NewCtx(svcs ...Service) (*Context, error)

NewCtx creates a new context containing the given services.

func (*Context) Configure

func (ctx *Context) Configure(svc Service) error

Configure the given service.

func (*Context) Register

func (ctx *Context) Register(service Service) error

Register a new service into the context and preserve the order passed.

func (*Context) Run

func (ctx *Context) Run() error

Run starts the context. Each service is configured first, then started.

func (*Context) Service

func (ctx *Context) Service(id string) Service

Service returns the pointer to the given service.

func (*Context) Services

func (ctx *Context) Services() []string

func (*Context) Start

func (ctx *Context) Start(svc Service) error

Start the given service.

type DefaultService

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

DefaultService should be extended for each service. Handles the internal context routing.

func (*DefaultService) Configure

func (ds *DefaultService) Configure(ctx *Context) error

Configure is the base that will be called for EVERY service extending DefaultService.

func (*DefaultService) Service

func (ds *DefaultService) Service(id string) Service

Service returns the inner context service by ID.

func (*DefaultService) Services

func (ds *DefaultService) Services() []string

Services returns the inner context list of service keys.

func (*DefaultService) Shutdown

func (ds *DefaultService) Shutdown()

Shutdown performs any shutdown procedures.

func (*DefaultService) Start

func (ds *DefaultService) Start() error

Start the service.

type Service

type Service interface {
	Id() string
	Configure(ctx *Context) error
	Start() error
	Shutdown()
}

Service interface defines what each service needs to expose to be included within the service context.

Jump to

Keyboard shortcuts

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