Documentation ¶
Index ¶
- func BuildServiceGraph(objs []interface{}, services []*Descriptor) error
- func ClearOverrides()
- func IsDisabled(srv Service) bool
- func Register(descriptor *Descriptor)
- func RegisterOverride(fn OverrideServiceFunc)
- func RegisterService(instance Service)
- func RegisterServiceWithPriority(instance Service, priority Priority)
- type BackgroundService
- type CanBeDisabled
- type DatabaseMigrator
- type Descriptor
- type OverrideServiceFunc
- type Priority
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildServiceGraph ¶
func BuildServiceGraph(objs []interface{}, services []*Descriptor) error
BuildServiceGraph builds a graph of services and their dependencies. The services are initialized after the graph is built.
func ClearOverrides ¶
func ClearOverrides()
func IsDisabled ¶
IsDisabled returns whether a service is disabled.
func Register ¶
func Register(descriptor *Descriptor)
func RegisterOverride ¶
func RegisterOverride(fn OverrideServiceFunc)
func RegisterService ¶
func RegisterService(instance Service)
Types ¶
type BackgroundService ¶
type BackgroundService interface { // Run starts the background process of the service after `Init` have been called // on all services. The `context.Context` passed into the function should be used // to subscribe to ctx.Done() so the service can be notified when Grafarg shuts down. Run(ctx context.Context) error }
BackgroundService should be implemented for services that have long running tasks in the background.
type CanBeDisabled ¶
type CanBeDisabled interface { // IsDisabled should return a bool saying if it can be started or not. IsDisabled() bool }
CanBeDisabled allows the services to decide if it should be started or not by itself. This is useful for services that might not always be started, ex alerting. This will be called after `Init()`.
type DatabaseMigrator ¶
type DatabaseMigrator interface { // AddMigrations allows the service to add migrations to // the database migrator. AddMigration(mg *migrator.Migrator) }
DatabaseMigrator allows the caller to add migrations to the migrator passed as argument
type Descriptor ¶
func GetService ¶
func GetService(name string) *Descriptor
GetService gets the registered service descriptor with a certain name. If none is found, nil is returned.
func GetServices ¶
func GetServices() []*Descriptor
type OverrideServiceFunc ¶
type OverrideServiceFunc func(descriptor Descriptor) (*Descriptor, bool)
type Service ¶
type Service interface { // Init is called by Grafarg main process which gives the service // the possibility do some initial work before its started. Things // like adding routes, bus handlers should be done in the Init function Init() error }
Service interface is the lowest common shape that services are expected to fulfill to be started within Grafarg.