service

package
v0.0.0-...-83e654d Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	http.Handler
	GetPrefix() string
}

Endpoint adds a HTTP handler for the `GetPrefix()` to the webserver

type Service

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

Service is the main struct for controlling a guble server

func New

func New(router router.Router, webserver *webserver.WebServer) *Service

New creates a new Service, using the given Router and WebServer. If the router has already a configured Cluster, it is registered as a service module. The Router and Webserver are then registered as modules.

func (*Service) HealthEndpoint

func (s *Service) HealthEndpoint(endpointPrefix string) *Service

HealthEndpoint sets the endpoint used for health. Parameter for disabling the endpoint is: "". Returns the updated service.

func (*Service) MetricsEndpoint

func (s *Service) MetricsEndpoint(endpointPrefix string) *Service

MetricsEndpoint sets the endpoint used for metrics. Parameter for disabling the endpoint is: "". Returns the updated service.

func (*Service) ModulesSortedByStartOrder

func (s *Service) ModulesSortedByStartOrder() []interface{}

ModulesSortedByStartOrder returns the registered modules sorted by their startOrder property

func (*Service) RegisterModules

func (s *Service) RegisterModules(startOrder int, stopOrder int, ifaces ...interface{})

RegisterModules adds more modules (which can be Startable, Stopable, Endpoint etc.) to the service, with their start and stop ordering across all the service's modules.

func (*Service) Start

func (s *Service) Start() error

Start checks the modules for the following interfaces and registers and/or starts:

Startable:
health.Checker:
Endpoint: Register the handler function of the Endpoint in the http service at prefix

func (*Service) Stop

func (s *Service) Stop() error

Stop stops the registered modules in their given order

func (*Service) WebServer

func (s *Service) WebServer() *webserver.WebServer

WebServer returns the service *webserver.WebServer instance

type Startable

type Startable interface {
	Start() error
}

Startable interface for modules which provide a start mechanism

type Stopable

type Stopable interface {
	Stop() error
}

Stopable interface for modules which provide a stop mechanism

Jump to

Keyboard shortcuts

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