mirror of
https://github.com/status-im/consul.git
synced 2025-02-23 10:58:25 +00:00
consul: Adding RPCInfo to get common info
This commit is contained in:
parent
fbc526e8c1
commit
cea8a4f9f2
@ -28,6 +28,13 @@ const (
|
|||||||
HealthCritical = "critical"
|
HealthCritical = "critical"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// RPCInfo is used to describe common information about query
|
||||||
|
type RPCInfo interface {
|
||||||
|
RequestDatacenter() string
|
||||||
|
IsRead() bool
|
||||||
|
AllowStaleRead() bool
|
||||||
|
}
|
||||||
|
|
||||||
// BlockingQuery is used to block on a query and wait for a change.
|
// BlockingQuery is used to block on a query and wait for a change.
|
||||||
// Either both fields, or neither must be provided.
|
// Either both fields, or neither must be provided.
|
||||||
type BlockingQuery struct {
|
type BlockingQuery struct {
|
||||||
@ -49,6 +56,26 @@ type QueryOptions struct {
|
|||||||
RequireConsistent bool
|
RequireConsistent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryOption only applies to reads, so always true
|
||||||
|
func (q QueryOptions) IsRead() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q QueryOptions) AllowStaleRead() bool {
|
||||||
|
return q.AllowStale
|
||||||
|
}
|
||||||
|
|
||||||
|
type WriteRequest struct{}
|
||||||
|
|
||||||
|
// WriteRequest only applies to writes, always false
|
||||||
|
func (w WriteRequest) IsRead() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w WriteRequest) AllowStaleRead() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// QueryMeta allows a query response to include potentially
|
// QueryMeta allows a query response to include potentially
|
||||||
// useful metadata about a query
|
// useful metadata about a query
|
||||||
type QueryMeta struct {
|
type QueryMeta struct {
|
||||||
@ -70,6 +97,11 @@ type RegisterRequest struct {
|
|||||||
Address string
|
Address string
|
||||||
Service *NodeService
|
Service *NodeService
|
||||||
Check *HealthCheck
|
Check *HealthCheck
|
||||||
|
WriteRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RegisterRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeregisterRequest is used for the Catalog.Deregister endpoint
|
// DeregisterRequest is used for the Catalog.Deregister endpoint
|
||||||
@ -80,6 +112,11 @@ type DeregisterRequest struct {
|
|||||||
Node string
|
Node string
|
||||||
ServiceID string
|
ServiceID string
|
||||||
CheckID string
|
CheckID string
|
||||||
|
WriteRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *DeregisterRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
}
|
}
|
||||||
|
|
||||||
// DCSpecificRequest is used to query about a specific DC
|
// DCSpecificRequest is used to query about a specific DC
|
||||||
@ -89,6 +126,10 @@ type DCSpecificRequest struct {
|
|||||||
QueryOptions
|
QueryOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *DCSpecificRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
|
}
|
||||||
|
|
||||||
// ServiceSpecificRequest is used to query about a specific node
|
// ServiceSpecificRequest is used to query about a specific node
|
||||||
type ServiceSpecificRequest struct {
|
type ServiceSpecificRequest struct {
|
||||||
Datacenter string
|
Datacenter string
|
||||||
@ -99,6 +140,10 @@ type ServiceSpecificRequest struct {
|
|||||||
QueryOptions
|
QueryOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *ServiceSpecificRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
|
}
|
||||||
|
|
||||||
// NodeSpecificRequest is used to request the information about a single node
|
// NodeSpecificRequest is used to request the information about a single node
|
||||||
type NodeSpecificRequest struct {
|
type NodeSpecificRequest struct {
|
||||||
Datacenter string
|
Datacenter string
|
||||||
@ -107,6 +152,10 @@ type NodeSpecificRequest struct {
|
|||||||
QueryOptions
|
QueryOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *NodeSpecificRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
|
}
|
||||||
|
|
||||||
// ChecksInStateRequest is used to query for nodes in a state
|
// ChecksInStateRequest is used to query for nodes in a state
|
||||||
type ChecksInStateRequest struct {
|
type ChecksInStateRequest struct {
|
||||||
Datacenter string
|
Datacenter string
|
||||||
@ -115,6 +164,10 @@ type ChecksInStateRequest struct {
|
|||||||
QueryOptions
|
QueryOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *ChecksInStateRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
|
}
|
||||||
|
|
||||||
// Used to return information about a node
|
// Used to return information about a node
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Node string
|
Node string
|
||||||
@ -231,6 +284,11 @@ type KVSRequest struct {
|
|||||||
Datacenter string
|
Datacenter string
|
||||||
Op KVSOp // Which operation are we performing
|
Op KVSOp // Which operation are we performing
|
||||||
DirEnt DirEntry // Which directory entry
|
DirEnt DirEntry // Which directory entry
|
||||||
|
WriteRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *KVSRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyRequest is used to request a key, or key prefix
|
// KeyRequest is used to request a key, or key prefix
|
||||||
@ -241,6 +299,10 @@ type KeyRequest struct {
|
|||||||
QueryOptions
|
QueryOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *KeyRequest) RequestDatacenter() string {
|
||||||
|
return r.Datacenter
|
||||||
|
}
|
||||||
|
|
||||||
type IndexedDirEntries struct {
|
type IndexedDirEntries struct {
|
||||||
Index uint64
|
Index uint64
|
||||||
Entries DirEntries
|
Entries DirEntries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user