consul: Adding additional query options and return meta data

This commit is contained in:
Armon Dadgar 2014-04-18 16:46:51 -07:00
parent ccf982cdf8
commit fbc526e8c1

View File

@ -38,6 +38,29 @@ type BlockingQuery struct {
MaxQueryTime time.Duration MaxQueryTime time.Duration
} }
// QueryOptions is used to specify various flags for read queries
type QueryOptions struct {
// 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
}
// QueryMeta allows a query response to include potentially
// useful metadata about a query
type QueryMeta struct {
// 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
}
// RegisterRequest is used for the Catalog.Register endpoint // RegisterRequest is used for the Catalog.Register endpoint
// to register a node as providing a service. If no service // to register a node as providing a service. If no service
// is provided, the node is registered. // is provided, the node is registered.
@ -63,6 +86,7 @@ type DeregisterRequest struct {
type DCSpecificRequest struct { type DCSpecificRequest struct {
Datacenter string Datacenter string
BlockingQuery BlockingQuery
QueryOptions
} }
// ServiceSpecificRequest is used to query about a specific node // ServiceSpecificRequest is used to query about a specific node
@ -72,6 +96,7 @@ type ServiceSpecificRequest struct {
ServiceTag string ServiceTag string
TagFilter bool // Controls tag filtering TagFilter bool // Controls tag filtering
BlockingQuery BlockingQuery
QueryOptions
} }
// NodeSpecificRequest is used to request the information about a single node // NodeSpecificRequest is used to request the information about a single node
@ -79,6 +104,7 @@ type NodeSpecificRequest struct {
Datacenter string Datacenter string
Node string Node string
BlockingQuery BlockingQuery
QueryOptions
} }
// ChecksInStateRequest is used to query for nodes in a state // ChecksInStateRequest is used to query for nodes in a state
@ -86,6 +112,7 @@ type ChecksInStateRequest struct {
Datacenter string Datacenter string
State string State string
BlockingQuery BlockingQuery
QueryOptions
} }
// Used to return information about a node // Used to return information about a node
@ -146,31 +173,37 @@ type CheckServiceNodes []CheckServiceNode
type IndexedNodes struct { type IndexedNodes struct {
Index uint64 Index uint64
Nodes Nodes Nodes Nodes
QueryMeta
} }
type IndexedServices struct { type IndexedServices struct {
Index uint64 Index uint64
Services Services Services Services
QueryMeta
} }
type IndexedServiceNodes struct { type IndexedServiceNodes struct {
Index uint64 Index uint64
ServiceNodes ServiceNodes ServiceNodes ServiceNodes
QueryMeta
} }
type IndexedNodeServices struct { type IndexedNodeServices struct {
Index uint64 Index uint64
NodeServices *NodeServices NodeServices *NodeServices
QueryMeta
} }
type IndexedHealthChecks struct { type IndexedHealthChecks struct {
Index uint64 Index uint64
HealthChecks HealthChecks HealthChecks HealthChecks
QueryMeta
} }
type IndexedCheckServiceNodes struct { type IndexedCheckServiceNodes struct {
Index uint64 Index uint64
Nodes CheckServiceNodes Nodes CheckServiceNodes
QueryMeta
} }
// DirEntry is used to represent a directory entry. This is // DirEntry is used to represent a directory entry. This is
@ -205,11 +238,13 @@ type KeyRequest struct {
Datacenter string Datacenter string
Key string Key string
BlockingQuery BlockingQuery
QueryOptions
} }
type IndexedDirEntries struct { type IndexedDirEntries struct {
Index uint64 Index uint64
Entries DirEntries Entries DirEntries
QueryMeta
} }
// Decode is used to decode a MsgPack encoded object // Decode is used to decode a MsgPack encoded object