Documentation ¶
Index ¶
- Variables
- func ApplyForMembershipHandler(app *App) func(c *iris.Context)
- func ApproveOrDenyMembershipApplicationHandler(app *App) func(c *iris.Context)
- func ApproveOrDenyMembershipInvitationHandler(app *App) func(c *iris.Context)
- func CreateClanHandler(app *App) func(c *iris.Context)
- func CreateGameHandler(app *App) func(c *iris.Context)
- func CreateHookHandler(app *App) func(c *iris.Context)
- func CreatePlayerHandler(app *App) func(c *iris.Context)
- func DeleteMembershipHandler(app *App) func(c *iris.Context)
- func FailWith(status int, message string, c *iris.Context)
- func HealthCheckHandler(app *App) func(c *iris.Context)
- func InviteForMembershipHandler(app *App) func(c *iris.Context)
- func LeaveClanHandler(app *App) func(c *iris.Context)
- func ListClansHandler(app *App) func(c *iris.Context)
- func LoadJSONPayload(payloadStruct interface{}, c *iris.Context, l zap.Logger) error
- func NewHTTPFromCtx(ctx *iris.Context) *raven.Http
- func NewLoggerMiddleware(theLogger zap.Logger) iris.HandlerFunc
- func PromoteOrDemoteMembershipHandler(app *App, action string) func(c *iris.Context)
- func RemoveHookHandler(app *App) func(c *iris.Context)
- func RetrieveClanHandler(app *App) func(c *iris.Context)
- func RetrieveClanSummaryHandler(app *App) func(c *iris.Context)
- func RetrieveClansSummariesHandler(app *App) func(c *iris.Context)
- func RetrievePlayerHandler(app *App) func(c *iris.Context)
- func SearchClansHandler(app *App) func(c *iris.Context)
- func StatusHandler(app *App) func(c *iris.Context)
- func SucceedWith(payload map[string]interface{}, c *iris.Context)
- func TransferOwnershipHandler(app *App) func(c *iris.Context)
- func UpdateClanHandler(app *App) func(c *iris.Context)
- func UpdateGameHandler(app *App) func(c *iris.Context)
- func UpdatePlayerHandler(app *App) func(c *iris.Context)
- type App
- func (app *App) BeginTrans(l zap.Logger) (*gorp.Transaction, error)
- func (app *App) Commit(tx *gorp.Transaction, msg string, l zap.Logger) error
- func (app *App) Configure()
- func (app *App) DispatchHooks(gameID string, eventType int, payload map[string]interface{}) error
- func (app *App) GetCtxDB(ctx *iris.Context) (models.DB, error)
- func (app *App) GetGame(gameID string) (*models.Game, error)
- func (app *App) GetHooks() map[string]map[int][]*models.Hook
- func (app *App) Rollback(tx *gorp.Transaction, msg string, l zap.Logger, err error) error
- func (app *App) Start()
- type Dispatch
- type Dispatcher
- type LoggerMiddleware
- type RecoveryMiddleware
- type SentryMiddleware
- type TransactionMiddleware
- type VersionMiddleware
- type Worker
Constants ¶
This section is empty.
Variables ¶
var VERSION = "0.9.10"
VERSION identifies Khan's current version
Functions ¶
func ApplyForMembershipHandler ¶
ApplyForMembershipHandler is the handler responsible for applying for new memberships
func ApproveOrDenyMembershipApplicationHandler ¶
ApproveOrDenyMembershipApplicationHandler is the handler responsible for approving or denying a membership invitation
func ApproveOrDenyMembershipInvitationHandler ¶
ApproveOrDenyMembershipInvitationHandler is the handler responsible for approving or denying a membership invitation
func CreateClanHandler ¶
CreateClanHandler is the handler responsible for creating new clans
func CreateGameHandler ¶
CreateGameHandler is the handler responsible for creating new games
func CreateHookHandler ¶
CreateHookHandler is the handler responsible for creating new hooks
func CreatePlayerHandler ¶
CreatePlayerHandler is the handler responsible for creating new players
func DeleteMembershipHandler ¶
DeleteMembershipHandler is the handler responsible for deleting a member
func HealthCheckHandler ¶
HealthCheckHandler is the handler responsible for validating that the app is still up
func InviteForMembershipHandler ¶
InviteForMembershipHandler is the handler responsible for creating new memberships
func LeaveClanHandler ¶
LeaveClanHandler is the handler responsible for changing the clan ownership when the owner leaves it
func ListClansHandler ¶
ListClansHandler is the handler responsible for returning a list of all clans
func LoadJSONPayload ¶
LoadJSONPayload loads the JSON payload to the given struct validating all fields are not null
func NewHTTPFromCtx ¶
NewHTTPFromCtx returns a new context for Raven
func NewLoggerMiddleware ¶
func NewLoggerMiddleware(theLogger zap.Logger) iris.HandlerFunc
NewLoggerMiddleware returns the logger middleware
func PromoteOrDemoteMembershipHandler ¶
PromoteOrDemoteMembershipHandler is the handler responsible for promoting or demoting a member
func RemoveHookHandler ¶
RemoveHookHandler is the handler responsible for removing existing hooks
func RetrieveClanHandler ¶
RetrieveClanHandler is the handler responsible for returning details for a given clan
func RetrieveClanSummaryHandler ¶
RetrieveClanSummaryHandler is the handler responsible for returning details summary for a given clan
func RetrieveClansSummariesHandler ¶
RetrieveClansSummariesHandler is the handler responsible for returning details summary for a given list of clans
func RetrievePlayerHandler ¶
RetrievePlayerHandler is the handler responsible for returning details for a given player
func SearchClansHandler ¶
SearchClansHandler is the handler responsible for searching for clans
func StatusHandler ¶
StatusHandler is the handler responsible for reporting khan status
func SucceedWith ¶
SucceedWith sends payload to user with status 200
func TransferOwnershipHandler ¶
TransferOwnershipHandler is the handler responsible for transferring the clan ownership to another clan member
func UpdateClanHandler ¶
UpdateClanHandler is the handler responsible for updating existing clans
func UpdateGameHandler ¶
UpdateGameHandler is the handler responsible for updating existing
func UpdatePlayerHandler ¶
UpdatePlayerHandler is the handler responsible for updating existing
Types ¶
type App ¶
type App struct { Debug bool Port int Host string ConfigPath string Errors metrics.EWMA App *iris.Framework Db models.DB Config *viper.Viper Dispatcher *Dispatcher Logger zap.Logger ReadBufferSize int }
App is a struct that represents a Khan API Application
func (*App) BeginTrans ¶
BeginTrans in the current Db connection
func (*App) Configure ¶
func (app *App) Configure()
Configure instantiates the required dependencies for Khan Api Application
func (*App) DispatchHooks ¶
DispatchHooks dispatches web hooks for a specific game and event type
func (*App) GetCtxDB ¶
GetCtxDB returns the proper database connection depending on the request context
type Dispatch ¶
type Dispatch struct {
// contains filtered or unexported fields
}
Dispatch represents an event hook to be sent to all available dispatchers
type Dispatcher ¶
type Dispatcher struct { Jobs int // contains filtered or unexported fields }
Dispatcher is responsible for sending web hooks to workers
func NewDispatcher ¶
func NewDispatcher(app *App, workerCount, bufferSize int) (*Dispatcher, error)
NewDispatcher creates a new dispatcher available to our app
func (*Dispatcher) DispatchHook ¶
func (d *Dispatcher) DispatchHook(gameID string, eventType int, payload map[string]interface{})
DispatchHook dispatches an event hook for eventType to gameID with the specified payload
func (*Dispatcher) Wait ¶
func (d *Dispatcher) Wait(timeout ...int)
Wait blocks until all jobs are done
type LoggerMiddleware ¶
LoggerMiddleware is responsible for logging to Zap all requests
func (*LoggerMiddleware) Serve ¶
func (l *LoggerMiddleware) Serve(ctx *iris.Context)
Serve serves the middleware
type RecoveryMiddleware ¶
RecoveryMiddleware recovers from errors in Iris
func (RecoveryMiddleware) Serve ¶
func (r RecoveryMiddleware) Serve(ctx *iris.Context)
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 (*SentryMiddleware) Serve ¶
func (l *SentryMiddleware) Serve(ctx *iris.Context)
Serve serves the middleware
type TransactionMiddleware ¶
type TransactionMiddleware struct {
App *App
}
TransactionMiddleware wraps transactions around the request
func (*TransactionMiddleware) Serve ¶
func (m *TransactionMiddleware) Serve(c *iris.Context)
Serve Automatically wrap transaction around the request
type VersionMiddleware ¶
type VersionMiddleware struct {
App *App
}
VersionMiddleware automatically adds a version header to response
func (*VersionMiddleware) Serve ¶
func (m *VersionMiddleware) Serve(c *iris.Context)
Serve automatically adds a version header to response
type Worker ¶
type Worker struct { ID int App *App Dispatcher *Dispatcher Work chan Dispatch WorkerQueue chan chan Dispatch }
Worker is an unit of work that keeps processing dispatches
func (*Worker) DispatchHook ¶
DispatchHook dispatches web hooks for a specific game and event type