Documentation ¶
Index ¶
- type Cache
- func (st *Cache) Channel(ID Snowflake) (*resource.Channel, error)
- func (st *Cache) Clear()
- func (st *Cache) Close() (err error)
- func (st *Cache) Guild(ID Snowflake) (*resource.Guild, error)
- func (s *Cache) Myself() *resource.User
- func (st *Cache) ProcessChannel(details *ChannelDetail)
- func (st *Cache) ProcessGuild(gd *GuildDetail)
- func (st *Cache) ProcessUser(details *UserDetail)
- func (st *Cache) User(ID Snowflake) (*resource.User, error)
- type Cacher
- type ChannelCache
- type ChannelCacher
- type ChannelDetail
- type ChannelUserCacher
- type GuildCache
- type GuildCacher
- type GuildChannelCacher
- type GuildDetail
- type GuildUserCacher
- type UserCache
- func (st *UserCache) Chan() chan<- *UserDetail
- func (st *UserCache) Clear()
- func (st *UserCache) Close() (err error)
- func (st *UserCache) Process(uc *UserDetail)
- func (st *UserCache) Size() int
- func (st *UserCache) StartListener() (err error)
- func (st *UserCache) User(ID Snowflake) (*resource.User, error)
- type UserCacher
- type UserDetail
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { Users UserCacher Channels ChannelCacher Guilds GuildCacher // TODO: implement // contains filtered or unexported fields }
func (*Cache) ProcessChannel ¶
func (st *Cache) ProcessChannel(details *ChannelDetail)
func (*Cache) ProcessGuild ¶
func (st *Cache) ProcessGuild(gd *GuildDetail)
func (*Cache) ProcessUser ¶
func (st *Cache) ProcessUser(details *UserDetail)
type Cacher ¶
type Cacher interface { User(ID Snowflake) (*resource.User, error) Channel(ID Snowflake) (*resource.Channel, error) Guild(ID Snowflake) (*resource.Guild, error) Myself() *resource.User // clear all the cached objects Clear() }
Cacher used by the session interface, so the user cannot access methods to ruin the cache state
type ChannelCache ¶
type ChannelCache struct {
// contains filtered or unexported fields
}
func NewChannelCache ¶
func NewChannelCache(userCacher ChannelUserCacher) *ChannelCache
func (*ChannelCache) Chan ¶
func (st *ChannelCache) Chan() chan<- *ChannelDetail
func (*ChannelCache) Channel ¶
func (st *ChannelCache) Channel(ID Snowflake) (*resource.Channel, error)
func (*ChannelCache) Close ¶
func (st *ChannelCache) Close() (err error)
func (*ChannelCache) Process ¶
func (st *ChannelCache) Process(cd *ChannelDetail)
func (*ChannelCache) Size ¶
func (st *ChannelCache) Size() int
type ChannelCacher ¶
type ChannelCacher interface { Process(cd *ChannelDetail) Chan() chan<- *ChannelDetail Channel(ID Snowflake) (*resource.Channel, error) Size() int Clear() Close() error }
type ChannelDetail ¶
type ChannelDetail struct { Channel *resource.Channel Dirty bool Action string //event.* for specific behavior, such as delete }
ChannelDetail holds information about the "incoming" channel object. how it was created, should it be considered dirty, etc.
type ChannelUserCacher ¶
type ChannelUserCacher interface { Process(ud *UserDetail) User(ID Snowflake) (*resource.User, error) }
type GuildCache ¶
type GuildCache struct {
// contains filtered or unexported fields
}
GuildCache handles guild caching
func NewGuildCache ¶
func NewGuildCache(userCacher GuildUserCacher, channelCacher GuildChannelCacher) *GuildCache
NewGuildCache creates a new guild cacher, and starts listening for inputs
func (*GuildCache) Chan ¶
func (st *GuildCache) Chan() chan<- *GuildDetail
func (*GuildCache) Close ¶
func (st *GuildCache) Close() (err error)
func (*GuildCache) Process ¶
func (st *GuildCache) Process(gd *GuildDetail)
type GuildCacher ¶
type GuildCacher interface { Process(cd *GuildDetail) Chan() chan<- *GuildDetail Guild(ID Snowflake) (*resource.Guild, error) Clear() Close() error }
type GuildChannelCacher ¶
type GuildChannelCacher interface {
Process(ud *ChannelDetail)
}
type GuildDetail ¶
type GuildUserCacher ¶
type GuildUserCacher interface {
Process(ud *UserDetail)
}
type UserCache ¶
type UserCache struct {
// contains filtered or unexported fields
}
UserCache handles user caching
func NewUserCache ¶
func NewUserCache() *UserCache
NewUserCache creates a new user cacher, and starts listening for inputs
func (*UserCache) Chan ¶
func (st *UserCache) Chan() chan<- *UserDetail
func (*UserCache) Process ¶
func (st *UserCache) Process(uc *UserDetail)
func (*UserCache) StartListener ¶
type UserCacher ¶
type UserCacher interface { Process(ud *UserDetail) Chan() chan<- *UserDetail User(ID Snowflake) (*resource.User, error) Size() int Clear() StartListener() error Close() error }
type UserDetail ¶
type UserDetail struct { User *resource.User Dirty bool // if the user is a part of another struct, like Member, we only need to check that it exists. otherwise dirty. }
UserCache made this a struct, in case I want to add details/data in the future for optimizing caching.
Click to show internal directories.
Click to hide internal directories.