groups

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

func (c *EtcdGroupService) GroupCountMembers(ctx context.Context, groupName string) (int, error)

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

func (c *EtcdGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error)

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

type MemoryGroup struct {
	Uids        []string
	LastRefresh int64
	TTL         int64
}

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

func (c *MemoryGroupService) GroupCountMembers(ctx context.Context, groupName string) (int, error)

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

func (c *MemoryGroupService) GroupMembers(ctx context.Context, groupName string) ([]string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL