Documentation ¶
Index ¶
- Variables
- type Config
- type HA
- func (h *HA) CacheRead(cache, key string, want interface{}) (interface{}, error)
- func (h *HA) CacheWrite(cache, key string, data interface{}, ttl time.Duration) error
- func (h *HA) Lock(obj interface{}) (bool, error)
- func (h *HA) LockVoice(channelID string) (bool, error)
- func (h *HA) SendVoiceCommand(channelID string, command VoiceCommand) error
- func (h *HA) Unlock(obj interface{}) error
- func (h *HA) UnlockVoice(channelID string) error
- func (h *HA) WatchVoiceCommands(ctx context.Context, channelID string) chan VoiceCommand
- type VoiceCommand
Constants ¶
This section is empty.
Variables ¶
var ErrorCacheKeyNotExist = errors.New("Cache key does not exist")
ErrorCacheKeyNotExist is the error the cache returns if a key does not exist
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Session *discordgo.Session HA bool LockUpdateInterval time.Duration LockTTL time.Duration EtcdEndpoints []string Context context.Context }
Config contains the configuration for HA
type HA ¶
type HA struct {
// contains filtered or unexported fields
}
HA is a helper struct for high available discordgo using etcd
func (*HA) CacheRead ¶
CacheRead reads a key from a specific cache, returns ErrorCacheKeyNotExist if not found
func (*HA) CacheWrite ¶
CacheWrite writes an object to a specific cache with a specific key, will be purged after TTL expires
func (*HA) Lock ¶
Lock tries to acquire a lock on an event, it will return true if the instance that requests it may process the request.
func (*HA) SendVoiceCommand ¶
func (h *HA) SendVoiceCommand(channelID string, command VoiceCommand) error
SendVoiceCommand sends a string command to the instance handling the voice channel These can be received using WatchVoiceCommands
func (*HA) UnlockVoice ¶
UnlockVoice unlocks a voice channel ID
func (*HA) WatchVoiceCommands ¶
func (h *HA) WatchVoiceCommands(ctx context.Context, channelID string) chan VoiceCommand
WatchVoiceCommands gives a channel with commands transmitted by SendVoiceCommand