Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateTokens(numTokens int, takenTokens []uint32) []uint32
- func ProtoDescFactory() proto.Message
- type ByToken
- type CASCallback
- type Codec
- type Config
- type ConsulClient
- type ConsulConfig
- type Operation
- type ProtoCodec
- type Ring
- func (r *Ring) BatchGet(keys []uint32, n int, op Operation) ([][]*IngesterDesc, error)
- func (r *Ring) Collect(ch chan<- prometheus.Metric)
- func (r *Ring) Describe(ch chan<- *prometheus.Desc)
- func (r *Ring) Get(key uint32, n int, op Operation) ([]*IngesterDesc, error)
- func (r *Ring) GetAll() []*IngesterDesc
- func (r *Ring) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Ring) Stop()
Constants ¶
const (
// ConsulKey is the key under which we store the ring in consul.
ConsulKey = "ring"
)
Variables ¶
var ErrEmptyRing = errors.New("empty circle")
ErrEmptyRing is the error returned when trying to get an element when nothing has been added to hash.
var ( // ErrNotFound is returned by ConsulClient.Get. ErrNotFound = fmt.Errorf("Not found") )
Functions ¶
func GenerateTokens ¶
GenerateTokens make numTokens random tokens, none of which clash with takenTokens. Assumes takenTokens is sorted.
Types ¶
type CASCallback ¶
CASCallback is the type of the callback to CAS. If err is nil, out must be non-nil.
type Config ¶
type Config struct { ConsulConfig HeartbeatTimeout time.Duration }
Config for a Ring
func (*Config) RegisterFlags ¶
RegisterFlags adds the flags required to config this to the given FlagSet
type ConsulClient ¶
type ConsulClient interface { CAS(key string, f CASCallback) error WatchPrefix(path string, done <-chan struct{}, f func(string, interface{}) bool) WatchKey(key string, done <-chan struct{}, f func(interface{}) bool) Get(key string) (interface{}, error) PutBytes(key string, buf []byte) error }
ConsulClient is a high-level client for Consul, that exposes operations such as CAS and Watch which take callbacks. It also deals with serialisation by having an instance factory passed in to methods and deserialising into that.
func NewConsulClient ¶
func NewConsulClient(cfg ConsulConfig, codec Codec) (ConsulClient, error)
NewConsulClient returns a new ConsulClient.
func NewMockConsulClient ¶
func NewMockConsulClient() ConsulClient
NewMockConsulClient makes a new mock consul client.
func PrefixClient ¶
func PrefixClient(client ConsulClient, prefix string) ConsulClient
PrefixClient takes a ConsulClient and forces a prefix on all its operations.
type ConsulConfig ¶
type ConsulConfig struct { Host string Prefix string HTTPClientTimeout time.Duration Mock ConsulClient }
ConsulConfig to create a ConsulClient
func (*ConsulConfig) RegisterFlags ¶
func (cfg *ConsulConfig) RegisterFlags(f *flag.FlagSet)
RegisterFlags adds the flags required to config this to the given FlagSet
type ProtoCodec ¶
ProtoCodec is a Codec for proto/snappy
func (ProtoCodec) Decode ¶
func (p ProtoCodec) Decode(bytes []byte) (interface{}, error)
Decode implements Codec
func (ProtoCodec) Encode ¶
func (p ProtoCodec) Encode(msg interface{}) ([]byte, error)
Encode implements Codec
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring holds the information about the members of the consistent hash circle.
func (*Ring) BatchGet ¶
BatchGet returns n (or more) ingesters which form the replicas for the given key. The order of the result matches the order of the input.
func (*Ring) Collect ¶
func (r *Ring) Collect(ch chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*Ring) Describe ¶
func (r *Ring) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.