structs

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2014 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HealthAny is special, and is used as a wild card,
	// not as a specific state.
	HealthAny      = "any"
	HealthUnknown  = "unknown"
	HealthPassing  = "passing"
	HealthWarning  = "warning"
	HealthCritical = "critical"
)
View Source
const (
	// Client tokens have rules applied
	ACLTypeClient = "client"

	// Management tokens have an always allow policy.
	// They are used for token management.
	ACLTypeManagement = "management"
)
View Source
const (
	KVSSet        KVSOp = "set"
	KVSDelete           = "delete"
	KVSDeleteTree       = "delete-tree"
	KVSCAS              = "cas"    // Check-and-set
	KVSLock             = "lock"   // Lock a key
	KVSUnlock           = "unlock" // Unlock a key
)
View Source
const (
	ACLSet      ACLOp = "set"
	ACLForceSet       = "force-set" // Deprecated, left to backwards compatibility
	ACLDelete         = "delete"
)
View Source
const (
	// MaxLockDelay provides a maximum LockDelay value for
	// a session. Any value above this will not be respected.
	MaxLockDelay = 60 * time.Second
)

Variables

View Source
var (
	ErrNoLeader  = fmt.Errorf("No cluster leader")
	ErrNoDCPath  = fmt.Errorf("No path to datacenter")
	ErrNoServers = fmt.Errorf("No known Consul servers")
)

Functions

func Decode

func Decode(buf []byte, out interface{}) error

Decode is used to decode a MsgPack encoded object

func Encode

func Encode(t MessageType, msg interface{}) ([]byte, error)

Encode is used to encode a MsgPack object with type prefix

Types

type ACL added in v0.4.0

type ACL struct {
	CreateIndex uint64
	ModifyIndex uint64
	ID          string
	Name        string
	Type        string
	Rules       string
}

ACL is used to represent a token and it's rules

type ACLOp added in v0.4.0

type ACLOp string

type ACLPolicy added in v0.4.0

type ACLPolicy struct {
	ETag   string
	Parent string
	Policy *acl.Policy
	TTL    time.Duration
	QueryMeta
}

type ACLPolicyRequest added in v0.4.0

type ACLPolicyRequest struct {
	Datacenter string
	ACL        string
	ETag       string
	QueryOptions
}

ACLPolicyRequest is used to request an ACL by ID, conditionally filtering on an ID

func (*ACLPolicyRequest) RequestDatacenter added in v0.4.0

func (r *ACLPolicyRequest) RequestDatacenter() string

type ACLRequest added in v0.4.0

type ACLRequest struct {
	Datacenter string
	Op         ACLOp
	ACL        ACL
	WriteRequest
}

ACLRequest is used to create, update or delete an ACL

func (*ACLRequest) RequestDatacenter added in v0.4.0

func (r *ACLRequest) RequestDatacenter() string

type ACLSpecificRequest added in v0.4.0

type ACLSpecificRequest struct {
	Datacenter string
	ACL        string
	QueryOptions
}

ACLSpecificRequest is used to request an ACL by ID

func (*ACLSpecificRequest) RequestDatacenter added in v0.4.0

func (r *ACLSpecificRequest) RequestDatacenter() string

type ACLs added in v0.4.0

type ACLs []*ACL

type CheckServiceNode

type CheckServiceNode struct {
	Node    Node
	Service NodeService
	Checks  HealthChecks
}

CheckServiceNode is used to provide the node, it's service definition, as well as a HealthCheck that is associated

type CheckServiceNodes

type CheckServiceNodes []CheckServiceNode

type ChecksInStateRequest

type ChecksInStateRequest struct {
	Datacenter string
	State      string
	QueryOptions
}

ChecksInStateRequest is used to query for nodes in a state

func (*ChecksInStateRequest) RequestDatacenter added in v0.2.0

func (r *ChecksInStateRequest) RequestDatacenter() string

type DCSpecificRequest

type DCSpecificRequest struct {
	Datacenter string
	QueryOptions
}

DCSpecificRequest is used to query about a specific DC

func (*DCSpecificRequest) RequestDatacenter added in v0.2.0

func (r *DCSpecificRequest) RequestDatacenter() string

type DeregisterRequest

type DeregisterRequest struct {
	Datacenter string
	Node       string
	ServiceID  string
	CheckID    string
	WriteRequest
}

DeregisterRequest is used for the Catalog.Deregister endpoint to deregister a node as providing a service. If no service is provided the entire node is deregistered.

func (*DeregisterRequest) RequestDatacenter added in v0.2.0

func (r *DeregisterRequest) RequestDatacenter() string

type DirEntries

type DirEntries []*DirEntry

type DirEntry

type DirEntry struct {
	CreateIndex uint64
	ModifyIndex uint64
	LockIndex   uint64
	Key         string
	Flags       uint64
	Value       []byte
	Session     string `json:",omitempty"`
}

DirEntry is used to represent a directory entry. This is used for values in our Key-Value store.

type EventFireRequest added in v0.4.0

type EventFireRequest struct {
	Datacenter string
	Name       string
	Payload    []byte

	// Not using WriteRequest so that any server can process
	// the request. It is a bit unusual...
	QueryOptions
}

EventFireRequest is used to ask a server to fire a Serf event. It is a bit odd, since it doesn't depend on the catalog or leader. Any node can respond, so it's not quite like a standard write request. This is used only internally.

func (*EventFireRequest) RequestDatacenter added in v0.4.0

func (r *EventFireRequest) RequestDatacenter() string

type EventFireResponse added in v0.4.0

type EventFireResponse struct {
	QueryMeta
}

EventFireResponse is used to respond to a fire request.

type HealthCheck

type HealthCheck struct {
	Node        string
	CheckID     string // Unique per-node ID
	Name        string // Check name
	Status      string // The current check status
	Notes       string // Additional notes with the status
	Output      string // Holds output of script runs
	ServiceID   string // optional associated service
	ServiceName string // optional service name
}

HealthCheck represents a single check on a given node

type HealthChecks

type HealthChecks []*HealthCheck

type IndexedACLs added in v0.4.0

type IndexedACLs struct {
	ACLs ACLs
	QueryMeta
}

type IndexedCheckServiceNodes

type IndexedCheckServiceNodes struct {
	Nodes CheckServiceNodes
	QueryMeta
}

type IndexedDirEntries

type IndexedDirEntries struct {
	Entries DirEntries
	QueryMeta
}

type IndexedHealthChecks

type IndexedHealthChecks struct {
	HealthChecks HealthChecks
	QueryMeta
}

type IndexedKeyList added in v0.2.0

type IndexedKeyList struct {
	Keys []string
	QueryMeta
}

type IndexedNodeDump added in v0.2.0

type IndexedNodeDump struct {
	Dump NodeDump
	QueryMeta
}

type IndexedNodeServices

type IndexedNodeServices struct {
	NodeServices *NodeServices
	QueryMeta
}

type IndexedNodes

type IndexedNodes struct {
	Nodes Nodes
	QueryMeta
}

type IndexedServiceNodes

type IndexedServiceNodes struct {
	ServiceNodes ServiceNodes
	QueryMeta
}

type IndexedServices

type IndexedServices struct {
	Services Services
	QueryMeta
}

type IndexedSessions added in v0.3.0

type IndexedSessions struct {
	Sessions Sessions
	QueryMeta
}

type KVSOp

type KVSOp string

type KVSRequest

type KVSRequest struct {
	Datacenter string
	Op         KVSOp    // Which operation are we performing
	DirEnt     DirEntry // Which directory entry
	WriteRequest
}

KVSRequest is used to operate on the Key-Value store

func (*KVSRequest) RequestDatacenter added in v0.2.0

func (r *KVSRequest) RequestDatacenter() string

type KeyListRequest added in v0.2.0

type KeyListRequest struct {
	Datacenter string
	Prefix     string
	Seperator  string
	QueryOptions
}

KeyListRequest is used to list keys

func (*KeyListRequest) RequestDatacenter added in v0.2.0

func (r *KeyListRequest) RequestDatacenter() string

type KeyRequest

type KeyRequest struct {
	Datacenter string
	Key        string
	QueryOptions
}

KeyRequest is used to request a key, or key prefix

func (*KeyRequest) RequestDatacenter added in v0.2.0

func (r *KeyRequest) RequestDatacenter() string

type MessageType

type MessageType uint8
const (
	RegisterRequestType MessageType = iota
	DeregisterRequestType
	KVSRequestType
	SessionRequestType
	ACLRequestType
)

type Node

type Node struct {
	Node    string
	Address string
}

Used to return information about a node

type NodeDump added in v0.2.0

type NodeDump []*NodeInfo

NodeDump is used to dump all the nodes with all their associated data. This is currently used for the UI only, as it is rather expensive to generate.

type NodeInfo added in v0.2.0

type NodeInfo struct {
	Node     string
	Address  string
	Services []*NodeService
	Checks   []*HealthCheck
}

NodeInfo is used to dump all associated information about a node. This is currently used for the UI only, as it is rather expensive to generate.

type NodeService

type NodeService struct {
	ID      string
	Service string
	Tags    []string
	Port    int
}

NodeService is a service provided by a node

type NodeServices

type NodeServices struct {
	Node     Node
	Services map[string]*NodeService
}

type NodeSpecificRequest

type NodeSpecificRequest struct {
	Datacenter string
	Node       string
	QueryOptions
}

NodeSpecificRequest is used to request the information about a single node

func (*NodeSpecificRequest) RequestDatacenter added in v0.2.0

func (r *NodeSpecificRequest) RequestDatacenter() string

type Nodes

type Nodes []Node

type QueryMeta added in v0.2.0

type QueryMeta struct {
	// This is the index associated with the read
	Index uint64

	// If AllowStale is used, this is time elapsed since
	// last contact between the follower and leader. This
	// can be used to gauge staleness.
	LastContact time.Duration

	// Used to indicate if there is a known leader node
	KnownLeader bool
}

QueryMeta allows a query response to include potentially useful metadata about a query

type QueryOptions added in v0.2.0

type QueryOptions struct {
	// Token is the ACL token ID. If not provided, the 'anonymous'
	// token is assumed for backwards compatibility.
	Token string

	// If set, wait until query exceeds given index. Must be provided
	// with MaxQueryTime.
	MinQueryIndex uint64

	// Provided with MinQueryIndex to wait for change.
	MaxQueryTime time.Duration

	// If set, any follower can service the request. Results
	// may be arbitrarily stale.
	AllowStale bool

	// If set, the leader must verify leadership prior to
	// servicing the request. Prevents a stale read.
	RequireConsistent bool
}

QueryOptions is used to specify various flags for read queries

func (QueryOptions) ACLToken added in v0.4.0

func (q QueryOptions) ACLToken() string

func (QueryOptions) AllowStaleRead added in v0.2.0

func (q QueryOptions) AllowStaleRead() bool

func (QueryOptions) IsRead added in v0.2.0

func (q QueryOptions) IsRead() bool

QueryOption only applies to reads, so always true

type RPCInfo added in v0.2.0

type RPCInfo interface {
	RequestDatacenter() string
	IsRead() bool
	AllowStaleRead() bool
	ACLToken() string
}

RPCInfo is used to describe common information about query

type RegisterRequest

type RegisterRequest struct {
	Datacenter string
	Node       string
	Address    string
	Service    *NodeService
	Check      *HealthCheck
	WriteRequest
}

RegisterRequest is used for the Catalog.Register endpoint to register a node as providing a service. If no service is provided, the node is registered.

func (*RegisterRequest) RequestDatacenter added in v0.2.0

func (r *RegisterRequest) RequestDatacenter() string

type ServiceNode

type ServiceNode struct {
	Node        string
	Address     string
	ServiceID   string
	ServiceName string
	ServiceTags []string
	ServicePort int
}

ServiceNode represents a node that is part of a service

type ServiceNodes

type ServiceNodes []ServiceNode

type ServiceSpecificRequest

type ServiceSpecificRequest struct {
	Datacenter  string
	ServiceName string
	ServiceTag  string
	TagFilter   bool // Controls tag filtering
	QueryOptions
}

ServiceSpecificRequest is used to query about a specific node

func (*ServiceSpecificRequest) RequestDatacenter added in v0.2.0

func (r *ServiceSpecificRequest) RequestDatacenter() string

type Services

type Services map[string][]string

Used to return information about a provided services. Maps service name to available tags

type Session added in v0.3.0

type Session struct {
	CreateIndex uint64
	ID          string
	Name        string
	Node        string
	Checks      []string
	LockDelay   time.Duration
}

Session is used to represent an open session in the KV store. This issued to associate node checks with acquired locks.

type SessionOp added in v0.3.0

type SessionOp string
const (
	SessionCreate  SessionOp = "create"
	SessionDestroy           = "destroy"
)

type SessionRequest added in v0.3.0

type SessionRequest struct {
	Datacenter string
	Op         SessionOp // Which operation are we performing
	Session    Session   // Which session
	WriteRequest
}

SessionRequest is used to operate on sessions

func (*SessionRequest) RequestDatacenter added in v0.3.0

func (r *SessionRequest) RequestDatacenter() string

type SessionSpecificRequest added in v0.3.0

type SessionSpecificRequest struct {
	Datacenter string
	Session    string
	QueryOptions
}

SessionSpecificRequest is used to request a session by ID

func (*SessionSpecificRequest) RequestDatacenter added in v0.3.0

func (r *SessionSpecificRequest) RequestDatacenter() string

type Sessions added in v0.3.0

type Sessions []*Session

type WriteRequest added in v0.2.0

type WriteRequest struct {
	// Token is the ACL token ID. If not provided, the 'anonymous'
	// token is assumed for backwards compatibility.
	Token string
}

func (WriteRequest) ACLToken added in v0.4.0

func (w WriteRequest) ACLToken() string

func (WriteRequest) AllowStaleRead added in v0.2.0

func (w WriteRequest) AllowStaleRead() bool

func (WriteRequest) IsRead added in v0.2.0

func (w WriteRequest) IsRead() bool

WriteRequest only applies to writes, always false

Jump to

Keyboard shortcuts

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