services

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Error = fmt.Errorf("services error")
	// StartEvent starts services defined in payload
	StartEvent = events.New("services", "start.services")
	StopEvent  = events.New("services", "stop.services")
)

Functions

This section is empty.

Types

type Container added in v0.25.0

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

func NewContainer added in v0.25.0

func NewContainer(sess *session.Context, addr *address.Address, svc *Service) (*Container, error)

func (*Container) CanRetry added in v0.25.0

func (c *Container) CanRetry() bool

func (*Container) Cancel added in v0.25.0

func (c *Container) Cancel(err error)

func (*Container) Done added in v0.25.0

func (c *Container) Done() <-chan struct{}

func (*Container) HandleEvent added in v0.25.0

func (c *Container) HandleEvent(sess *session.Context, ev events.Event)

func (*Container) HasTick added in v0.25.0

func (c *Container) HasTick() bool

func (*Container) Info added in v0.25.0

func (c *Container) Info() *service.Info

func (*Container) Listeners added in v0.25.0

func (c *Container) Listeners() []string

func (*Container) Register added in v0.25.0

func (c *Container) Register(sess *session.Context) error

func (*Container) Retries added in v0.25.0

func (c *Container) Retries() int

func (*Container) Settings added in v0.25.0

func (c *Container) Settings() service.Config

func (*Container) Start added in v0.25.0

func (c *Container) Start(ectx context.Context, sess *session.Context) (err error)

func (*Container) Stop added in v0.25.0

func (c *Container) Stop(sess *session.Context, e error) (err error)

func (*Container) Tick added in v0.25.0

func (c *Container) Tick(sess *session.Context, ts time.Time, delta time.Duration) error

func (*Container) Tock added in v0.25.0

func (c *Container) Tock(sess *session.Context, delta time.Duration, tps int) error

type CronScheduler added in v0.25.0

type CronScheduler interface {
	Job(name, expr string, cb action.Action)
}

type Info added in v0.25.0

type Info interface {
	Running() bool
	Name() string
	StartedAt() time.Time
	StoppedAt() time.Time
	Addr() *address.Address
	Failed() bool
	Errs() map[time.Time]error
}

type Service added in v0.25.0

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

func New added in v0.25.0

func New(s service.Config) *Service

New cretes new draft service which you can compose before passing it to applciation or providing it from addon.

func (*Service) Cron added in v0.25.0

func (s *Service) Cron(setupFunc func(schedule CronScheduler))

Cron scheduled cron jobs to run when the service is running.

func (*Service) Name added in v0.25.0

func (s *Service) Name() string

func (*Service) OnAnyEvent added in v0.25.0

func (s *Service) OnAnyEvent(cb events.ActionWithEvent[*session.Context])

OnAnyEvent called when any event is received.

func (*Service) OnEvent added in v0.25.0

func (s *Service) OnEvent(scope, key string, cb events.ActionWithEvent[*session.Context])

OnEvent is called when a specific event is received.

func (*Service) OnRegister added in v0.25.0

func (s *Service) OnRegister(action action.Action)

OnRegister is called when app is preparing runtime and attaching services, This does not mean that service will be used or started.

func (*Service) OnStart added in v0.25.0

func (s *Service) OnStart(action action.Action)

OnStart is called when service is requested to be started. For instace when command is requiring this service or whenever service is required on runtime via sess.RequireService call.

Start can be called multiple times in case of service restarts. If you do not want to allow service restarts you should implement your logic in OnStop when it's called first time and check that state OnStart.

func (*Service) OnStop added in v0.25.0

func (s *Service) OnStop(action action.WithPrevErr)

OnStop is called when runtime request to stop the service is recieved.

func (*Service) Slug added in v0.25.0

func (s *Service) Slug() string

func (*Service) Tick added in v0.25.0

func (s *Service) Tick(action action.Tick)

OnTick when set will be called every application tick when service is in running state.

func (*Service) Tock added in v0.25.0

func (s *Service) Tock(action action.Tock)

OnTock is called after every tick.

type ServiceLoader added in v0.25.0

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

func NewLoader added in v0.25.0

func NewLoader(sess *session.Context, svcs ...string) *ServiceLoader

NewServiceLoader creates new service loader which can be used to load services.

func (*ServiceLoader) Err added in v0.25.0

func (sl *ServiceLoader) Err() error

func (*ServiceLoader) Load added in v0.25.0

func (sl *ServiceLoader) Load() <-chan struct{}

type Settings

type Settings struct {
	LoaderTimeout  settings.Duration `key:"loader_timeout,save" default:"30s" mutation:"once" desc:"Service loader timeout"`
	RunCronOnStart settings.Bool     `key:"cron_on_service_start,save" default:"false" mutation:"once" desc:"Run cron jobs on service start"`
}

func (Settings) Blueprint

func (s Settings) Blueprint() (*settings.Blueprint, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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