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, healthCheckPort string, checkFunction func() (bool, error), isDockerType bool) (string, error)
RegisterService will register the service on consul It will also register two checks for the service. A mon check and a gRPC check mon check can be used for releases while the gRPC 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, healthCheckPort string, checkFunction func() (bool, error), isDockerType bool) (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.
func NewK8sClient ¶
func NewK8sClient(options ...K8SOptions) IServiceDiscoveryAgent
NewK8sClient returns new K8s Service discovery agent
func NewMultiSourceClient ¶
func NewMultiSourceClient(clients ...IServiceDiscoveryAgent) IServiceDiscoveryAgent
NewMultiSourceClient returns new K8s Service discovery agent
type K8SOptions ¶
type K8SOptions func(k *k8sClient)
func IsInK8SCluster ¶
func IsInK8SCluster(flag bool) K8SOptions
IsInK8SCluster sets whether running inside kubernetes cluster. Defults to true.
func SetK8sNamespace ¶
func SetK8sNamespace(namespace string) K8SOptions
SetK8sNamespace sets the namespace to be used for querying k8s. Defaults to 'default'
type Options ¶
type Options func(c *ConsulAgent)
Options sets a parameter for consul agent
func ConsulHost ¶
ConsulHost sets the IP for consul agent. Defults to 127.0.0.1
func ConsulMonScriptName ¶
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 ¶
ConsulPort sets the port for consul agent. Defaults to 8500
func Logger ¶
func Logger(customLogger *gologger.CustomLogger) Options
Logger sets the logger for consul Defaults to consul logger