consulagent

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 31, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulAgent

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

ConsulAgent is the custom consul agent that will be used by all go lang applications

func (*ConsulAgent) DeregisterService

func (c *ConsulAgent) DeregisterService(serviceID string)

DeregisterService will deregister all the checks and the service itself This should be used on an exit listener of the application. It will help reduce clutter in consul

func (*ConsulAgent) GetHealthyService

func (c *ConsulAgent) GetHealthyService(moduleName string) ([]string, error)

GetHealthyService will give all the IPs of the service

func (*ConsulAgent) RegisterService

func (c *ConsulAgent) RegisterService(name, ipAddress, port string) (string, error)

RegisterService will register the service on consul It will also register two checks for the service. A mon check and a consultest check mon check can be used for releases while the service check script should check whether the service is running or not.

type IServiceDiscoveryAgent

type IServiceDiscoveryAgent interface {
	//RegisterService will register the service given the name, ip and port
	//It returns the ID of the service
	RegisterService(name, ipAddress, port string) (string, error)
	//DeregisterService will deregister the service given the ID
	DeregisterService(serviceID string)
	//GetHealthyService will give a list of all the instances of the module
	GetHealthyService(moduleName string) ([]string, error)
}

IServiceDiscoveryAgent is the interface that every service discovery agent should implement

func NewConsulAgent

func NewConsulAgent(options ...Options) IServiceDiscoveryAgent

NewConsulAgent will initialize consul client.

type Options

type Options func(c *ConsulAgent)

Options sets a parameter for consul agent

func ConsulHost

func ConsulHost(hostName string) Options

ConsulHost sets the IP for consul agent. Defults to 127.0.0.1

func ConsulMonScriptName

func ConsulMonScriptName(name string) Options

ConsulMonScriptName sets the name of the mon check script for the service The script should be located in the mon folder of the application Defaults to mon.py

func ConsulPort

func ConsulPort(portNumber int) Options

ConsulPort sets the port for consul agent. Defaults to 8500

func ConsulServiceScriptName

func ConsulServiceScriptName(name string) Options

ConsulServiceScriptName sets the name of the service check script The script should be located in the mon folder of the application Defaults to consultest.py

func Logger

func Logger(customLogger *gologger.CustomLogger) Options

Logger sets the logger for consul Defaults to consul logger

Jump to

Keyboard shortcuts

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