adapter

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const REGIntrannetIP = `` /* 129-byte string literal not displayed */

Regular expression to match intranet IP Address include: 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16

Variables

View Source
var ErrEmptyCircle = errors.New("empty circle")

ErrEmptyCircle is the error returned when trying to get an element when nothing has been added to hash.

Functions

func IntranetIP

func IntranetIP(ipStr string) string

func Start

func Start()

Types

type Consistent

type Consistent struct {
	NumberOfReplicas int

	sync.RWMutex
	// contains filtered or unexported fields
}

Consistent holds the information about the members of the consistent hash circle.

func NewConsistent

func NewConsistent() *Consistent

New creates a new Consistent object with a default setting of 20 replicas for each entry.

To change the number of replicas, set NumberOfReplicas before adding entries.

func (*Consistent) Add

func (c *Consistent) Add(elt string)

Add inserts a string element in the consistent hash.

func (*Consistent) Get

func (c *Consistent) Get(name string) (string, error)

Get returns an element close to where name hashes to in the circle.

func (*Consistent) GetN

func (c *Consistent) GetN(name string, n int) ([]string, error)

GetN returns the N closest distinct elements to the name input in the circle.

func (*Consistent) GetTwo

func (c *Consistent) GetTwo(name string) (string, string, error)

GetTwo returns the two closest distinct elements to the name input in the circle.

func (*Consistent) Members

func (c *Consistent) Members() []string

func (*Consistent) Remove

func (c *Consistent) Remove(elt string)

Remove removes an element from the hash.

func (*Consistent) Set

func (c *Consistent) Set(elts []string)

Set sets all the elements in the hash. If there are existing elements not present in elts, they will be removed.

type Kapacitor

type Kapacitor struct {
	Addrs     []string
	AlarmAddr string

	Clients map[string]*client.Client

	Hash *Consistent
	// contains filtered or unexported fields
}

func NewKapacitor

func NewKapacitor(addrs []string, alarmAddr string) *Kapacitor

func (*Kapacitor) CreateTask

func (k *Kapacitor) CreateTask(alarm models.Alarm) error

Create a new task. Errors if the task already exists.

func (*Kapacitor) RemoveTask

func (k *Kapacitor) RemoveTask(task client.Task) error

func (*Kapacitor) SetAddr

func (k *Kapacitor) SetAddr(addrs []string)

func (*Kapacitor) Tasks

func (k *Kapacitor) Tasks() map[string]client.Task

func (*Kapacitor) Work

func (k *Kapacitor) Work(tasks map[string]client.Task, alarms map[string]models.Alarm)

type Machine

type Machine struct {
	IP string `json:"ip"`
}

type Registry

type Registry struct {
	Addr     string
	AlarmNS  string
	Interval int
}

func NewRegistry

func NewRegistry(addr string, alarmNS string) *Registry

func (*Registry) AlarmServers

func (r *Registry) AlarmServers() ([]string, error)

func (*Registry) Alarms

func (r *Registry) Alarms() (map[string]models.Alarm, error)

type RespAlarm

type RespAlarm struct {
	Status int            `json:"httpstatus"`
	Data   []models.Alarm `json:"data"`
}

type RespMachine

type RespMachine struct {
	Status int       `json:"httpstatus"`
	Data   []Machine `json:"data"`
}

Jump to

Keyboard shortcuts

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