Documentation ¶
Index ¶
- Variables
- func New(config Config) *http.Server
- type Config
- type Dependency
- func (d *Dependency) GetAll(ctx context.Context) ([]byte, error)
- func (d *Dependency) GetDukunPoints(ctx context.Context) ([]byte, error)
- func (d *Dependency) GetHourly(ctx context.Context) ([]byte, error)
- func (d *Dependency) GetTotal(ctx context.Context) ([]byte, error)
- func (d *Dependency) LastUpdated(r Endpoint) (time.Time, error)
- type Endpoint
- type Hourly
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidValue = errors.New("invalid value")
Functions ¶
Types ¶
type Config ¶
type Config struct { DB *sqlx.DB Mongo *mongo.Client MongoDBName string Memory *bigcache.BigCache Environment string ListeningAddress string }
Config is the configuration struct for the server package. Only the Port field is optional. It will be set to 8080 if not set.
type Dependency ¶
type Dependency struct { DB *sqlx.DB Memory *bigcache.BigCache Mongo *mongo.Client MongoDBName string }
Dependency specifies the dependency injection struct for the server package to use.
func (*Dependency) GetAll ¶
func (d *Dependency) GetAll(ctx context.Context) ([]byte, error)
GetAll fetch the users' data either it's from the in memory cache or from the database (if the data does not exist on the memory cache).
func (*Dependency) GetDukunPoints ¶
func (d *Dependency) GetDukunPoints(ctx context.Context) ([]byte, error)
func (*Dependency) GetHourly ¶
func (d *Dependency) GetHourly(ctx context.Context) ([]byte, error)
GetHourly returns hourly message count, specified in a daily kind of object. The data is fetched from the memory cache or the database, if the memory cache data is empty or non-existent.
func (*Dependency) GetTotal ¶
func (d *Dependency) GetTotal(ctx context.Context) ([]byte, error)
GetTotal returns the total amount of chat as the data have it. The data is fetched from the memory cache or the database, if the memory cache data is empty or non-existent.
func (*Dependency) LastUpdated ¶
func (d *Dependency) LastUpdated(r Endpoint) (time.Time, error)
LastUpdated returns the last updated value as a time.Time object for cached data.
type Endpoint ¶
type Endpoint int
Endpoint specifies a type to be used as enum.
const ( // UserEndpoint indicates the endpoint for getting users data UserEndpoint Endpoint = iota // HourlyEndpoint indicates the endpoint for getting the data per hour HourlyEndpoint // TotalEndpoint indicates the endpoint for getting the total amount // of messages that was sent per the database's data. TotalEndpoint // DukunEndpoint indicates the endpoint for getting the whole // dukun points as used by the Javascript bot. DukunEndpoint )
type User ¶
type User = analytics.GroupMember
User is a type alias for analytics.GroupMember and should be similar for the behavior and other stuffs.