Documentation ¶
Index ¶
- Variables
- func SetupTest()
- type Opts
- type Process
- type Service
- func (s *Service) Database() database.Database
- func (s *Service) FirehosePublisher() firehose.Publisher
- func (s *Service) HandleFunc(method, path string, ...)
- func (s *Service) HandleRaw(method, path string, handler http.Handler)
- func (s *Service) Health(ctx context.Context) map[string]error
- func (s *Service) Hostname() string
- func (s *Service) Revision() string
- func (s *Service) Run(processes ...Process)
Constants ¶
This section is empty.
Variables ¶
var Revision string
Revision is the service's revision and should be set at build time to the current git commit hash.
Functions ¶
Types ¶
type Opts ¶
type Opts struct { // Config is a pointer to a struct which, if not nil, will // be populated with config from environment variables. Config interface{} // ServiceName is the name of the service e.g. service.foo ServiceName string }
Opts defines basic initialisation options for a service
type Process ¶
type Process interface { // GetName returns a friendly name for the process for use in logs GetName() string // Start kicks off the task and only returns when the task has finished. // The task will be stopped if the context is cancelled. Start(ctx context.Context) error }
Process is a long-running task that provides service functionality
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service represents a collection of processes
func (*Service) Database ¶
Database is a helper function that returns a cached database. The first time it is called, a new connection to the database is established. Closing the connection when the program ends is handled automatically.
func (*Service) FirehosePublisher ¶
FirehosePublisher is a helper function that returns a cached firehose client. The first time it is called, a new firehose client is set up.
func (*Service) HandleFunc ¶
func (s *Service) HandleFunc(method, path string, handler func(context.Context, taxi.Decoder) (interface{}, error))
HandleFunc registers a new taxi-style handler with the application's router for the specified method and path.
func (*Service) HandleRaw ¶
HandleRaw registers a new http.Handler with the application's router for the specified method and path.
func (*Service) Health ¶
Health returns a map representing the result of all of the health checks that have been registered.
func (*Service) Hostname ¶
Hostname returns the hostname as reported by the operating system's kernel.
func (*Service) Run ¶
Run starts all processes that have already been registered with the service, plus any extra ones passed in as arguments. This function blocks until either all processes return, or an interrupt signal is received, at which point all processes are signalled to end. If any processes do not, at this point, return, then Run() may hang indefinitely.