Documentation ¶
Overview ¶
This file is largely a copy of https://github.com/prometheus/prometheus/blob/master/util/treecache/treecache.go, minus the external Prometheus dependencies. I will try my bet to keep these up to date if any changes are made to the original file
Index ¶
Constants ¶
const DefaultInitialUriWatchTimeout = 10 * time.Second
Variables ¶
var Logger = log.New(ioutil.Discard, "[D2] ", log.Ldate|log.Ltime|log.Lmicroseconds|log.Lshortfile|log.LUTC)
Functions ¶
func ClustersPath ¶
func EnableD2Logging ¶
func EnableD2Logging()
func ServicesPath ¶
Types ¶
type Client ¶
type Client struct { Conn *zk.Conn // During the initial listing of the /d2/uris node for a new cluster, this duration specifies how long to for the // first host to show up. If the /d2/services node exists for a service, it is impossible to know whether or not a // host will ever show up in the /d2/uris node for that service, which is why this timeout is provided. // A positive value will be used as-is, a 0 value will default to DefaultInitialUriWatchTimeout and a negative value // disables the timeout altogether InitialZkWatchTimeout time.Duration // contains filtered or unexported fields }
func (*Client) ResolveHostnameAndContextForQuery ¶
func (*Client) SingleServiceClient ¶
func (c *Client) SingleServiceClient(serviceName string) *SingleServiceClient
SingleServiceClient will always return URIs from the given serviceName instead of getting them from the service specified in resourceBaseName in ResolveHostnameAndContextForQuery. Some services announce to special D2 cluster instead of the resource name (i.e. by default, the service name is equal to the resource name).
type Cluster ¶
type Cluster struct { ClusterName string `json:"clusterName"` PartitionProperties struct { HashAlgorithm string `json:"hashAlgorithm"` PartitionCount int `json:"partitionCount"` PartitionKeyRegex string `json:"partitionKeyRegex"` PartitionType string `json:"partitionType"` } `json:"partitionProperties"` }
type SingleServiceClient ¶
type SingleServiceClient struct {
// contains filtered or unexported fields
}
func (*SingleServiceClient) ResolveHostnameAndContextForQuery ¶
type TreeCache ¶
type TreeCache struct {
// contains filtered or unexported fields
}
A TreeCache keeps data from all children of a Zookeeper path locally cached and updated according to received events.
func NewTreeCache ¶
func NewTreeCache(conn *zk.Conn, path string, events chan TreeCacheEvent) *TreeCache
NewTreeCache creates a new TreeCache for a given path.
type TreeCacheEvent ¶
A TreeCacheEvent models a Zookeeper event for a path.
type Uri ¶
type Uri struct { Weights map[url.URL]float64 Properties map[url.URL]UriProperty PartitionDesc map[url.URL]map[int]float64 }