registry

package
v0.0.0-...-67faadc Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(descriptor *Descriptor)

func RegisterService

func RegisterService(instance Service, prio Priority)

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 Grafana 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 Descriptor

type Descriptor struct {
	Name         string
	Instance     Service
	InitPriority Priority
}

func GetServices

func GetServices() []*Descriptor

func (*Descriptor) BackgroundService

func (d *Descriptor) BackgroundService() (BackgroundService, bool)

func (*Descriptor) Inject

func (d *Descriptor) Inject(serviceGraph *inject.Graph)

func (*Descriptor) IsDisabled

func (d *Descriptor) IsDisabled() bool

type Priority

type Priority int
const (
	High Priority = 100
	Low  Priority = 0
)

type Service

type Service interface {
	// Init is called by at process startup 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 forfill to be started within Grafana.

Jump to

Keyboard shortcuts

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