Documentation ¶
Overview ¶
Redis data structures:
users :: SET
user:%d :: MAP
rates:%d :: SET
These are the data structures FixrBot uses to keep track of:
Users names and currency base
Registered users
The rates preferences of a given user.
Index ¶
- Variables
- type FixrDB
- func (fa *FixrDB) ClearRates(ID int) error
- func (fa *FixrDB) Close()
- func (fa *FixrDB) GetRates(ID int) ([]string, error)
- func (fa *FixrDB) GetRegistered() ([]string, error)
- func (fa *FixrDB) GetSetting(ID int, prop string) (string, error)
- func (fa *FixrDB) RemoveRate(ID int, rate string) error
- func (fa *FixrDB) SetBase(ID int, base string) (bool, error)
- func (fa *FixrDB) SetRates(ID int, rates []string) error
- func (fa *FixrDB) Subscribe(ID int) (bool, error)
- func (fa *FixrDB) Unsubscribe(ID int) (bool, error)
- type RedisError
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadySubscribed = errors.New("You are already subscribed")
Throws ErrAlreadySubscribed when it tries to subscribe an ID but he already is subscribed.
var ErrInvalidBase = errors.New("This base is invalid.")
Throws ErrInvalidBase when the base is invalid.
var ErrNotSubscribed = errors.New("You are not subscribed.")
Throws ErroNotSubscribed when user should be subscribed but isn't.
Functions ¶
This section is empty.
Types ¶
type FixrDB ¶
type FixrDB struct {
// contains filtered or unexported fields
}
The FixrDB access the backend, that is Redis.
func New ¶
New creates a *FixrDB and dials a connection to Redis. If redis isn't available on given transport and port, it panics.
func (*FixrDB) ClearRates ¶
Clear all the rates of a given ID.
func (*FixrDB) GetRegistered ¶
Returns all registered users Redis error otherwise
func (*FixrDB) GetSetting ¶
Gets a property from the `user:%id` map. Returns an error if there's something wrong.
func (*FixrDB) RemoveRate ¶
Removes a given rate of an ID. Returns an error if something goes wrong.
type RedisError ¶
type RedisError struct {
// contains filtered or unexported fields
}
Returns an generic RedisError when appropriate. Today, this doesn't do anything, but we can type match on this if we have to.