api

package
v7.4.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: MIT Imports: 33 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VERSION = "7.4.1"

VERSION identifies podium's current version

Functions

func BulkUpsertMembersScoreHandler

func BulkUpsertMembersScoreHandler(app *App) func(c echo.Context) error

BulkUpsertMembersScoreHandler is the handler responsible for creating or updating members score

func FailWith

func FailWith(status int, message string, c echo.Context) error

FailWith fails with the specified message

func FailWithError

func FailWithError(e error, c echo.Context) error

FailWithError fails with the specified error

func GetAroundMemberHandler

func GetAroundMemberHandler(app *App) func(c echo.Context) error

GetAroundMemberHandler retrieves a list of member score and rank centered in the given member

func GetAroundScoreHandler

func GetAroundScoreHandler(app *App) func(c echo.Context) error

GetAroundScoreHandler retrieves a list of member score and rank centered in a given

func GetIntParam

func GetIntParam(app *App, c echo.Context, paramName string, defaultValue int) (int, error)

GetIntParam gets a query parameter as integer

func GetIntRouteParam

func GetIntRouteParam(app *App, c echo.Context, paramName string, defaultValue int) (int, error)

GetIntRouteParam gets a query parameter as integer

func GetMemberHandler

func GetMemberHandler(app *App) func(c echo.Context) error

GetMemberHandler is the handler responsible for retrieving a member score and rank

func GetMemberRankHandler

func GetMemberRankHandler(app *App) func(c echo.Context) error

GetMemberRankHandler is the handler responsible for retrieving a member rank

func GetMemberRankInManyLeaderboardsHandler

func GetMemberRankInManyLeaderboardsHandler(app *App) func(c echo.Context) error

GetMemberRankInManyLeaderboardsHandler returns the member rank in several leaderboards at once

func GetMembersHandler

func GetMembersHandler(app *App) func(c echo.Context) error

GetMembersHandler retrieves several members at once

func GetPageSize

func GetPageSize(app *App, c echo.Context, defaultPageSize int) (int, error)

GetPageSize gets the page size from the querystring

func GetRequestBody

func GetRequestBody(c echo.Context) ([]byte, error)

GetRequestBody from echo context

func GetRequestJSON

func GetRequestJSON(payloadStruct interface{}, c echo.Context) error

GetRequestJSON as the specified interface from echo context

func GetTX

GetTX returns new relic transaction

func GetTopMembersHandler

func GetTopMembersHandler(app *App) func(c echo.Context) error

GetTopMembersHandler retrieves onePage of member score and rank

func GetTopPercentageHandler

func GetTopPercentageHandler(app *App) func(c echo.Context) error

GetTopPercentageHandler retrieves top x % members in the leaderboard

func GetTotalMembersHandler

func GetTotalMembersHandler(app *App) func(c echo.Context) error

GetTotalMembersHandler is the handler responsible for returning the total number of members in a leaderboard

func HealthCheckHandler

func HealthCheckHandler(app *App) func(c echo.Context) error

HealthCheckHandler is the handler responsible for validating that the app is still up

func IncrementMemberScoreHandler

func IncrementMemberScoreHandler(app *App) func(c echo.Context) error

IncrementMemberScoreHandler is the handler responsible for incrementing the member score

func LoadJSONPayload

func LoadJSONPayload(payloadStruct interface{}, c echo.Context, l zap.Logger) error

LoadJSONPayload loads the JSON payload to the given struct validating all fields are not null

func RemoveLeaderboardHandler

func RemoveLeaderboardHandler(app *App) func(c echo.Context) error

RemoveLeaderboardHandler is the handler responsible for removing a leaderboard

func RemoveMemberHandler

func RemoveMemberHandler(app *App) func(c echo.Context) error

RemoveMemberHandler removes a member from a leaderboard

func RemoveMembersHandler

func RemoveMembersHandler(app *App) func(c echo.Context) error

RemoveMembersHandler removes several members from a leaderboard

func StatusHandler

func StatusHandler(app *App) func(c echo.Context) error

StatusHandler is the handler responsible for reporting podium status

func SucceedWith

func SucceedWith(payload map[string]interface{}, c echo.Context) error

SucceedWith sends payload to member with status 200

func UpsertMemberLeaderboardsScoreHandler

func UpsertMemberLeaderboardsScoreHandler(app *App) func(c echo.Context) error

UpsertMemberLeaderboardsScoreHandler sets the member score for all leaderboards

func UpsertMemberScoreHandler

func UpsertMemberScoreHandler(app *App) func(c echo.Context) error

UpsertMemberScoreHandler is the handler responsible for creating or updating the member score

func ValidatePayload

func ValidatePayload(payload Validatable) []string

ValidatePayload for any validatable payload

func WithSegment

func WithSegment(name string, c echo.Context, f func() error) error

WithSegment adds a segment to new relic transaction

Types

type App

type App struct {
	Debug       bool
	Fast        bool
	Port        int
	Host        string
	ConfigPath  string
	Errors      metrics.EWMA
	App         *echo.Echo
	Engine      engine.Server
	Config      *viper.Viper
	Logger      zap.Logger
	RedisClient *redis.Client
	NewRelic    newrelic.Application
	DDStatsD    *extnethttpmiddleware.DogStatsD
}

App is a struct that represents a podium Application

func GetApp

func GetApp(host string, port int, configPath string, debug, fast bool, logger zap.Logger) (*App, error)

GetApp returns a new podium Application

func (*App) AddError

func (app *App) AddError()

AddError rate statistics

func (*App) Configure

func (app *App) Configure() error

Configure instantiates the required dependencies for podium Application

func (*App) OnErrorHandler

func (app *App) OnErrorHandler(err error, stack []byte)

OnErrorHandler handles panics

func (*App) Start

func (app *App) Start() error

Start starts listening for web requests at specified host and port

type EasyJSONMarshaler

type EasyJSONMarshaler interface {
	MarshalEasyJSON(w *jwriter.Writer)
}

EasyJSONMarshaler describes a struct able to marshal json

type EasyJSONUnmarshaler

type EasyJSONUnmarshaler interface {
	UnmarshalEasyJSON(l *jlexer.Lexer)
}

EasyJSONUnmarshaler describes a struct able to unmarshal json

type JSON

type JSON map[string]interface{}

JSON type

type LoggerMiddleware

type LoggerMiddleware struct {
	Logger zap.Logger
}

LoggerMiddleware is responsible for logging to Zap all requests

func NewLoggerMiddleware

func NewLoggerMiddleware(theLogger zap.Logger) *LoggerMiddleware

NewLoggerMiddleware returns the logger middleware

func (*LoggerMiddleware) Serve

Serve serves the middleware

type NewRelicMiddleware

type NewRelicMiddleware struct {
	App    *App
	Logger zap.Logger
}

NewRelicMiddleware is responsible for logging to Zap all requests

func NewNewRelicMiddleware

func NewNewRelicMiddleware(app *App, theLogger zap.Logger) *NewRelicMiddleware

NewNewRelicMiddleware returns the logger middleware

func (*NewRelicMiddleware) Serve

Serve serves the middleware

type RecoveryMiddleware

type RecoveryMiddleware struct {
	OnError func(error, []byte)
}

RecoveryMiddleware recovers from errors

func NewRecoveryMiddleware

func NewRecoveryMiddleware(onError func(error, []byte)) *RecoveryMiddleware

NewRecoveryMiddleware returns a configured middleware

func (*RecoveryMiddleware) Serve

Serve executes on error handler when errors happen

type SentryMiddleware

type SentryMiddleware struct {
	App *App
}

SentryMiddleware is responsible for sending all exceptions to sentry

func NewSentryMiddleware

func NewSentryMiddleware(app *App) *SentryMiddleware

NewSentryMiddleware returns a new sentry middleware

func (*SentryMiddleware) Serve

Serve serves the middleware

type Validatable

type Validatable interface {
	Validate() []string
}

Validatable indicates that a struct can be validated

type Validation

type Validation struct {
	// contains filtered or unexported fields
}

Validation struct

func NewValidation

func NewValidation() *Validation

NewValidation for validating structs

func (*Validation) Errors

func (v *Validation) Errors() []string

Errors in validation

func (Validation) MarshalEasyJSON

func (v Validation) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (*Validation) UnmarshalEasyJSON

func (v *Validation) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

type VersionMiddleware

type VersionMiddleware struct {
	Version string
}

VersionMiddleware inserts the current version in all requests

func NewVersionMiddleware

func NewVersionMiddleware() *VersionMiddleware

NewVersionMiddleware with API version

func (*VersionMiddleware) Serve

Serve serves the middleware

Jump to

Keyboard shortcuts

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