consul

package module
v0.0.0-...-872bf76 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2016 License: LGPL-3.0 Imports: 11 Imported by: 0

README

###Consul

Is the consul implementation for herald.

GoDoc

consul

-- import "github.com/duckbunny/consul"

The consul package implements the Pool and Declare interfaces for the Herald package. https://github.com/duckbunny/herald

The package takes one flag "consul-ttl" to set the time until the service expires from consul using a heartbeat.

The package utilizies the Default client returned from consul api, but this can be overriden by editing.

ConsulConfig.Config.Address = "192.168.1.56"

This service must be registered with herald.

consul.Register()

Or you can fall back on the herald service registry, to register all available services.

Usage

var (
	// TTL time to life for service in consul
	TTL int = 15

	// Where the ServiceKVPath resides
	KVpath string = "services"

	// Title for specifying herald in flags
	Title string = "consul"

	// Config falls back to client default config
	ConsulConfig *api.Config = api.DefaultConfig()
)
func FormattedID
func FormattedID(s *service.Service) string

FormattedID returns correctly formatted id of the service

func FormattedKey
func FormattedKey(s *service.Service) string

FormattedKey returns correctly formatted key of the service

func FormattedName
func FormattedName(s *service.Service) string

FormattedName returns correctly formatted name of the service

func Register
func Register()

Register this herald with consul

type Consul
type Consul struct {
	// Agent to register service
	Agent *api.Agent
	// KV to save service definition
	KV *api.KV
}

Consul structure

func New
func New() *Consul

New Consul

func (*Consul) Declare
func (c *Consul) Declare(s *service.Service) error

Send service definition to consul

func (*Consul) Get
func (c *Consul) Get(s *service.Service) error

Retrieve the consul service definition. Requires Domain, Title and Version be set. Returns err if not found.

func (*Consul) Heartbeat
func (c *Consul) Heartbeat(s *service.Service)

Heartbeat begins heart beat of health check.

func (*Consul) Init
func (c *Consul) Init() error

Init Consul herald with Default Settings

func (*Consul) Start
func (c *Consul) Start(s *service.Service) error

Start Register the service in the consul pool of services

func (*Consul) Stop
func (c *Consul) Stop(s *service.Service) error

Kill the Hearteat and remove the service

Documentation

Overview

The consul package implements the Pool and Declare interfaces for the Herald package. https://github.com/duckbunny/herald

The package takes one flag "consul-ttl" to set the time until the service expires from consul using a heartbeat.

The package utilizies the Default client returned from consul api, but this can be overriden by editing.

ConsulConfig.Config.Address = "192.168.1.56"

This service must be registered with herald.

consul.Register()

Or you can fall back on the herald service registry, to register all available services.

Index

Constants

This section is empty.

Variables

View Source
var (
	// TTL time to life for service in consul
	TTL int = 15

	// Where the ServiceKVPath resides
	ServicesKVpath string = "services"

	// Title for specifying herald in flags
	Title string = "consul"

	// Config falls back to client default config
	ConsulConfig *api.Config = api.DefaultConfig()
)

Functions

func FormattedID

func FormattedID(s *service.Service) string

FormattedID returns correctly formatted id of the service

func FormattedKey

func FormattedKey(s *service.Service) string

FormattedKey returns correctly formatted key of the service

func FormattedName

func FormattedName(s *service.Service) string

FormattedName returns correctly formatted name of the service

func Register

func Register()

Register this herald with consul

Types

type Consul

type Consul struct {
	// Agent to register service
	Agent *api.Agent
	// KV to save service definition
	KV *api.KV
	// contains filtered or unexported fields
}

Consul structure

func New

func New() *Consul

New Consul

func (*Consul) Declare

func (c *Consul) Declare(s *service.Service) error

Send service definition to consul

func (*Consul) GetService

func (c *Consul) GetService(s *service.Service) error

Retrieve the consul service definition. Requires Domain, Title and Version be set. Returns err if not found.

func (*Consul) Heartbeat

func (c *Consul) Heartbeat(s *service.Service)

Heartbeat begins heart beat of health check.

func (*Consul) Init

func (c *Consul) Init() error

Init Consul herald with Default Settings

func (*Consul) Start

func (c *Consul) Start(s *service.Service) error

Start Register the service in the consul pool of services

func (*Consul) Stop

func (c *Consul) Stop(s *service.Service) error

Kill the Hearteat and remove the service

Jump to

Keyboard shortcuts

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