bootstrap

package
v0.0.0-...-eb599cc Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTest

func SetupTest()

SetupTest should be called in a TestMain() function to setup the various global state that code relies on.

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

	// Firehose indicates whether a connection to Redis should be made
	Firehose bool

	// Database indicates whether a connection to MySQL should be made
	Database bool
}

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
	Start() error

	// Stop will try to gracefully end the task and should be safe to run regardless of whether the process is currently running
	Stop(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 Init

func Init(opts *Opts) *Service

Init performs standard service startup tasks and returns a Service

func (*Service) Run

func (s *Service) Run(processes ...Process)

Run takes a number of processes and concurrently runs them all. It will stop if all processes terminate or if a signal (SIGINT or SIGTERM) is received.

Jump to

Keyboard shortcuts

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