inmemorytracker

package
v2.19.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryTracker

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

func NewInMemoryTracker

func NewInMemoryTracker(conf TrackerConfig, totalShards int64) *InMemoryTracker

func (*InMemoryTracker) DelShard

func (tracker *InMemoryTracker) DelShard(shardID int64)

DelShard allows you to manually reset shards in the state notice how i said reset and not delete, as the shards themselves are fixed.

func (*InMemoryTracker) GetGuild

func (tracker *InMemoryTracker) GetGuild(guildID int64) *dstate.GuildSet

func (*InMemoryTracker) GetMember

func (tracker *InMemoryTracker) GetMember(guildID int64, memberID int64) *dstate.MemberState

func (*InMemoryTracker) GetMemberPermissions

func (tracker *InMemoryTracker) GetMemberPermissions(guildID int64, channelID int64, memberID int64) (perms int64, ok bool)

func (*InMemoryTracker) GetMessages

func (tracker *InMemoryTracker) GetMessages(guildID int64, channelID int64, query *dstate.MessagesQuery) []*dstate.MessageState

func (*InMemoryTracker) GetRolePermisisons

func (tracker *InMemoryTracker) GetRolePermisisons(guildID int64, channelID int64, memberID int64, roles []int64) (perms int64, ok bool)

func (*InMemoryTracker) GetShardGuilds

func (tracker *InMemoryTracker) GetShardGuilds(shardID int64) []*dstate.GuildSet

func (*InMemoryTracker) HandleEvent

func (t *InMemoryTracker) HandleEvent(s *discordgo.Session, evt interface{})

func (*InMemoryTracker) IterateMembers

func (tracker *InMemoryTracker) IterateMembers(guildID int64, f func(chunk []*dstate.MemberState) bool)

this IterateMembers implementation is very simple, it makes a full copy of the member slice and calls f in one chunk

func (*InMemoryTracker) RunGCLoop

func (t *InMemoryTracker) RunGCLoop(interval time.Duration)

RunGCLoop starts a goroutine per shard that runs a gc on a guild per interval note that this is per shard, so if you have the interval set to 1s and 10 shards, there will effectively be 10 guilds per second gc'd

func (*InMemoryTracker) SetGuild

func (tracker *InMemoryTracker) SetGuild(gs *dstate.GuildSet)

SetGuild allows you to manually add guilds to the state tracker, for example when recovering state

func (*InMemoryTracker) SetMember

func (tracker *InMemoryTracker) SetMember(ms *dstate.MemberState)

SetMember allows you to manually add members to the state tracker, for example for caching reasons

type ShardTracker

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

func (*ShardTracker) HandleEvent

func (tracker *ShardTracker) HandleEvent(s *discordgo.Session, i interface{})

type SparseGuildState

type SparseGuildState struct {
	Guild       *dstate.GuildState
	Channels    []dstate.ChannelState
	Threads     []dstate.ChannelState
	Roles       []discordgo.Role
	Emojis      []discordgo.Emoji
	VoiceStates []discordgo.VoiceState
}

These are updated less frequently and so we remake the indiv lists on update this makes us able to just return a straight reference, since the object is effectively immutable TODO: reuse the interface version of this?

func SparseGuildStateFromDstate

func SparseGuildStateFromDstate(gs *dstate.GuildSet) *SparseGuildState

type TrackerConfig

type TrackerConfig struct {
	ChannelMessageLen int
	ChannelMessageDur time.Duration

	ChannelMessageLimitsF func(guildID int64) (int, time.Duration)

	RemoveOfflineMembersAfter time.Duration

	// Set this to avoid GC'ing ourselves
	BotMemberID int64
}

type WrappedMember

type WrappedMember struct {
	dstate.MemberState
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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