consul

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package consul provides a consul client from which data will be queried to know the health status of a service based in its tags

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultClientConfig

func DefaultClientConfig() *consulapi.Config

DefaultClientConfig returns the default consul config

Types

type Check

type Check struct {
	// Consul Client object from our custom Consul client wrapper
	Consul *Consul
	// CheckConfig
	Config *CheckConfig
	// QueryOptions is a consulapi struct that allows us to to blocking queries
	QueryOptions *consulapi.QueryOptions
}

Check is used to represent a single service check

func NewCheck

func NewCheck(config *CheckConfig) (*Check, error)

NewCheck returns a new check

func (*Check) Healthy

func (c *Check) Healthy() (int, *consulapi.QueryMeta, error)

Healthy returns the number of healthy instances of a service based on the data of the exisitng check

type CheckConfig

type CheckConfig struct {
	// Service the name of the service we'll check
	Service string
	// Tags is a filter applied to the service we'll check
	Tag string
	// PassingOnly will show only passing services or not
	PassingOnly bool
	// BlockTime Consul blocking query time
	BlockTime time.Duration
}

CheckConfig is used to represent a basic Check configuration

func DefaultCheckConfig

func DefaultCheckConfig() *CheckConfig

DefaultCheckConfig retruns a valid check configuration

type Consul

type Consul struct {
	Client *consulapi.Client
}

Consul provides a client to the Consul API

func NewClient

func NewClient(config *consulapi.Config) (*Consul, error)

NewClient creates and returns a consul client

Jump to

Keyboard shortcuts

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