sharding

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: Apache-2.0 Imports: 9 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShardIDByGuild

func ShardIDByGuild(guildID snowflake.Snowflake, shardCount int) int

Types

type Config

type Config struct {
	Logger                log.Logger
	Shards                *IntSet
	ShardCount            int
	GatewayCreateFunc     gateway.CreateFunc
	GatewayConfigOpts     []gateway.ConfigOpt
	RateLimiter           srate.Limiter
	RateLimiterConfigOpts []srate.ConfigOpt
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Apply

func (c *Config) Apply(opts []ConfigOpt)

type ConfigOpt

type ConfigOpt func(config *Config)

func WithGatewayConfigOpts

func WithGatewayConfigOpts(opts ...gateway.ConfigOpt) ConfigOpt

func WithGatewayCreateFunc

func WithGatewayCreateFunc(gatewayCreateFunc gateway.CreateFunc) ConfigOpt

func WithLogger

func WithLogger(logger log.Logger) ConfigOpt

func WithRateLimiter

func WithRateLimiter(rateLimiter srate.Limiter) ConfigOpt

func WithRateLimiterConfigOpt

func WithRateLimiterConfigOpt(opts ...srate.ConfigOpt) ConfigOpt

func WithShardCount

func WithShardCount(shardCount int) ConfigOpt

func WithShards

func WithShards(shards ...int) ConfigOpt

type IntSet

type IntSet struct {
	// contains filtered or unexported fields
}

func NewIntSet

func NewIntSet(ints ...int) *IntSet

func (*IntSet) Add

func (s *IntSet) Add(i int)

func (*IntSet) Delete

func (s *IntSet) Delete(i int)

func (*IntSet) Has

func (s *IntSet) Has(i int) bool

func (*IntSet) Len

func (s *IntSet) Len() int

func (*IntSet) String

func (s *IntSet) String() string

func (*IntSet) Values

func (s *IntSet) Values() []int

type ShardManager

type ShardManager interface {
	Logger() log.Logger
	RateLimiter() srate.Limiter

	Open(ctx context.Context)
	ReOpen(ctx context.Context)
	Close(ctx context.Context)

	OpenShard(ctx context.Context, shardID int) error
	ReOpenShard(ctx context.Context, shardID int) error
	CloseShard(ctx context.Context, shardID int)

	GetGuildShard(guildId snowflake.Snowflake) gateway.Gateway

	Shard(shardID int) gateway.Gateway
	Shards() *ShardsMap
}

func New

func New(token string, eventHandlerFunc gateway.EventHandlerFunc, opts ...ConfigOpt) ShardManager

type ShardsMap

type ShardsMap struct {
	// contains filtered or unexported fields
}

func NewShardsMap

func NewShardsMap() *ShardsMap

func (*ShardsMap) AllIDs

func (m *ShardsMap) AllIDs() []int

func (*ShardsMap) Delete

func (m *ShardsMap) Delete(shardId int) gateway.Gateway

func (*ShardsMap) Get

func (m *ShardsMap) Get(shardId int) gateway.Gateway

func (*ShardsMap) Has

func (m *ShardsMap) Has(shardId int) bool

func (*ShardsMap) Set

func (m *ShardsMap) Set(shardId int, shard gateway.Gateway)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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