Documentation ¶
Index ¶
- func Register(pmap *PartitionMap, name string)
- func RegisterStatsService(svc PartitionedService)
- func RunRebalancer(svc PartitionedService, period time.Duration)
- type GetVersionRequest
- type GetVersionResponse
- type Partition
- type PartitionMap
- func (pmap *PartitionMap) AllTargets() []string
- func (pmap *PartitionMap) GetEndKey(key string) string
- func (pmap *PartitionMap) GetPartition(key string) Partition
- func (pmap *PartitionMap) GetStamp() time.Time
- func (pmap *PartitionMap) GetTarget(key string) string
- func (pmap *PartitionMap) GetVersion() string
- func (pmap *PartitionMap) Save(path string) error
- type PartitionStatsResponse
- type PartitionStatus
- type PartitionedService
- type PartitionedServiceBase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(pmap *PartitionMap, name string)
func RegisterStatsService ¶
func RegisterStatsService(svc PartitionedService)
func RunRebalancer ¶
func RunRebalancer(svc PartitionedService, period time.Duration)
Types ¶
type GetVersionRequest ¶
type GetVersionRequest struct {
Name string
}
type GetVersionResponse ¶
type PartitionMap ¶
type PartitionMap struct { P partitionList // contains filtered or unexported fields }
func LoadPartitionMap ¶
func LoadPartitionMap(path string) (*PartitionMap, error)
func MustLoadPartitionMap ¶
func MustLoadPartitionMap(path string) *PartitionMap
func NewHexEncodedRandomPartitionMap ¶
func NewHexEncodedRandomPartitionMap(nParts int, keyBits uint, targets []string) *PartitionMap
func NewPartitionMap ¶
func NewPartitionMap() *PartitionMap
func NewSimplePartitionMap ¶
func NewSimplePartitionMap(target string) *PartitionMap
func (*PartitionMap) AllTargets ¶
func (pmap *PartitionMap) AllTargets() []string
AllTargets returns a list of unique targets.
func (*PartitionMap) GetEndKey ¶
func (pmap *PartitionMap) GetEndKey(key string) string
GetEndKey returns the end key for the partition containing a key.
func (*PartitionMap) GetPartition ¶
func (pmap *PartitionMap) GetPartition(key string) Partition
GetPartition returns the Partition for a key.
func (*PartitionMap) GetStamp ¶
func (pmap *PartitionMap) GetStamp() time.Time
func (*PartitionMap) GetTarget ¶
func (pmap *PartitionMap) GetTarget(key string) string
GetTarget returns a target for the specified key.
func (*PartitionMap) GetVersion ¶
func (pmap *PartitionMap) GetVersion() string
GetVersion lazily computes a fingerprint of the partition map. This can be useful to verify that all instances of a program are using the same partition map.
func (*PartitionMap) Save ¶
func (pmap *PartitionMap) Save(path string) error
Save stores the partition map in a file, in JSON format.
type PartitionStatsResponse ¶
type PartitionStatus ¶
type PartitionStatus struct { Name string Target string Version string Stamp time.Time Counters map[string]int Err error }
func (PartitionStatus) Partitions ¶
func (s PartitionStatus) Partitions() int
func (PartitionStatus) Total ¶
func (s PartitionStatus) Total() int
type PartitionedService ¶
type PartitionedService interface { GetPartitionMap() *PartitionMap GetPartitionCounters() map[string]int SetPartitionCounters(map[string]int) GetSelfTarget() string Scan() <-chan string Move(key string) error }
Interface of a service that supports partitioning. You should provide your own Scan() and Move() methods, but it is possible to extend PartitionedServiceBase for the boilerplate methods.
type PartitionedServiceBase ¶
type PartitionedServiceBase struct { // Partition map (used by the client). Self is our target ID. Pmap *PartitionMap SelfTarget string // Partition counters. Pcounters map[string]int }
func (*PartitionedServiceBase) GetPartitionCounters ¶
func (pb *PartitionedServiceBase) GetPartitionCounters() map[string]int
func (*PartitionedServiceBase) GetPartitionMap ¶
func (pb *PartitionedServiceBase) GetPartitionMap() *PartitionMap
func (*PartitionedServiceBase) GetSelfTarget ¶
func (pb *PartitionedServiceBase) GetSelfTarget() string
func (*PartitionedServiceBase) SetPartitionCounters ¶
func (pb *PartitionedServiceBase) SetPartitionCounters(c map[string]int)
Click to show internal directories.
Click to hide internal directories.