Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePlayerFactory(db DB, gameID string, skipCreateGame ...bool) (*Game, *Player, error)
- func GetClanAndOwnerByPublicID(db DB, gameID, publicID string) (*Clan, *Player, error)
- func GetClanDetails(db DB, gameID string, clan *Clan, maxClansPerPlayer int, ...) (map[string]interface{}, error)
- func GetClanMembers(db DB, gameID, publicID string) (map[string]interface{}, error)
- func GetClanReachedMaxMemberships(db DB) (*Game, *Clan, *Player, []*Player, []*Membership, error)
- func GetClanSummary(db DB, gameID, publicID string) (map[string]interface{}, error)
- func GetClanWithMemberships(db DB, ...) (*Game, *Clan, *Player, []*Player, []*Membership, error)
- func GetClansSummaries(db DB, gameID string, publicIDs []string) ([]map[string]interface{}, error)
- func GetDB(host string, user string, port int, sslmode string, dbName string, ...) (interfaces.Database, error)
- func GetDefaultDB() (interfaces.Database, error)
- func GetLevelByLevelInt(levelInt int, levels map[string]interface{}) string
- func GetLevelIntByLevel(level string, levels map[string]interface{}) int
- func GetNumberOfPendingInvites(db DB, player *Player) (int, error)
- func GetPerfDB() (interfaces.Database, error)
- func GetPlayerDetails(db DB, gameID, publicID string) (map[string]interface{}, error)
- func GetPlayerMembershipDetails(db DB, gameID, publicID string) (map[string]interface{}, error)
- func GetPlayerOwnershipDetails(db DB, gameID, publicID string) (map[string]interface{}, error)
- func GetTestClanWithStaleData(db DB, staleApplications, staleInvites, staleDenies, staleDeletes int) (string, error)
- func GetTestClans(db DB, gameID string, publicIDTemplate string, numberOfClans int) (*Player, []*Clan, error)
- func InitDb(host string, user string, port int, sslmode string, dbName string, ...) (interfaces.Database, error)
- func IsValidOrder(order string) bool
- func LeaveClan(db DB, gameID, publicID string) (*Clan, *Player, *Player, error)
- func RemoveHook(db DB, gameID string, publicID string) error
- func TransferClanOwnership(db DB, gameID, clanPublicID, playerPublicID string, ...) (*Clan, *Player, *Player, error)
- func UpdateClanMembershipCount(db DB, id int64) error
- func UpdatePlayerMembershipCount(db DB, id int64) error
- func UpdatePlayerOwnershipCount(db DB, id int64) error
- type AlreadyHasValidMembershipError
- type CannotApproveOrDenyMembershipAlreadyProcessedError
- type CannotPromoteOrDemoteInvalidMemberError
- type CannotPromoteOrDemoteMemberLevelError
- type Clan
- func CreateClan(db DB, gameID, publicID, name, ownerPublicID string, ...) (*Clan, error)
- func GetAllClans(db DB, gameID string) ([]Clan, error)
- func GetClanByID(db DB, id int64) (*Clan, error)
- func GetClanByPublicID(db DB, gameID, publicID string) (*Clan, error)
- func GetClanByPublicIDAndOwnerPublicID(db DB, gameID, publicID, ownerPublicID string) (*Clan, error)
- func GetClanByShortPublicID(db DB, gameID, publicID string) (*Clan, error)
- func GetClanFromJSON(data []byte) (*Clan, error)
- func GetClansByPublicIDs(db DB, gameID string, publicIDs []string) ([]Clan, error)
- func GetTestClanWithName(db DB, gameID, name string, ownerID int64) (*Clan, error)
- func GetTestClanWithRandomPublicIDAndName(db DB, gameID string, ownerID int64) (*Clan, error)
- func SearchClan(db DB, mongo interfaces.MongoDB, gameID, term string, pageSize int64) ([]Clan, error)
- func UpdateClan(db DB, gameID, publicID, name, ownerPublicID string, ...) (*Clan, error)
- func (c *Clan) DeleteClanFromElasticSearch() error
- func (c *Clan) DeleteClanFromMongoDB() error
- func (c *Clan) IndexClanIntoElasticSearch() error
- func (v Clan) MarshalEasyJSON(w *jwriter.Writer)
- func (c *Clan) NewClanWithNamePrefixes() *ClanWithNamePrefixes
- func (c *Clan) PostDelete(s gorp.SqlExecutor) error
- func (c *Clan) PostInsert(s gorp.SqlExecutor) error
- func (c *Clan) PostUpdate(s gorp.SqlExecutor) error
- func (c *Clan) PreInsert(s gorp.SqlExecutor) error
- func (c *Clan) PreUpdate(s gorp.SqlExecutor) error
- func (c *Clan) Serialize() map[string]interface{}
- func (c *Clan) ToJSON() ([]byte, error)
- func (v *Clan) UnmarshalEasyJSON(l *jlexer.Lexer)
- func (c *Clan) UpdateClanIntoElasticSearch() error
- func (c *Clan) UpdateClanIntoMongoDB() error
- type ClanByName
- type ClanHasNoMembersError
- type ClanReachedMaxMembersError
- type ClanWithNamePrefixes
- type CouldNotFindAllClansError
- type DB
- type ESWorker
- type EmptyGameIDError
- type EmptySearchTermError
- type ForbiddenError
- type Game
- func CreateGame(db DB, publicID, name string, levels, metadata map[string]interface{}, ...) (*Game, error)
- func GetAllGames(db DB) ([]*Game, error)
- func GetGameByID(db DB, id int) (*Game, error)
- func GetGameByPublicID(db DB, publicID string) (*Game, error)
- func UpdateGame(db DB, publicID, name string, levels, metadata map[string]interface{}, ...) (*Game, error)
- type GetClanDetailsOptions
- type Hook
- func CreateHook(db DB, gameID string, eventType int, url string) (*Hook, error)
- func CreateHookFactory(db DB, gameID string, eventType int, url string) (*Hook, error)
- func GetAllHooks(db DB) ([]*Hook, error)
- func GetHookByDetails(db DB, gameID string, eventType int, hookURL string) *Hook
- func GetHookByID(db DB, id int) (*Hook, error)
- func GetHookByPublicID(db DB, gameID string, publicID string) (*Hook, error)
- func GetHooksForRoutes(db DB, routes []string, eventType int) ([]*Hook, error)
- func GetTestHooks(db DB, gameID string, numberOfHooks int) ([]*Hook, error)
- type InvalidCastToGorpSQLExecutorError
- type InvalidLevelForGameError
- type InvalidMembershipActionError
- type Membership
- func ApproveOrDenyMembershipApplication(db DB, game *Game, ...) (*Membership, error)
- func ApproveOrDenyMembershipInvitation(db DB, game *Game, gameID, playerPublicID, clanPublicID, action string) (*Membership, error)
- func CreateMembership(db DB, game *Game, ...) (*Membership, error)
- func DeleteMembership(db DB, game *Game, ...) (*Membership, error)
- func GetDeletedMembershipByClanAndPlayerID(db DB, gameID string, clanID, playerID int64) (*Membership, error)
- func GetMembershipByClanAndPlayerPublicID(db DB, gameID, clanPublicID, playerPublicID string) (*Membership, error)
- func GetMembershipByID(db DB, id int64) (*Membership, error)
- func GetOldestMemberWithHighestLevel(db DB, gameID, clanPublicID string) (*Membership, error)
- func GetValidMembershipByClanAndPlayerPublicID(db DB, gameID, clanPublicID, playerPublicID string) (*Membership, error)
- func PromoteOrDemoteMember(db DB, game *Game, ...) (*Membership, error)
- type ModelNotFoundError
- type MongoWorker
- type MustWaitMembershipCooldownError
- type Player
- func CreatePlayer(db DB, gameID, publicID, name string, metadata map[string]interface{}, ...) (*Player, error)
- func GetPlayerByID(db DB, id int64) (*Player, error)
- func GetPlayerByPublicID(db DB, gameID string, publicID string) (*Player, error)
- func GetTestPlayerWithMemberships(db DB, gameID string, ...) (*Player, error)
- func UpdatePlayer(db DB, gameID, publicID, name string, metadata map[string]interface{}) (*Player, error)
- type PlayerCannotCreateMembershipError
- type PlayerCannotPerformMembershipActionError
- type PlayerReachedMaxClansError
- type PlayerReachedMaxInvitesError
- type PruneOptions
- type PruneStats
Constants ¶
const ( //GameUpdatedHook happens when a game is updated GameUpdatedHook = 0 //PlayerCreatedHook happens when a new player is created PlayerCreatedHook = 1 //PlayerUpdatedHook happens when a player is updated PlayerUpdatedHook = 2 //ClanCreatedHook happens when a clan is created ClanCreatedHook = 3 //ClanUpdatedHook happens when a clan is updated ClanUpdatedHook = 4 //ClanLeftHook happens when a clan owner rage quits ClanLeftHook = 5 //ClanOwnershipTransferredHook happens when a clan owner transfers ownership to another player ClanOwnershipTransferredHook = 6 //MembershipApplicationCreatedHook happens when a new application or invite to a clan is created MembershipApplicationCreatedHook = 7 //MembershipApprovedHook happens when a clan membership is approved MembershipApprovedHook = 8 //MembershipDeniedHook happens when a clan membership is denied MembershipDeniedHook = 9 //MembershipPromotedHook happens when a clan member is promoted MembershipPromotedHook = 10 //MembershipDemotedHook happens when a clan member is demoted MembershipDemotedHook = 11 //MembershipLeftHook happens when a player leaves a clan MembershipLeftHook = 12 )
const MaxPendingApplicationsKey string = "getClanDetails.defaultOptions.maxPendingApplications"
MaxPendingApplicationsKey is string constant
const MaxPendingInvitesKey string = "getClanDetails.defaultOptions.maxPendingInvites"
MaxPendingInvitesKey is string constant
const Newest string = "newest"
Newest is the constant "newest"
const Oldest string = "oldest"
Oldest is the constant "oldest"
const PendingApplicationsOrderKey string = "getClanDetails.defaultOptions.pendingApplicationsOrder"
PendingApplicationsOrderKey is string constant
const PendingInvitesOrderKey string = "getClanDetails.defaultOptions.pendingInvitesOrder"
PendingInvitesOrderKey is string constant
Variables ¶
var ClanFactory = configureFactory(factory.NewFactory( &Clan{}, ))
ClanFactory is responsible for constructing test clan instances
var GameFactory = factory.NewFactory( &Game{ MinLevelToAcceptApplication: 2, MinLevelToCreateInvitation: 2, MinLevelToRemoveMember: 2, MinLevelOffsetToRemoveMember: 1, MinLevelOffsetToPromoteMember: 2, MinLevelOffsetToDemoteMember: 1, MaxClansPerPlayer: 1, MaxMembers: 100, CooldownAfterDeny: 0, CooldownAfterDelete: 0, CooldownBeforeApply: 3600, CooldownBeforeInvite: 0, MaxPendingInvites: 20, }, ).Attr("PublicID", func(args factory.Args) (interface{}, error) { return uuid.NewV4().String(), nil }).Attr("Name", func(args factory.Args) (interface{}, error) { return uuid.NewV4().String(), nil }).Attr("Metadata", func(args factory.Args) (interface{}, error) { return map[string]interface{}{}, nil }).Attr("MembershipLevels", func(args factory.Args) (interface{}, error) { return map[string]interface{}{"Member": 1, "Elder": 2, "CoLeader": 3}, nil })
GameFactory is responsible for constructing test game instances
var HookFactory = factory.NewFactory( &Hook{EventType: GameUpdatedHook, URL: "http://test/game-created"}, )
HookFactory is responsible for constructing event hook instances
var MembershipFactory = factory.NewFactory( &Membership{}, ).SeqInt("GameID", func(n int) (interface{}, error) { return fmt.Sprintf("game-%d", n), nil }).Attr("ApproverID", func(args factory.Args) (interface{}, error) { membership := args.Instance().(*Membership) approverID := int64(0) valid := false if membership.Approved { approverID = membership.RequestorID valid = true } return sql.NullInt64{Int64: int64(approverID), Valid: valid}, nil }).Attr("DenierID", func(args factory.Args) (interface{}, error) { membership := args.Instance().(*Membership) denierID := int64(0) valid := false if membership.Denied { denierID = membership.RequestorID valid = true } return sql.NullInt64{Int64: denierID, Valid: valid}, nil })
MembershipFactory is responsible for constructing test membership instances
var PlayerFactory = configureFactory(factory.NewFactory( &Player{}, ))
PlayerFactory is responsible for constructing test player instances
Functions ¶
func CreatePlayerFactory ¶
CreatePlayerFactory is responsible for creating a test player instance with the associated game
func GetClanAndOwnerByPublicID ¶
GetClanAndOwnerByPublicID returns the clan as well as the owner of a clan by clan's public id
func GetClanDetails ¶
func GetClanDetails(db DB, gameID string, clan *Clan, maxClansPerPlayer int, options *GetClanDetailsOptions) (map[string]interface{}, error)
GetClanDetails returns all details for a given clan by its game id and public id
func GetClanMembers ¶
GetClanMembers gets only the ids of then clan members
func GetClanReachedMaxMemberships ¶
GetClanReachedMaxMemberships returns a clan with one approved membership, one unapproved membership and game MaxMembers=1
func GetClanSummary ¶
GetClanSummary returns a summary of the clan details for a given clan by its game id and public id
func GetClanWithMemberships ¶
func GetClanWithMemberships( db DB, approvedMemberships, deniedMemberships, bannedMemberships, pendingMemberships int, gameID string, clanPublicID string, options ...bool) (*Game, *Clan, *Player, []*Player, []*Membership, error)
GetClanWithMemberships returns a clan filled with the number of memberships specified
func GetClansSummaries ¶
GetClansSummaries returns a summary of the clans details for a given list of clans by their game id and public ids
func GetDB ¶
func GetDB(host string, user string, port int, sslmode string, dbName string, password string) (interfaces.Database, error)
GetDB returns a DbMap connection to the database specified in the arguments
func GetDefaultDB ¶
func GetDefaultDB() (interfaces.Database, error)
GetDefaultDB returns a connection to the default database
func GetLevelByLevelInt ¶
GetLevelByLevelInt returns the level string given the level int
func GetLevelIntByLevel ¶
GetLevelIntByLevel returns the level string given the level int
func GetNumberOfPendingInvites ¶
GetNumberOfPendingInvites gets total number of pending invites for player
func GetPerfDB ¶
func GetPerfDB() (interfaces.Database, error)
GetPerfDB returns a connection to the perf database
func GetPlayerDetails ¶
GetPlayerDetails returns detailed information about a player and their memberships
func GetPlayerMembershipDetails ¶
GetPlayerMembershipDetails returns detailed information about a player and their memberships
func GetPlayerOwnershipDetails ¶
GetPlayerOwnershipDetails returns detailed information about a player owned clans
func GetTestClanWithStaleData ¶ added in v0.12.0
func GetTestClanWithStaleData(db DB, staleApplications, staleInvites, staleDenies, staleDeletes int) (string, error)
GetTestClanWithStaleData returns a player with approved, rejected and banned memberships
func GetTestClans ¶
func GetTestClans(db DB, gameID string, publicIDTemplate string, numberOfClans int) (*Player, []*Clan, error)
GetTestClans returns a list of clans for tests
func InitDb ¶
func InitDb(host string, user string, port int, sslmode string, dbName string, password string) (interfaces.Database, error)
InitDb initializes a connection to the database
func IsValidOrder ¶
IsValidOrder returns whether the input is equal to Newest or Oldest
func LeaveClan ¶
LeaveClan allows the clan owner to leave the clan and transfer the clan ownership to the next player in line
func RemoveHook ¶
RemoveHook removes a hook by public ID
func TransferClanOwnership ¶
func TransferClanOwnership(db DB, gameID, clanPublicID, playerPublicID string, levels map[string]interface{}, maxLevel int) (*Clan, *Player, *Player, error)
TransferClanOwnership allows the clan owner to transfer the clan ownership to a clan member
func UpdateClanMembershipCount ¶ added in v0.10.0
UpdateClanMembershipCount updates the clan membership count
func UpdatePlayerMembershipCount ¶ added in v0.10.0
UpdatePlayerMembershipCount updates the player membership count
func UpdatePlayerOwnershipCount ¶ added in v0.10.0
UpdatePlayerOwnershipCount updates the player ownership count
Types ¶
type AlreadyHasValidMembershipError ¶
AlreadyHasValidMembershipError identifies that a player already has a valid membership for the given clan
func (*AlreadyHasValidMembershipError) Error ¶
func (e *AlreadyHasValidMembershipError) Error() string
type CannotApproveOrDenyMembershipAlreadyProcessedError ¶
type CannotApproveOrDenyMembershipAlreadyProcessedError struct {
Action string
}
CannotApproveOrDenyMembershipAlreadyProcessedError identifies that a membership that is already processed cannot be approved or denied
func (*CannotApproveOrDenyMembershipAlreadyProcessedError) Error ¶
func (e *CannotApproveOrDenyMembershipAlreadyProcessedError) Error() string
type CannotPromoteOrDemoteInvalidMemberError ¶
type CannotPromoteOrDemoteInvalidMemberError struct {
Action string
}
CannotPromoteOrDemoteInvalidMemberError identifies that a given player is not allowed to promote/demote a member
func (*CannotPromoteOrDemoteInvalidMemberError) Error ¶
func (e *CannotPromoteOrDemoteInvalidMemberError) Error() string
type CannotPromoteOrDemoteMemberLevelError ¶
CannotPromoteOrDemoteMemberLevelError identifies that a given member is already max level and cannot be promoted
func (*CannotPromoteOrDemoteMemberLevelError) Error ¶
func (e *CannotPromoteOrDemoteMemberLevelError) Error() string
type Clan ¶
type Clan struct { ID int64 `db:"id" json:"id" bson:"id"` GameID string `db:"game_id" json:"gameId" bson:"gameId"` PublicID string `db:"public_id" json:"publicId" bson:"publicId"` Name string `db:"name" json:"name" bson:"name"` OwnerID int64 `db:"owner_id" json:"ownerId" bson:"ownerId"` MembershipCount int `db:"membership_count" json:"membershipCount" bson:"membershipCount"` Metadata map[string]interface{} `db:"metadata" json:"metadata" bson:"metadata"` AllowApplication bool `db:"allow_application" json:"allowApplication" bson:"allowApplication"` AutoJoin bool `db:"auto_join" json:"autoJoin" bson:"autoJoin"` CreatedAt int64 `db:"created_at" json:"createdAt" bson:"createdAt"` UpdatedAt int64 `db:"updated_at" json:"updatedAt" bson:"updatedAt"` DeletedAt int64 `db:"deleted_at" json:"deletedAt" bson:"deletedAt"` }
Clan identifies uniquely one clan in a given game
func CreateClan ¶
func CreateClan(db DB, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool, maxClansPerPlayer int) (*Clan, error)
CreateClan creates a new clan
func GetAllClans ¶
GetAllClans returns a list of all clans in a given game
func GetClanByID ¶
GetClanByID returns a clan by id
func GetClanByPublicID ¶
GetClanByPublicID returns a clan by its public id
func GetClanByPublicIDAndOwnerPublicID ¶
func GetClanByPublicIDAndOwnerPublicID(db DB, gameID, publicID, ownerPublicID string) (*Clan, error)
GetClanByPublicIDAndOwnerPublicID returns a clan by its public id and the owner public id
func GetClanByShortPublicID ¶
GetClanByShortPublicID returns a clan by the beginning of its public id
func GetClanFromJSON ¶ added in v0.9.15
GetClanFromJSON unmarshals the clan from the specified JSON
func GetClansByPublicIDs ¶
GetClansByPublicIDs returns clans by their public ids
func GetTestClanWithName ¶
GetTestClanWithName returns a clan with name for tests
func GetTestClanWithRandomPublicIDAndName ¶
GetTestClanWithRandomPublicIDAndName returns a clan with random UUID v4 publicID and name for tests
func SearchClan ¶
func SearchClan( db DB, mongo interfaces.MongoDB, gameID, term string, pageSize int64, ) ([]Clan, error)
SearchClan returns a list of clans for a given term (by name or publicID)
func UpdateClan ¶
func UpdateClan(db DB, gameID, publicID, name, ownerPublicID string, metadata map[string]interface{}, allowApplication, autoJoin bool) (*Clan, error)
UpdateClan updates an existing clan
func (*Clan) DeleteClanFromElasticSearch ¶ added in v0.9.13
DeleteClanFromElasticSearch after deletion in PG
func (*Clan) DeleteClanFromMongoDB ¶
DeleteClanFromMongoDB after deletion in PG
func (*Clan) IndexClanIntoElasticSearch ¶ added in v0.9.13
IndexClanIntoElasticSearch after operation in PG
func (Clan) MarshalEasyJSON ¶ added in v0.9.15
MarshalEasyJSON supports easyjson.Marshaler interface
func (*Clan) NewClanWithNamePrefixes ¶
func (c *Clan) NewClanWithNamePrefixes() *ClanWithNamePrefixes
NewClanWithNamePrefixes returns a new extended Clan object with name prefixes
func (*Clan) PostDelete ¶ added in v0.9.13
func (c *Clan) PostDelete(s gorp.SqlExecutor) error
PostDelete deletes clan from elasticsearch after deleting from PG
func (*Clan) PostInsert ¶ added in v0.9.13
func (c *Clan) PostInsert(s gorp.SqlExecutor) error
PostInsert indexes clan in ES after creation in PG
func (*Clan) PostUpdate ¶ added in v0.9.13
func (c *Clan) PostUpdate(s gorp.SqlExecutor) error
PostUpdate indexes clan in ES after update in PG
func (*Clan) PreInsert ¶
func (c *Clan) PreInsert(s gorp.SqlExecutor) error
PreInsert populates fields before inserting a new clan
func (*Clan) PreUpdate ¶
func (c *Clan) PreUpdate(s gorp.SqlExecutor) error
PreUpdate populates fields before updating a clan
func (*Clan) UnmarshalEasyJSON ¶ added in v0.9.15
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Clan) UpdateClanIntoElasticSearch ¶
UpdateClanIntoElasticSearch after operation in PG
func (*Clan) UpdateClanIntoMongoDB ¶
UpdateClanIntoMongoDB after operation in PG
type ClanByName ¶
type ClanByName []*Clan
ClanByName allows sorting clans by name
func (ClanByName) Len ¶
func (a ClanByName) Len() int
func (ClanByName) Less ¶
func (a ClanByName) Less(i, j int) bool
func (ClanByName) Swap ¶
func (a ClanByName) Swap(i, j int)
type ClanHasNoMembersError ¶
type ClanHasNoMembersError struct {
ClanID interface{}
}
ClanHasNoMembersError identifies that a clan has no members
func (*ClanHasNoMembersError) Error ¶
func (e *ClanHasNoMembersError) Error() string
type ClanReachedMaxMembersError ¶
type ClanReachedMaxMembersError struct {
ID interface{}
}
ClanReachedMaxMembersError identifies that a given clan already reached the max number of members allowed
func (*ClanReachedMaxMembersError) Error ¶
func (e *ClanReachedMaxMembersError) Error() string
type ClanWithNamePrefixes ¶
ClanWithNamePrefixes extends Clan with a field to help name indexation in MongoDB
type CouldNotFindAllClansError ¶
type CouldNotFindAllClansError struct { ClanIDs []string // contains filtered or unexported fields }
CouldNotFindAllClansError identifies that one or more of the requested clans do not exist
func (*CouldNotFindAllClansError) Error ¶
func (e *CouldNotFindAllClansError) Error() string
type DB ¶
type DB interface { Get(interface{}, ...interface{}) (interface{}, error) Select(interface{}, string, ...interface{}) ([]interface{}, error) SelectOne(interface{}, string, ...interface{}) error SelectInt(string, ...interface{}) (int64, error) Insert(...interface{}) error Update(...interface{}) (int64, error) Delete(...interface{}) (int64, error) Exec(string, ...interface{}) (sql.Result, error) }
DB is the contract for all the operations we use from either a connection or transaction This is required for automatic transactions
type ESWorker ¶
ESWorker is the worker that will update elasticsearch
func NewESWorker ¶
NewESWorker creates and returns a new elasticsearch worker
func (*ESWorker) PerformUpdateES ¶
func (w *ESWorker) PerformUpdateES(m *workers.Msg)
PerformUpdateES updates the clan into elasticsearc
type EmptyGameIDError ¶
type EmptyGameIDError struct {
Type string
}
EmptyGameIDError identifies that a request was made for a model without the proper game id
func (*EmptyGameIDError) Error ¶
func (e *EmptyGameIDError) Error() string
type EmptySearchTermError ¶
type EmptySearchTermError struct{}
EmptySearchTermError identifies that a search term was not provided
func (*EmptySearchTermError) Error ¶
func (e *EmptySearchTermError) Error() string
type ForbiddenError ¶
type ForbiddenError struct { GameID string PlayerID interface{} ClanID interface{} }
ForbiddenError identifies that an action over an actionable is forbidden given PlayerId
func (*ForbiddenError) Error ¶
func (e *ForbiddenError) Error() string
type Game ¶
type Game struct { ID int `db:"id"` PublicID string `db:"public_id"` Name string `db:"name"` MinMembershipLevel int `db:"min_membership_level"` MaxMembershipLevel int `db:"max_membership_level"` MinLevelToAcceptApplication int `db:"min_level_to_accept_application"` MinLevelToCreateInvitation int `db:"min_level_to_create_invitation"` MinLevelToRemoveMember int `db:"min_level_to_remove_member"` MinLevelOffsetToRemoveMember int `db:"min_level_offset_to_remove_member"` MinLevelOffsetToPromoteMember int `db:"min_level_offset_to_promote_member"` MinLevelOffsetToDemoteMember int `db:"min_level_offset_to_demote_member"` MaxMembers int `db:"max_members"` MaxClansPerPlayer int `db:"max_clans_per_player"` MembershipLevels map[string]interface{} `db:"membership_levels"` Metadata map[string]interface{} `db:"metadata"` CreatedAt int64 `db:"created_at"` UpdatedAt int64 `db:"updated_at"` CooldownAfterDeny int `db:"cooldown_after_deny"` CooldownAfterDelete int `db:"cooldown_after_delete"` CooldownBeforeApply int `db:"cooldown_before_apply"` CooldownBeforeInvite int `db:"cooldown_before_invite"` MaxPendingInvites int `db:"max_pending_invites"` ClanUpdateMetadataFieldsHookTriggerWhitelist string `db:"clan_metadata_fields_whitelist"` PlayerUpdateMetadataFieldsHookTriggerWhitelist string `db:"player_metadata_fields_whitelist"` }
Game identifies uniquely one game
func CreateGame ¶
func CreateGame( db DB, publicID, name string, levels, metadata map[string]interface{}, minLevelAccept, minLevelCreate, minLevelRemove, minOffsetRemove, minOffsetPromote, minOffsetDemote, maxMembers, maxClans, cooldownAfterDeny, cooldownAfterDelete, cooldownBeforeApply, cooldownBeforeInvite, maxPendingInvites int, upsert bool, clanUpdateMetadataFieldsHookTriggerWhitelist string, playerUpdateMetadataFieldsHookTriggerWhitelist string, ) (*Game, error)
CreateGame creates a new game
func GetGameByPublicID ¶
GetGameByPublicID returns a game by their public id
func UpdateGame ¶
func UpdateGame( db DB, publicID, name string, levels, metadata map[string]interface{}, minLevelAccept, minLevelCreate, minLevelRemove, minOffsetRemove, minOffsetPromote, minOffsetDemote, maxMembers, maxClans, cooldownAfterDeny, cooldownAfterDelete, cooldownBeforeApply, cooldownBeforeInvite, maxPendingInvites int, clanUpdateMetadataFieldsHookTriggerWhitelist string, playerUpdateMetadataFieldsHookTriggerWhitelist string, ) (*Game, error)
UpdateGame updates an existing game
type GetClanDetailsOptions ¶
type GetClanDetailsOptions struct { MaxPendingApplications int MaxPendingInvites int PendingApplicationsOrder string PendingInvitesOrder string }
GetClanDetailsOptions holds options to change the output of GetClanDetails()
func NewDefaultGetClanDetailsOptions ¶
func NewDefaultGetClanDetailsOptions(config *viper.Viper) *GetClanDetailsOptions
NewDefaultGetClanDetailsOptions returns a new options structure with default values for GetClanDetails()
type Hook ¶
type Hook struct { ID int `db:"id"` GameID string `db:"game_id"` PublicID string `db:"public_id"` EventType int `db:"event_type"` URL string `db:"url"` CreatedAt int64 `db:"created_at"` UpdatedAt int64 `db:"updated_at"` }
Hook identifies a webhook for a given event
func CreateHook ¶
CreateHook returns a newly created event hook
func CreateHookFactory ¶
CreateHookFactory is responsible for creating a test hook instance with the associated game
func GetAllHooks ¶
GetAllHooks returns all the available hooks
func GetHookByDetails ¶
GetHookByDetails returns a hook by its details (GameID, EventType and Hook URL) If no hook is found returns nil.
func GetHookByPublicID ¶
GetHookByPublicID returns a hook by game id and public id
func GetHooksForRoutes ¶
GetHooksForRoutes gets hooks for all the specified routes
func GetTestHooks ¶
GetTestHooks return a fixed number of hooks for each event available
type InvalidCastToGorpSQLExecutorError ¶
type InvalidCastToGorpSQLExecutorError struct { }
InvalidCastToGorpSQLExecutorError identifies that cast to gorp.SqlExecutor failed
func (*InvalidCastToGorpSQLExecutorError) Error ¶
func (e *InvalidCastToGorpSQLExecutorError) Error() string
type InvalidLevelForGameError ¶
type InvalidLevelForGameError struct { GameID string Level interface{} }
InvalidLevelForGameError identifies that a given level is not valid for the given game
func (*InvalidLevelForGameError) Error ¶
func (e *InvalidLevelForGameError) Error() string
type InvalidMembershipActionError ¶
type InvalidMembershipActionError struct {
Action string
}
InvalidMembershipActionError identifies that a given action is not valid
func (*InvalidMembershipActionError) Error ¶
func (e *InvalidMembershipActionError) Error() string
type Membership ¶
type Membership struct { ID int64 `db:"id"` GameID string `db:"game_id"` Level string `db:"membership_level"` Approved bool `db:"approved"` Denied bool `db:"denied"` Banned bool `db:"banned"` PlayerID int64 `db:"player_id"` ClanID int64 `db:"clan_id"` RequestorID int64 `db:"requestor_id"` ApproverID sql.NullInt64 `db:"approver_id"` DenierID sql.NullInt64 `db:"denier_id"` CreatedAt int64 `db:"created_at"` UpdatedAt int64 `db:"updated_at"` DeletedBy int64 `db:"deleted_by"` DeletedAt int64 `db:"deleted_at"` ApprovedAt int64 `db:"approved_at"` DeniedAt int64 `db:"denied_at"` Message string `db:"message"` }
Membership relates a player to a clan
func ApproveOrDenyMembershipApplication ¶
func ApproveOrDenyMembershipApplication(db DB, game *Game, gameID, playerPublicID, clanPublicID, requestorPublicID, action string) (*Membership, error)
ApproveOrDenyMembershipApplication sets Membership.Approved to true or Membership.Denied to true
func ApproveOrDenyMembershipInvitation ¶
func ApproveOrDenyMembershipInvitation(db DB, game *Game, gameID, playerPublicID, clanPublicID, action string) (*Membership, error)
ApproveOrDenyMembershipInvitation sets Membership.Approved to true or Membership.Denied to true
func CreateMembership ¶
func CreateMembership(db DB, game *Game, gameID, level, playerPublicID, clanPublicID, requestorPublicID, message string) (*Membership, error)
CreateMembership creates a new membership
func DeleteMembership ¶
func DeleteMembership(db DB, game *Game, gameID, playerPublicID, clanPublicID, requestorPublicID string) (*Membership, error)
DeleteMembership soft deletes a membership
func GetDeletedMembershipByClanAndPlayerID ¶ added in v1.1.3
func GetDeletedMembershipByClanAndPlayerID(db DB, gameID string, clanID, playerID int64) (*Membership, error)
GetDeletedMembershipByClanAndPlayerID returns a deleted membership for the player with the given ID and the clan ID
func GetMembershipByClanAndPlayerPublicID ¶
func GetMembershipByClanAndPlayerPublicID(db DB, gameID, clanPublicID, playerPublicID string) (*Membership, error)
GetMembershipByClanAndPlayerPublicID returns a deleted membership for the clan and the player with the given publicIDs
func GetMembershipByID ¶
func GetMembershipByID(db DB, id int64) (*Membership, error)
GetMembershipByID returns a membership by id
func GetOldestMemberWithHighestLevel ¶
func GetOldestMemberWithHighestLevel(db DB, gameID, clanPublicID string) (*Membership, error)
GetOldestMemberWithHighestLevel returns the member with highest level that has the oldest creation date
func GetValidMembershipByClanAndPlayerPublicID ¶
func GetValidMembershipByClanAndPlayerPublicID(db DB, gameID, clanPublicID, playerPublicID string) (*Membership, error)
GetValidMembershipByClanAndPlayerPublicID returns a non deleted membership for the clan and the player with the given publicIDs
func PromoteOrDemoteMember ¶
func PromoteOrDemoteMember(db DB, game *Game, gameID, playerPublicID, clanPublicID, requestorPublicID, action string) (*Membership, error)
PromoteOrDemoteMember increments or decrements Membership.LevelInt by one
func (*Membership) PreInsert ¶
func (m *Membership) PreInsert(s gorp.SqlExecutor) error
PreInsert populates fields before inserting a new clan
func (*Membership) PreUpdate ¶
func (m *Membership) PreUpdate(s gorp.SqlExecutor) error
PreUpdate populates fields before updating a clan
type ModelNotFoundError ¶
type ModelNotFoundError struct { Type string ID interface{} }
ModelNotFoundError identifies that a given model was not found in the Database with the given ID
func (*ModelNotFoundError) Error ¶
func (e *ModelNotFoundError) Error() string
type MongoWorker ¶
type MongoWorker struct { Logger zap.Logger MongoDB interfaces.MongoDB MongoCollectionTemplate string }
MongoWorker is the worker that will update mongo
func NewMongoWorker ¶
func NewMongoWorker(logger zap.Logger, config *viper.Viper) *MongoWorker
NewMongoWorker creates and returns a new mongo worker
func (*MongoWorker) PerformUpdateMongo ¶
func (w *MongoWorker) PerformUpdateMongo(m *workers.Msg)
PerformUpdateMongo updates the clan into elasticsearc
type MustWaitMembershipCooldownError ¶
MustWaitMembershipCooldownError identifies that one must wait a number of seconds before creating the membership
func (*MustWaitMembershipCooldownError) Error ¶
func (e *MustWaitMembershipCooldownError) Error() string
type Player ¶
type Player struct { ID int64 `db:"id"` GameID string `db:"game_id"` PublicID string `db:"public_id"` Name string `db:"name"` Metadata map[string]interface{} `db:"metadata"` MembershipCount int `db:"membership_count"` OwnershipCount int `db:"ownership_count"` CreatedAt int64 `db:"created_at"` UpdatedAt int64 `db:"updated_at"` }
Player identifies uniquely one player in a given game
func CreatePlayer ¶
func CreatePlayer(db DB, gameID, publicID, name string, metadata map[string]interface{}, upsert bool) (*Player, error)
CreatePlayer creates a new player
func GetPlayerByID ¶
GetPlayerByID returns a player by id
func GetPlayerByPublicID ¶
GetPlayerByPublicID returns a player by their public id
func GetTestPlayerWithMemberships ¶
func GetTestPlayerWithMemberships(db DB, gameID string, approvedMemberships, rejectedMemberships, bannedMemberships, pendingMemberships int) (*Player, error)
GetTestPlayerWithMemberships returns a player with approved, rejected and banned memberships
func UpdatePlayer ¶
func UpdatePlayer(db DB, gameID, publicID, name string, metadata map[string]interface{}) (*Player, error)
UpdatePlayer updates an existing player
func (*Player) PreInsert ¶
func (p *Player) PreInsert(s gorp.SqlExecutor) error
PreInsert populates fields before inserting a new player
type PlayerCannotCreateMembershipError ¶
type PlayerCannotCreateMembershipError struct { PlayerID interface{} ClanID interface{} }
PlayerCannotCreateMembershipError identifies that a given player is not allowed to create a membership
func (*PlayerCannotCreateMembershipError) Error ¶
func (e *PlayerCannotCreateMembershipError) Error() string
type PlayerCannotPerformMembershipActionError ¶
type PlayerCannotPerformMembershipActionError struct { Action string PlayerID interface{} ClanID interface{} RequestorID interface{} }
PlayerCannotPerformMembershipActionError identifies that a given player is not allowed to promote/demote another member
func (*PlayerCannotPerformMembershipActionError) Error ¶
func (e *PlayerCannotPerformMembershipActionError) Error() string
type PlayerReachedMaxClansError ¶
type PlayerReachedMaxClansError struct {
ID interface{}
}
PlayerReachedMaxClansError identifies that a given player already reached the max number of clans allowed
func (*PlayerReachedMaxClansError) Error ¶
func (e *PlayerReachedMaxClansError) Error() string
type PlayerReachedMaxInvitesError ¶
type PlayerReachedMaxInvitesError struct {
ID string
}
PlayerReachedMaxInvitesError identifies that a given player already reached the max number of pending invites allowed
func (*PlayerReachedMaxInvitesError) Error ¶
func (e *PlayerReachedMaxInvitesError) Error() string
type PruneOptions ¶ added in v0.12.0
type PruneOptions struct { GameID string PendingApplicationsExpiration int PendingInvitesExpiration int DeniedMembershipsExpiration int DeletedMembershipsExpiration int }
PruneOptions has all the prunable memberships TTL
type PruneStats ¶ added in v0.12.0
type PruneStats struct { PendingApplicationsPruned int PendingInvitesPruned int DeniedMembershipsPruned int DeletedMembershipsPruned int }
PruneStats show stats about what has been pruned
func PruneStaleData ¶ added in v0.12.0
func PruneStaleData(options *PruneOptions, db DB, logger zap.Logger) (*PruneStats, error)
PruneStaleData off of Khan's database
func (*PruneStats) GetStats ¶ added in v0.12.0
func (ps *PruneStats) GetStats() string
GetStats returns a formatted message