commands

package
v0.0.0-...-12d836b Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Exec is the command that should be executed if there's a watch that actually fires.
	Exec string

	// Token is used for access to Consul if an ACL is being used.
	Token string

	// DogStatsd sends metrics to Dogstatsd if set to true.
	DogStatsd bool

	// Prefix is the location in Consul's KV store to keep state information.
	Prefix string

	// MetricPrefix is the prefix for all Sifter metrics.
	MetricPrefix string

	// ConsulServer is where we want to connect to Consul.
	ConsulServer string
)
View Source
var RootCmd = &cobra.Command{
	Use:   "sifter",
	Short: "Make sure that a Consul watch only fires when it's appropriate.",
	Long:  `When Consul loads watches, it often fires them with a blank JSON array. sifter makes sure there's an actual JSON entity present, that it's new and then runs your command.`,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("`sifter -h` for help information.")
	},
}

RootCmd sets up all fo the other commands.

Functions

func Connect

func Connect() (*consul.Client, error)

Connect sets up a connection to Consul and hands back a client.

func Get

func Get(c *consul.Client, key string) string

Get grabs a key's value from Consul.

func Log

func Log(message, priority string)

Log sends logs to syslog.

func RunTime

func RunTime(start time.Time, location, extra string)

RunTime shows logs with timing information.

func Set

func Set(c *consul.Client, key, value string) bool

Set sets a key's value inside Consul.

func StatsdBlank

func StatsdBlank(watchType string)

StatsdBlank sends Dogstatsd metrics whenever there's a blank watch.

func StatsdDuplicate

func StatsdDuplicate(watchType string, watchID string)

StatsdDuplicate sends Dogstatsd metrics whenever there's a duplicate watch.

func StatsdRunTime

func StatsdRunTime(start time.Time, exec string, watchType string, watchID string, id string)

StatsdRunTime sends timing metrics via Dogstatsd.

Types

type EventWatch

type EventWatch struct {
	ID            string `json:"ID"`
	Name          string `json:"Name"`
	Payload       string `json:"Payload,omitempty"`
	NodeFilter    string `json:"NodeFilter,omitempty"`
	ServiceFilter string `json:"ServiceFilter"`
	TagFilter     string `json:"TagFilter"`
	Version       int    `json:"Version"`
	LTime         int    `json:"LTime"`
}

EventWatch is the JSON structure of a Consul Event.

type KeyWatch

type KeyWatch struct {
	CreateIndex int    `json:"CreateIndex"`
	Flags       int    `json:"Flags,omitempty"`
	Key         string `json:"Key"`
	LockIndex   int    `json:"LockIndex,omitempty"`
	ModifyIndex int    `json:"ModifyIndex"`
	Session     string `json:"Session,omitempty"`
	Value       string `json:"Value"`
}

KeyWatch is the JSON structure of a Consul key watch.

Jump to

Keyboard shortcuts

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