Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Autocache ¶
type Autocache struct { GroupcachePool *groupcache.HTTPPool Memberlist *memberlist.Memberlist // contains filtered or unexported fields }
Autocache implements automatic, distributed membership for a cluster of cache pool peers.
func New ¶
New creates a new Autocache instance, setups memberlist, and invokes groupcache's peer pooling handlers. Note, by design a groupcache pool can only be made _once_.
func (*Autocache) Join ¶
Join is used to take an existing Memberlist and attempt to join a cluster by contacting all the given hosts and performing a state sync. Initially, the Memberlist only contains our own state, so doing this will cause remote nodes to become aware of the existence of this node, effectively joining the cluster.
This returns the number of hosts successfully contacted and an error if none could be reached. If an error is returned, the node did not successfully join the cluster.
If an empty list is provided to this function, the memberlist will join itself.
func (*Autocache) NotifyJoin ¶
func (ac *Autocache) NotifyJoin(node *memberlist.Node)
NotifyJoin is invoked when a node is detected to have joined. The Node argument must not be modified. Implements memberlist's EventDelegate's interface.
func (*Autocache) NotifyLeave ¶
func (ac *Autocache) NotifyLeave(node *memberlist.Node)
NotifyLeave is invoked when a node is detected to have left. The Node argument must not be modified. Implements memberlist's EventDelegate's interface.
func (*Autocache) NotifyUpdate ¶
func (ac *Autocache) NotifyUpdate(node *memberlist.Node)
NotifyUpdate is invoked when a node is detected to have updated, usually involving the meta data. The Node argument must not be modified. Implements memberlist EventDelegate's interface.
type Options ¶
type Options struct { // Groupcache related // // Groupcache's pool is a HTTP handler. Scheme and port should be set // such that group cache's internal http client, used to fetch, distributed // keys, knows how to build the request URL. PoolOptions *groupcache.HTTPPoolOptions PoolScheme string PoolPort int // Transport optionally specifies an http.RoundTripper for the client // to use when it makes a request to another groupcache node. // If nil, the client uses http.DefaultTransport. PoolTransportFn func(context.Context) http.RoundTripper // Context optionally specifies a context for the server to use when it // receives a request. // If nil, the server uses the request's context PoolContext func(*http.Request) context.Context // Memberlist related // // MemberlistConfig ist he memberlist configuration to use. // If empty, `DefaultLANConfig` is used. MemberlistConfig *memberlist.Config // Logger is a custom logger which you provide. Logger *log.Logger }
Options are the configurations of a Autocache.