app

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataCleanupPublisher

type DataCleanupPublisher interface {
	CmdCleanUp(ctx context.Context, payloads ...domain.CleanUpDataCmdPayload) error
}

type DataCleanupService

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

func NewDataCleanupService

func NewDataCleanupService(serverSvc *ServerService, pub DataCleanupPublisher) *DataCleanupService

func (*DataCleanupService) CleanUp

func (svc *DataCleanupService) CleanUp(ctx context.Context) error

type DataSyncService

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

func NewDataSyncService

func NewDataSyncService(
	versionSvc *VersionService,
	serverSvc *ServerService,
	serverPub ServerPublisher,
	ennoblementPub EnnoblementPublisher,
) *DataSyncService

func (*DataSyncService) Sync

func (svc *DataSyncService) Sync(ctx context.Context) error

func (*DataSyncService) SyncEnnoblements

func (svc *DataSyncService) SyncEnnoblements(ctx context.Context) error

type EnnoblementPublisher

type EnnoblementPublisher interface {
	CmdSync(ctx context.Context, payloads ...domain.SyncEnnoblementsCmdPayload) error
	EventSynced(ctx context.Context, payloads ...domain.EnnoblementsSyncedEventPayload) error
}

type EnnoblementRepository

type EnnoblementRepository interface {
	Create(ctx context.Context, params ...domain.CreateEnnoblementParams) error
	List(ctx context.Context, params domain.ListEnnoblementsParams) (domain.ListEnnoblementsResult, error)
	ListWithRelations(
		ctx context.Context,
		params domain.ListEnnoblementsParams,
	) (domain.ListEnnoblementsWithRelationsResult, error)
	Delete(ctx context.Context, serverKey string, createdAtLTE time.Time) error
}

type EnnoblementService

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

func (*EnnoblementService) CleanUp

func (*EnnoblementService) List

func (*EnnoblementService) ListWithRelations

func (*EnnoblementService) Sync

func (svc *EnnoblementService) Sync(
	ctx context.Context,
	syncEnnoblementsCmdPayload domain.SyncEnnoblementsCmdPayload,
) error

type PlayerPublisher

type PlayerPublisher interface {
	EventSynced(ctx context.Context, payloads ...domain.PlayersSyncedEventPayload) error
}

type PlayerRepository

type PlayerRepository interface {
	CreateOrUpdate(ctx context.Context, params ...domain.CreatePlayerParams) error
	List(ctx context.Context, params domain.ListPlayersParams) (domain.ListPlayersResult, error)
	ListWithRelations(ctx context.Context, params domain.ListPlayersParams) (domain.ListPlayersWithRelationsResult, error)
	Count(ctx context.Context, params domain.CountPlayersParams) (int, error)
	// Delete marks players with the given serverKey and ids as deleted (sets deleted at to now).
	// In addition, Delete sets TribeID to null.
	//
	// https://en.wiktionary.org/wiki/soft_deletion
	Delete(ctx context.Context, serverKey string, ids ...int) error
}

type PlayerService

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

func NewPlayerService

func NewPlayerService(
	repo PlayerRepository,
	tribeChangeSvc *TribeChangeService,
	twSvc TWService,
	pub PlayerPublisher,
) *PlayerService

func (*PlayerService) GetWithRelations

func (svc *PlayerService) GetWithRelations(
	ctx context.Context,
	id int,
	serverKey string,
) (domain.PlayerWithRelations, error)

func (*PlayerService) List

func (*PlayerService) ListWithRelations

func (*PlayerService) Sync

func (svc *PlayerService) Sync(ctx context.Context, serverSyncedPayload domain.ServerSyncedEventPayload) error

type PlayerSnapshotRepository

type PlayerSnapshotRepository interface {
	// Create persists player snapshots in a store (e.g. Postgres).
	// Duplicates are ignored.
	Create(ctx context.Context, params ...domain.CreatePlayerSnapshotParams) error
	ListWithRelations(
		ctx context.Context,
		params domain.ListPlayerSnapshotsParams,
	) (domain.ListPlayerSnapshotsWithRelationsResult, error)
	Delete(ctx context.Context, serverKey string, dateLTE time.Time) error
}

type PlayerSnapshotService

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

func NewPlayerSnapshotService

func NewPlayerSnapshotService(
	repo PlayerSnapshotRepository,
	playerSvc *PlayerService,
	pub SnapshotPublisher,
) *PlayerSnapshotService

func (*PlayerSnapshotService) CleanUp

func (*PlayerSnapshotService) Create

func (svc *PlayerSnapshotService) Create(
	ctx context.Context,
	createSnapshotsCmdPayload domain.CreateSnapshotsCmdPayload,
) error

func (*PlayerSnapshotService) ListWithRelations

type ServerPublisher

type ServerPublisher interface {
	CmdSync(ctx context.Context, payloads ...domain.SyncServersCmdPayload) error
	EventSynced(ctx context.Context, payloads ...domain.ServerSyncedEventPayload) error
}

type ServerRepository

type ServerRepository interface {
	CreateOrUpdate(ctx context.Context, params ...domain.CreateServerParams) error
	List(ctx context.Context, params domain.ListServersParams) (domain.ListServersResult, error)
	Update(ctx context.Context, key string, params domain.UpdateServerParams) error
}

type ServerService

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

func NewServerService

func NewServerService(repo ServerRepository, twSvc TWService, pub ServerPublisher) *ServerService

func (*ServerService) GetNormalByVersionCodeAndServerKey

func (svc *ServerService) GetNormalByVersionCodeAndServerKey(
	ctx context.Context,
	versionCode, key string,
) (domain.Server, error)

func (*ServerService) List

func (*ServerService) ListAll

ListAll retrieves all servers from the database based on the given params in an optimal way. You can't specify a custom limit/cursor/sort for this operation.

func (*ServerService) ListAllOpen

func (svc *ServerService) ListAllOpen(ctx context.Context, versionCode string) (domain.Servers, error)

func (*ServerService) Sync

func (*ServerService) SyncConfigAndInfo

func (svc *ServerService) SyncConfigAndInfo(ctx context.Context, payload domain.ServerSyncedEventPayload) error

func (*ServerService) UpdateEnnoblementDataSyncedAt

func (svc *ServerService) UpdateEnnoblementDataSyncedAt(
	ctx context.Context,
	payload domain.EnnoblementsSyncedEventPayload,
) error

func (*ServerService) UpdateNumPlayers

func (svc *ServerService) UpdateNumPlayers(ctx context.Context, payload domain.PlayersSyncedEventPayload) error

func (*ServerService) UpdateNumTribes

func (svc *ServerService) UpdateNumTribes(ctx context.Context, payload domain.TribesSyncedEventPayload) error

func (*ServerService) UpdateNumVillages

func (svc *ServerService) UpdateNumVillages(ctx context.Context, payload domain.VillagesSyncedEventPayload) error

func (*ServerService) UpdatePlayerSnapshotsCreatedAt

func (svc *ServerService) UpdatePlayerSnapshotsCreatedAt(
	ctx context.Context,
	payload domain.SnapshotsCreatedEventPayload,
) error

func (*ServerService) UpdateSnapshotCreatedAt added in v1.1.0

func (svc *ServerService) UpdateSnapshotCreatedAt(
	ctx context.Context,
	key string,
) error

func (*ServerService) UpdateTribeSnapshotsCreatedAt

func (svc *ServerService) UpdateTribeSnapshotsCreatedAt(
	ctx context.Context,
	payload domain.SnapshotsCreatedEventPayload,
) error

type ServerSnapshotRepository added in v1.1.0

type ServerSnapshotRepository interface {
	// Create persists tribe snapshots in a store (e.g. Postgres).
	// Duplicates are ignored.
	Create(ctx context.Context, params ...domain.CreateServerSnapshotParams) error
}

type ServerSnapshotService added in v1.1.0

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

func NewServerSnapshotService added in v1.1.0

func NewServerSnapshotService(
	repo ServerSnapshotRepository,
	serverSvc *ServerService,
	pub SnapshotPublisher,
) *ServerSnapshotService

func (*ServerSnapshotService) Create added in v1.1.0

func (svc *ServerSnapshotService) Create(
	ctx context.Context,
	createSnapshotsCmdPayload domain.CreateSnapshotsCmdPayload,
) error

type SnapshotPublisher

type SnapshotPublisher interface {
	CmdCreate(ctx context.Context, payloads ...domain.CreateSnapshotsCmdPayload) error
	EventCreated(ctx context.Context, payloads ...domain.SnapshotsCreatedEventPayload) error
}

type SnapshotService

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

func NewSnapshotService

func NewSnapshotService(
	versionSvc *VersionService,
	serverSvc *ServerService,
	serverSnapshotPub SnapshotPublisher,
	tribeSnapshotPub SnapshotPublisher,
	playerSnapshotPub SnapshotPublisher,
) *SnapshotService

func (*SnapshotService) Create

func (svc *SnapshotService) Create(ctx context.Context) error

type TWService

type TWService interface {
	GetOpenServers(ctx context.Context, baseURL *url.URL) (domain.BaseServers, error)
	GetServerConfig(ctx context.Context, baseURL *url.URL) (domain.ServerConfig, error)
	GetUnitInfo(ctx context.Context, baseURL *url.URL) (domain.UnitInfo, error)
	GetBuildingInfo(ctx context.Context, baseURL *url.URL) (domain.BuildingInfo, error)
	GetTribes(ctx context.Context, baseURL *url.URL) (domain.BaseTribes, error)
	GetPlayers(ctx context.Context, baseURL *url.URL) (domain.BasePlayers, error)
	GetVillages(ctx context.Context, baseURL *url.URL) (domain.BaseVillages, error)
	GetEnnoblements(ctx context.Context, baseURL *url.URL, since time.Time) (domain.BaseEnnoblements, error)
}

type TribeChangeRepository

type TribeChangeRepository interface {
	// Create persists tribe changes in a store (e.g. Postgres).
	// Duplicates are ignored.
	Create(ctx context.Context, params ...domain.CreateTribeChangeParams) error
	List(ctx context.Context, params domain.ListTribeChangesParams) (domain.ListTribeChangesResult, error)
	ListWithRelations(
		ctx context.Context,
		params domain.ListTribeChangesParams,
	) (domain.ListTribeChangesWithRelationsResult, error)
}

type TribeChangeService

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

func NewTribeChangeService

func NewTribeChangeService(repo TribeChangeRepository) *TribeChangeService

func (*TribeChangeService) Create

func (*TribeChangeService) List

func (*TribeChangeService) ListWithRelations

type TribePublisher

type TribePublisher interface {
	EventSynced(ctx context.Context, payloads ...domain.TribesSyncedEventPayload) error
}

type TribeRepository

type TribeRepository interface {
	CreateOrUpdate(ctx context.Context, params ...domain.CreateTribeParams) error
	UpdateDominance(ctx context.Context, serverKey string, numPlayerVillages int) error
	List(ctx context.Context, params domain.ListTribesParams) (domain.ListTribesResult, error)
	Count(ctx context.Context, params domain.CountTribesParams) (int, error)
	// Delete marks players with the given serverKey and ids as deleted (sets deleted at to now).
	//
	// https://en.wiktionary.org/wiki/soft_deletion
	Delete(ctx context.Context, serverKey string, ids ...int) error
}

type TribeService

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

func NewTribeService

func NewTribeService(repo TribeRepository, twSvc TWService, pub TribePublisher) *TribeService

func (*TribeService) Get

func (svc *TribeService) Get(
	ctx context.Context,
	id int,
	serverKey string,
) (domain.Tribe, error)

func (*TribeService) List

func (*TribeService) Sync

func (svc *TribeService) Sync(ctx context.Context, serverSyncedPayload domain.ServerSyncedEventPayload) error

func (*TribeService) UpdateDominance

func (svc *TribeService) UpdateDominance(ctx context.Context, payload domain.VillagesSyncedEventPayload) error

type TribeSnapshotRepository

type TribeSnapshotRepository interface {
	// Create persists tribe snapshots in a store (e.g. Postgres).
	// Duplicates are ignored.
	Create(ctx context.Context, params ...domain.CreateTribeSnapshotParams) error
	ListWithRelations(
		ctx context.Context,
		params domain.ListTribeSnapshotsParams,
	) (domain.ListTribeSnapshotsWithRelationsResult, error)
	Delete(ctx context.Context, serverKey string, dateLTE time.Time) error
}

type TribeSnapshotService

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

func NewTribeSnapshotService

func NewTribeSnapshotService(
	repo TribeSnapshotRepository,
	tribeSvc *TribeService,
	pub SnapshotPublisher,
) *TribeSnapshotService

func (*TribeSnapshotService) CleanUp

func (*TribeSnapshotService) Create

func (svc *TribeSnapshotService) Create(
	ctx context.Context,
	createSnapshotsCmdPayload domain.CreateSnapshotsCmdPayload,
) error

func (*TribeSnapshotService) ListWithRelations

type VersionRepository

type VersionRepository interface {
	List(ctx context.Context, params domain.ListVersionsParams) (domain.ListVersionsResult, error)
}

type VersionService

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

func NewVersionService

func NewVersionService(repo VersionRepository) *VersionService

func (*VersionService) Get

func (svc *VersionService) Get(ctx context.Context, code string) (domain.Version, error)

func (*VersionService) List

type VillagePublisher

type VillagePublisher interface {
	EventSynced(ctx context.Context, payloads ...domain.VillagesSyncedEventPayload) error
}

type VillageRepository

type VillageRepository interface {
	CreateOrUpdate(ctx context.Context, params ...domain.CreateVillageParams) error
	List(ctx context.Context, params domain.ListVillagesParams) (domain.ListVillagesResult, error)
	ListWithRelations(
		ctx context.Context,
		params domain.ListVillagesParams,
	) (domain.ListVillagesWithRelationsResult, error)
	Delete(ctx context.Context, serverKey string, ids ...int) error
}

type VillageService

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

func NewVillageService

func NewVillageService(repo VillageRepository, twSvc TWService, pub VillagePublisher) *VillageService

func (*VillageService) GetWithRelations

func (svc *VillageService) GetWithRelations(
	ctx context.Context,
	id int,
	serverKey string,
) (domain.VillageWithRelations, error)

func (*VillageService) List

func (*VillageService) ListWithRelations

func (*VillageService) Sync

func (svc *VillageService) Sync(ctx context.Context, serverSyncedPayload domain.ServerSyncedEventPayload) error

Jump to

Keyboard shortcuts

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