sharding

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: Apache-2.0 Imports: 8 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShardIDByGuild

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

Types

type Config

type Config struct {
	Logger                log.Logger
	ShardIDs              map[int]struct{}
	ShardCount            int
	ShardSplitCount       int
	AutoScaling           bool
	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 WithAutoScaling added in v0.11.0

func WithAutoScaling(autoScaling bool) ConfigOpt

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 WithShardSplitCount added in v0.11.0

func WithShardSplitCount(shardSplitCount int) ConfigOpt

func WithShards

func WithShards(shards ...int) ConfigOpt

type ShardManager

type ShardManager interface {
	Logger() log.Logger

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

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

	ShardByGuildID(guildId snowflake.ID) gateway.Gateway
	Shard(shardID int) gateway.Gateway
	Shards() map[int]gateway.Gateway
}

func New

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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