fixrdb

package
v0.0.0-...-93509e5 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2015 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var ErrAlreadySubscribed = errors.New("You are already subscribed")

Throws ErrAlreadySubscribed when it tries to subscribe an ID but he already is subscribed.

View Source
var ErrInvalidBase = errors.New("This base is invalid.")

Throws ErrInvalidBase when the base is invalid.

View Source
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

func New(transport, port string) *FixrDB

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

func (fa *FixrDB) ClearRates(ID int) error

Clear all the rates of a given ID.

func (*FixrDB) Close

func (fa *FixrDB) Close()

Closes underlying connection with Redis.

func (*FixrDB) GetRates

func (fa *FixrDB) GetRates(ID int) ([]string, error)

Returns all rates for a given ID Redis error otherwise

func (*FixrDB) GetRegistered

func (fa *FixrDB) GetRegistered() ([]string, error)

Returns all registered users Redis error otherwise

func (*FixrDB) GetSetting

func (fa *FixrDB) GetSetting(ID int, prop string) (string, error)

Gets a property from the `user:%id` map. Returns an error if there's something wrong.

func (*FixrDB) RemoveRate

func (fa *FixrDB) RemoveRate(ID int, rate string) error

Removes a given rate of an ID. Returns an error if something goes wrong.

func (*FixrDB) SetBase

func (fa *FixrDB) SetBase(ID int, base string) (bool, error)

Sets the base for a given ID

func (*FixrDB) SetRates

func (fa *FixrDB) SetRates(ID int, rates []string) error

Sets the Rates for given ID. Returns a error if something goes wrong.

func (*FixrDB) Subscribe

func (fa *FixrDB) Subscribe(ID int) (bool, error)

Subscribes an ID, if he isn't already subscribed. Returns ErrAlreadySubscribed if already subscribed

func (*FixrDB) Unsubscribe

func (fa *FixrDB) Unsubscribe(ID int) (bool, error)

Unsubscribes a user, if he isn't already.

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.

func (RedisError) Error

func (r RedisError) Error() string

Implement error interface.

Jump to

Keyboard shortcuts

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