Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FizzBuzzStatsRedis ¶
type FizzBuzzStatsRedis struct {
// contains filtered or unexported fields
}
FizzBuzzStatsRedis is a statistic component based on redis DB
func NewFizzBuzzStatsRedis ¶
func NewFizzBuzzStatsRedis() (*FizzBuzzStatsRedis, error)
NewFizzBuzzStatsRedis instances a new FizzBuzzStatsRedis, which will automatically handles reconnection to the redis DB. the address can be set using environment variable REDIS_DB_ADDRESS as well as user login via variables REDIS_DB_USERNAME, REDIS_DB_PASSWORD. The db instance to use is not provide by default and can be changed via REDIS_DB_ID. If the connection needs a TLS protection, than variable REDIS_DB_TLS needs to be set to true. When using TLS the configuration can be tweaked using REDIS_DB_TLS_INSECURE, REDIS_DB_TLS_CERTIFICATE_PATH, REDIS_DB_TLS_KEY_PATH which will allow for an insecure connection and specific client certificate+key. Standard variable SSL_CERT_FILE and SSL_CERT_DIR can be used to change the default loading of system CAs.
func (*FizzBuzzStatsRedis) Increment ¶
func (fs *FizzBuzzStatsRedis) Increment(ctx context.Context, n, m, top int, fizz, buzz string) error
Increment uses redis ZINCRBY to increment the request count of the provided set of input parameters. The set identifier is built by concatenation of each parameter using the model.Separator
func (*FizzBuzzStatsRedis) Stats ¶
func (fs *FizzBuzzStatsRedis) Stats(ctx context.Context) (model.FizzBuzzStatisticsOutput, error)
Stats will return the most request set using ZREVRANGEBYSCORE of redis.Will return NoStatsAvailable error if no statistic of previous requests is available
type NoStatsAvailable ¶
type NoStatsAvailable struct{}
NoStatsAvailable indicates that no previous request is available
func (NoStatsAvailable) Error ¶
func (n NoStatsAvailable) Error() string
Error is the error interface implementation