Skip to content

Latest commit

 

History

History
98 lines (62 loc) · 2.38 KB

.godocdown.markdown

File metadata and controls

98 lines (62 loc) · 2.38 KB

#Herald

Herald is a package intended to make your microservice compatible with multiple service discovery platforms throught the use of flags or environment variables.

Herald serves two functions.

Declaring the microservice.

Utilizing the service definition a service can declare its definition in a k/v store.

Currently supports etcd and consul.

Pooling the microservice

Once again utilizing the service definition a system can become part of a pool of services for API routing.

Currently supports consul and vulcand

Flags and Env

This package supports three flags and 3 environment variables. Flags take prescendence over environement variables and specificty takes prescedence over genrality.

--herald will set the declare and pool services to the same thing env (HERALD). Service must me both interface requirements.

--herald-p sets the pooling service only (HERALD_POOL)

--herald-d sets the declare service (HERALD_DECLARE)

Herald only acts if a pool or declaration or both have been set. Pool and declcarations are mutually independent so a user can mix and match services.

Registry

Herald has a registry of platforms currently supported and you can register all:

package main

import (
	"github.com/duckbunny/herald/registry"
)

func init() {
	registry.RegisterAll()
}

Interfaces

Herald has two interfaces

###Pool

type Pool interface {
	Start(*service.Service) error
	Stop(*service.Service) error
	Init() error
}

New pool types can be created and registered utilizing the AddPool method.

my_new_pool = new(MyPoolStruct)
herald.AddPool("my_pool", my_new_pool)

which can then be invoked from a flag or env variable.

###Declaration

type Declaration interface {
	Declare(*service.Service) error
	Get(*service.Service) error
	Init() error
}

New declaration types can be created and registered utilizing the AddDeclaration method.

my_new_declaration = new(MyDeclarationStruct)
herald.AddDeclaration("my_declaration", my_new_declaration)

which can then be invoked from a flag or env variable.

[![GoDoc](https://godoc.org/github.com/duckbunny/{{ .Name }}?status.svg)](https://godoc.org/github.com/duckbunny/{{ .Name }})

Godocs

{{ .EmitHeader }}

{{ .EmitSynopsis }}

{{ .EmitUsage }}

docs generated by godocdown