Documentation ¶
Index ¶
- Variables
- type Config
- type Handler
- type HashFunction
- type MD5HashFunction
- type MemberType
- type MembershipConfig
- type Ring
- func (r *Ring) AddListener(listenerId string, handler Handler)
- func (r *Ring) AddResponsibilityChangeListener(listenerId string, handler ShardResponsibilityHandler)
- func (r *Ring) GetLoadBalancers() []string
- func (r *Ring) GetNode(objKey string) (map[string]string, bool)
- func (r *Ring) RemoveListener(listenerId string)
- func (r *Ring) RemoveResponsibilityChangeListener(listenerId string)
- func (r *Ring) Shutdown() error
- type ShardResponsibility
- type ShardResponsibilityHandler
Constants ¶
This section is empty.
Variables ¶
var (
ErrRealNodeNotFound = errors.New("real node not found")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { BindAddr string Tags map[string]string NodeName string SeedAddresses []string VirtualNodeCount int HashFunction HashFunction Logger hclog.Logger MemberType MemberType }
type Handler ¶
type Handler interface { Join(nodeName string, tags map[string]string) error Leave(nodeName string) error }
Handler interface to get notified when a new member joins or existing member leaves the ring.
type HashFunction ¶
type HashFunction interface {
// contains filtered or unexported methods
}
HashFunction hashes key (string) to uint64.
type MD5HashFunction ¶
type MD5HashFunction struct {
HashFunction
}
MD5HashFunction Default hash function
type MemberType ¶ added in v0.1.3
type MemberType uint8
const ( ShardMember MemberType = iota // RingMember takes part in the sharding. LoadBalancerMember // Doesn't take part in the sharding, but knows the addresses of member. )
type MembershipConfig ¶
type Ring ¶ added in v0.1.1
type Ring struct { Config // contains filtered or unexported fields }
func (*Ring) AddListener ¶ added in v0.1.1
AddListener registers the listener that will be called upon the node join/leave event in the ring.
func (*Ring) AddResponsibilityChangeListener ¶ added in v0.1.7
func (r *Ring) AddResponsibilityChangeListener(listenerId string, handler ShardResponsibilityHandler)
AddResponsibilityChangeListener registers the listener that will be called when the current node responsibility changes due to joining of the new nodes.
func (*Ring) GetLoadBalancers ¶ added in v0.1.3
GetLoadBalancers gets the load balancers of the ring.
func (*Ring) RemoveListener ¶ added in v0.1.1
RemoveListener removes the listener using the listenerId.
func (*Ring) RemoveResponsibilityChangeListener ¶ added in v0.1.7
RemoveResponsibilityChangeListener removes the listener from the router using the listenerId.
type ShardResponsibility ¶ added in v0.1.7
type ShardResponsibility struct {
// contains filtered or unexported fields
}
ShardResponsibility to determine if an object should get be transferred to the given node.
func (*ShardResponsibility) ResponsibleNode ¶ added in v0.1.7
func (s *ShardResponsibility) ResponsibleNode() string
func (*ShardResponsibility) ResponsibleNodeTags ¶ added in v0.1.7
func (s *ShardResponsibility) ResponsibleNodeTags() map[string]string
func (*ShardResponsibility) Transfer ¶ added in v0.1.7
func (s *ShardResponsibility) Transfer(objectKey string) bool
type ShardResponsibilityHandler ¶ added in v0.1.7
type ShardResponsibilityHandler interface { // OnChange This will be fired if the current node is affected by the new members. OnChange([]ShardResponsibility) }
ShardResponsibilityHandler to listen to responsibility change when any new member joins the ring at the next position of the current node.