Documentation ¶
Index ¶
- type EtcdGroupService
- func (c *EtcdGroupService) GroupAddMember(ctx context.Context, groupName, uid string) error
- func (c *EtcdGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error)
- func (c *EtcdGroupService) GroupCountMembers(ctx context.Context, groupName string) (int, error)
- func (c *EtcdGroupService) GroupCreate(ctx context.Context, groupName string) error
- func (c *EtcdGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error
- func (c *EtcdGroupService) GroupDelete(ctx context.Context, groupName string) error
- func (c *EtcdGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error)
- func (c *EtcdGroupService) GroupRemoveAll(ctx context.Context, groupName string) error
- func (c *EtcdGroupService) GroupRemoveMember(ctx context.Context, groupName, uid string) error
- func (c *EtcdGroupService) GroupRenewTTL(ctx context.Context, groupName string) error
- type GroupService
- type MemoryGroup
- type MemoryGroupService
- func (c *MemoryGroupService) GroupAddMember(ctx context.Context, groupName, uid string) error
- func (c *MemoryGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error)
- func (c *MemoryGroupService) GroupCountMembers(ctx context.Context, groupName string) (int, error)
- func (c *MemoryGroupService) GroupCreate(ctx context.Context, groupName string) error
- func (c *MemoryGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error
- func (c *MemoryGroupService) GroupDelete(ctx context.Context, groupName string) error
- func (c *MemoryGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error)
- func (c *MemoryGroupService) GroupRemoveAll(ctx context.Context, groupName string) error
- func (c *MemoryGroupService) GroupRemoveMember(ctx context.Context, groupName, uid string) error
- func (c *MemoryGroupService) GroupRenewTTL(ctx context.Context, groupName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EtcdGroupService ¶
type EtcdGroupService struct { }
EtcdGroupService base ETCD struct solution
func NewEtcdGroupService ¶
func NewEtcdGroupService(conf *config.Config, clientOrNil *clientv3.Client) (*EtcdGroupService, error)
NewEtcdGroupService returns a new group instance
func (*EtcdGroupService) GroupAddMember ¶
func (c *EtcdGroupService) GroupAddMember(ctx context.Context, groupName, uid string) error
GroupAddMember adds UID to group
func (*EtcdGroupService) GroupContainsMember ¶
func (c *EtcdGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error)
GroupContainsMember checks whether a UID is contained in current group or not
func (*EtcdGroupService) GroupCountMembers ¶
GroupCountMembers get current member amount in group
func (*EtcdGroupService) GroupCreate ¶
func (c *EtcdGroupService) GroupCreate(ctx context.Context, groupName string) error
GroupCreate creates a group struct inside ETCD, without TTL
func (*EtcdGroupService) GroupCreateWithTTL ¶
func (c *EtcdGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error
GroupCreateWithTTL creates a group struct inside ETCD, with TTL, using leaseID
func (*EtcdGroupService) GroupDelete ¶
func (c *EtcdGroupService) GroupDelete(ctx context.Context, groupName string) error
GroupDelete deletes the whole group, including members and base group
func (*EtcdGroupService) GroupMembers ¶
GroupMembers returns all member's UIDs
func (*EtcdGroupService) GroupRemoveAll ¶
func (c *EtcdGroupService) GroupRemoveAll(ctx context.Context, groupName string) error
GroupRemoveAll clears all UIDs in the group
func (*EtcdGroupService) GroupRemoveMember ¶
func (c *EtcdGroupService) GroupRemoveMember(ctx context.Context, groupName, uid string) error
GroupRemoveMember removes specified UID from group
func (*EtcdGroupService) GroupRenewTTL ¶
func (c *EtcdGroupService) GroupRenewTTL(ctx context.Context, groupName string) error
GroupRenewTTL will renew ETCD lease TTL
type GroupService ¶
type GroupService interface { GroupAddMember(ctx context.Context, groupName, uid string) error GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) GroupCountMembers(ctx context.Context, groupName string) (int, error) GroupCreate(ctx context.Context, groupName string) error GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error GroupDelete(ctx context.Context, groupName string) error GroupMembers(ctx context.Context, groupName string) ([]string, error) GroupRemoveAll(ctx context.Context, groupName string) error GroupRemoveMember(ctx context.Context, groupName, uid string) error GroupRenewTTL(ctx context.Context, groupName string) error }
GroupService has ranking methods
type MemoryGroup ¶
MemoryGroup is the struct stored in each group key(which is the name of the group)
type MemoryGroupService ¶
type MemoryGroupService struct { }
MemoryGroupService base in server memory solution
func NewMemoryGroupService ¶
func NewMemoryGroupService(conf *config.Config) *MemoryGroupService
NewMemoryGroupService returns a new group instance
func (*MemoryGroupService) GroupAddMember ¶
func (c *MemoryGroupService) GroupAddMember(ctx context.Context, groupName, uid string) error
GroupAddMember adds UID to group
func (*MemoryGroupService) GroupContainsMember ¶
func (c *MemoryGroupService) GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error)
GroupContainsMember check whether an UID is contained in given group or not
func (*MemoryGroupService) GroupCountMembers ¶
GroupCountMembers get current member amount in group
func (*MemoryGroupService) GroupCreate ¶
func (c *MemoryGroupService) GroupCreate(ctx context.Context, groupName string) error
GroupCreate creates a group without TTL
func (*MemoryGroupService) GroupCreateWithTTL ¶
func (c *MemoryGroupService) GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error
GroupCreateWithTTL creates a group with TTL, which the go routine will clean later
func (*MemoryGroupService) GroupDelete ¶
func (c *MemoryGroupService) GroupDelete(ctx context.Context, groupName string) error
GroupDelete deletes the whole group, including members and base group
func (*MemoryGroupService) GroupMembers ¶
GroupMembers returns all member's UID in given group
func (*MemoryGroupService) GroupRemoveAll ¶
func (c *MemoryGroupService) GroupRemoveAll(ctx context.Context, groupName string) error
GroupRemoveAll clears all UIDs from group
func (*MemoryGroupService) GroupRemoveMember ¶
func (c *MemoryGroupService) GroupRemoveMember(ctx context.Context, groupName, uid string) error
GroupRemoveMember removes specific UID from group
func (*MemoryGroupService) GroupRenewTTL ¶
func (c *MemoryGroupService) GroupRenewTTL(ctx context.Context, groupName string) error
GroupRenewTTL will renew lease TTL