Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Membership ¶
type Membership interface { // Register adds name to the list of available servers. The registration lasts // for timeout duration. Register should be called again before timeout expires // in order to remain a member of the group. Register(ctx context.Context, memberName string, timeout time.Duration) error // GetMembers retrieves the list of all currently registered members. Members // that have registered but timed out will not be returned. GetMembers(ctx context.Context) ([]string, error) }
Membership allows services to register themselves as members of a group and the list of all members can be retrieved by any member in the group.
type RedisMembership ¶
type RedisMembership struct { // Prefix is a way of namespacing your group membership Prefix string // Pool should be an already-initialized redis pool Pool *redis.Pool // RepeatCount is the number of times GetMembers should ask Redis for the list // of members in the pool. As seen in the Redis docs "The SCAN family of // commands only offer limited guarantees about the returned elements" // (https://redis.io/commands/scan). In order to overcome some of these // limitations and gain confidence that the list of members is complete (and // preferring to get older members than miss current members), you can // configure RedisMembership to repeat the request for all members and union // the results, returning a potentially more complete list. This option // determines how many times RedisMembership asks Redis for the list of members // in the pool before taking the union of results and returning. Defaults to // 2. RepeatCount int }
RedisMembership implements the Membership interface using Redis as the backend
func (*RedisMembership) GetMembers ¶
func (rm *RedisMembership) GetMembers(ctx context.Context) ([]string, error)
GetMembers reaches out to Redis to retrieve a list of all members in the cluster. It does this multiple times (how many is configured on initializition) and takes the union of the results returned.
Click to show internal directories.
Click to hide internal directories.