package module
Version: v0.0.0-...-41d89a1 Latest Latest

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 13 Imported by: 0



A simple and pluggable framework to quickly set up a golang application.

The framework is inspired by go micro but because of micro including so many transitive dependancies we try to skip those and only include what is really required.




This section is empty.


This section is empty.


func NewContext

func NewContext(ctx context.Context, s Service) context.Context

NewContext returns a new Context with the Service embedded within it.


type Option

type Option func(options *Options)

func AfterStart

func AfterStart(fn func() error) Option

AfterStart run funcs after service starts

func AfterStop

func AfterStop(fn func() error) Option

AfterStop run funcs after service stops

func BeforeStart

func BeforeStart(fn func() error) Option

BeforeStart run funcs before service starts

func BeforeStop

func BeforeStop(fn func() error) Option

BeforeStop run funcs before service stops

func Cache

func Cache(c cache.Cache) Option

func Logger

func Logger(l logger.Log) Option

func Metadata

func Metadata(m map[string]string) Option

func Name

func Name(s string) Option

func Queue

func Queue(q queue.Queue) Option

func Server

func Server(s server.Server) Option

func Stats

func Stats(s stats.Stats) Option

func Store

func Store(s store.Store) Option

func Tracer

func Tracer(t trace.Tracer) Option

type Options

type Options struct {
	Name     string
	Metadata map[string]string
	Config   config.Config
	Logger   logger.Log

	Tracer trace.Tracer
	Stats  stats.Stats
	Server server.Server
	Queue  queue.Queue
	Store  store.Store
	Cache  cache.Cache

	BeforeStart []func() error
	BeforeStop  []func() error
	AfterStart  []func() error
	AfterStop   []func() error

	Context context.Context

type Service

type Service interface {
	// The service name
	Name() string

	// Init initialises options
	Init(...Option) error

	Options() Options

	Server() server.Server

	// Run the service
	Run() error

	String() string

Service is a convenience of initialising services.

func FromContext

func FromContext(ctx context.Context) (Service, bool)

FromContext retrieves a Service from the Context.

func NewService

func NewService(opts ...Option) Service


Path Synopsis

Jump to

Keyboard shortcuts

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