feat(scum): rebuild plugin-owned management data
This commit is contained in:
+8
-107
@@ -43,27 +43,6 @@ type StoreSnapshot struct {
|
||||
GameClientBridgeSnapshots []domain.GameClientBridgeSnapshot `json:"gameClientBridgeSnapshots"`
|
||||
GameClientBridgeStreams []domain.GameClientBridgeSnapshotStream `json:"gameClientBridgeStreams"`
|
||||
PluginDataRecords []domain.PluginDataRecord `json:"pluginDataRecords"`
|
||||
GamePlayers []domain.GamePlayer `json:"gamePlayers"`
|
||||
GamePlayerAliases []domain.GamePlayerAlias `json:"gamePlayerAliases"`
|
||||
GamePlayerSessions []domain.GamePlayerSession `json:"gamePlayerSessions"`
|
||||
GameAccessAttempts []domain.GameAccessAttempt `json:"gameAccessAttempts"`
|
||||
GameSecuritySignals []domain.GameSecuritySignal `json:"gameSecuritySignals"`
|
||||
GamePlayerStatePatches []domain.GamePlayerStatePatch `json:"gamePlayerStatePatches"`
|
||||
GameMapTrackPoints []domain.GameMapTrackPoint `json:"gameMapTrackPoints"`
|
||||
GamePlayerVehicleSegments []domain.GamePlayerVehicleSegment `json:"gamePlayerVehicleSegments"`
|
||||
GameGiftCatalogs []domain.GameGiftCatalog `json:"gameGiftCatalogs"`
|
||||
GameGiftRevisions []domain.GameGiftRevision `json:"gameGiftRevisions"`
|
||||
GameGiftGrants []domain.GameGiftGrant `json:"gameGiftGrants"`
|
||||
SCUMDataObservations []domain.SCUMDataObservation `json:"scumDataObservations"`
|
||||
SCUMPlayerLiveStates []domain.SCUMPlayerLiveState `json:"scumPlayerLiveStates"`
|
||||
SCUMSquads []domain.SCUMSquad `json:"scumSquads"`
|
||||
SCUMSquadMembers []domain.SCUMSquadMember `json:"scumSquadMembers"`
|
||||
SCUMVehicles []domain.SCUMVehicle `json:"scumVehicles"`
|
||||
SCUMFlags []domain.SCUMFlag `json:"scumFlags"`
|
||||
SCUMCurrentPositions []domain.SCUMCurrentPosition `json:"scumCurrentPositions"`
|
||||
SCUMOperationRequests []domain.SCUMOperationRequest `json:"scumOperationRequests"`
|
||||
SCUMWorkflowInstances []domain.SCUMWorkflowInstance `json:"scumWorkflowInstances"`
|
||||
SCUMWorkflowSteps []domain.SCUMWorkflowStep `json:"scumWorkflowSteps"`
|
||||
}
|
||||
|
||||
type FileStore struct {
|
||||
@@ -215,70 +194,6 @@ func (store *FileStore) GameClientBridgeSnapshotStreams() GameClientBridgeSnapsh
|
||||
func (store *FileStore) PluginDataRecords() PluginDataRecordRepository {
|
||||
return &persistentRepository[domain.PluginDataRecord, domain.PluginDataFilter]{repository: store.MemoryStore.pluginDataRecords, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GamePlayers() GamePlayerRepository {
|
||||
return &persistentRepository[domain.GamePlayer, domain.GamePlayerFilter]{repository: store.MemoryStore.gamePlayers, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GamePlayerAliases() GamePlayerAliasRepository {
|
||||
return &persistentRepository[domain.GamePlayerAlias, domain.GamePlayerAliasFilter]{repository: store.MemoryStore.gamePlayerAliases, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GamePlayerSessions() GamePlayerSessionRepository {
|
||||
return &persistentRepository[domain.GamePlayerSession, domain.GamePlayerSessionFilter]{repository: store.MemoryStore.gamePlayerSessions, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GameAccessAttempts() GameAccessAttemptRepository {
|
||||
return &persistentRepository[domain.GameAccessAttempt, domain.GameAccessAttemptFilter]{repository: store.MemoryStore.gameAccessAttempts, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GameSecuritySignals() GameSecuritySignalRepository {
|
||||
return &persistentRepository[domain.GameSecuritySignal, domain.GameSecuritySignalFilter]{repository: store.MemoryStore.gameSecuritySignals, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GamePlayerStatePatches() GamePlayerStatePatchRepository {
|
||||
return &persistentRepository[domain.GamePlayerStatePatch, domain.GamePlayerStatePatchFilter]{repository: store.MemoryStore.gamePlayerStatePatches, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GameMapTrackPoints() GameMapTrackPointRepository {
|
||||
return &persistentRepository[domain.GameMapTrackPoint, domain.GameMapTrackPointFilter]{repository: store.MemoryStore.gameMapTrackPoints, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GamePlayerVehicleSegments() GamePlayerVehicleSegmentRepository {
|
||||
return &persistentRepository[domain.GamePlayerVehicleSegment, domain.GamePlayerVehicleSegmentFilter]{repository: store.MemoryStore.gamePlayerVehicleSegments, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GameGiftCatalogs() GameGiftCatalogRepository {
|
||||
return &persistentRepository[domain.GameGiftCatalog, domain.GameGiftCatalogFilter]{repository: store.MemoryStore.gameGiftCatalogs, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GameGiftRevisions() GameGiftRevisionRepository {
|
||||
return &persistentRepository[domain.GameGiftRevision, domain.GameGiftRevisionFilter]{repository: store.MemoryStore.gameGiftRevisions, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) GameGiftGrants() GameGiftGrantRepository {
|
||||
return &persistentRepository[domain.GameGiftGrant, domain.GameGiftGrantFilter]{repository: store.MemoryStore.gameGiftGrants, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMDataObservations() SCUMDataObservationRepository {
|
||||
return &persistentRepository[domain.SCUMDataObservation, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumDataObservations, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMPlayerLiveStates() SCUMPlayerLiveStateRepository {
|
||||
return &persistentRepository[domain.SCUMPlayerLiveState, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumPlayerLiveStates, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMSquads() SCUMSquadRepository {
|
||||
return &persistentRepository[domain.SCUMSquad, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumSquads, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMSquadMembers() SCUMSquadMemberRepository {
|
||||
return &persistentRepository[domain.SCUMSquadMember, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumSquadMembers, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMVehicles() SCUMVehicleRepository {
|
||||
return &persistentRepository[domain.SCUMVehicle, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumVehicles, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMFlags() SCUMFlagRepository {
|
||||
return &persistentRepository[domain.SCUMFlag, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumFlags, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMCurrentPositions() SCUMCurrentPositionRepository {
|
||||
return &persistentRepository[domain.SCUMCurrentPosition, domain.SCUMProjectionFilter]{repository: store.MemoryStore.scumCurrentPositions, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMOperationRequests() SCUMOperationRequestRepository {
|
||||
return &persistentRepository[domain.SCUMOperationRequest, domain.SCUMOperationRequestFilter]{repository: store.MemoryStore.scumOperationRequests, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMWorkflowInstances() SCUMWorkflowInstanceRepository {
|
||||
return &persistentRepository[domain.SCUMWorkflowInstance, domain.SCUMWorkflowInstanceFilter]{repository: store.MemoryStore.scumWorkflowInstances, persist: store.persist}
|
||||
}
|
||||
func (store *FileStore) SCUMWorkflowSteps() SCUMWorkflowStepRepository {
|
||||
return &persistentRepository[domain.SCUMWorkflowStep, domain.SCUMWorkflowStepFilter]{repository: store.MemoryStore.scumWorkflowSteps, persist: store.persist}
|
||||
}
|
||||
|
||||
func (store *FileStore) load() error {
|
||||
data, err := os.ReadFile(store.path)
|
||||
if err != nil {
|
||||
@@ -352,7 +267,6 @@ func (store *FileStore) snapshot() StoreSnapshot {
|
||||
GameClientBridgeSnapshots: snapshotRepository(store.MemoryStore.bridgeSnapshots.memoryRepository),
|
||||
GameClientBridgeStreams: snapshotRepository(store.MemoryStore.bridgeStreams),
|
||||
PluginDataRecords: snapshotRepository(store.MemoryStore.pluginDataRecords),
|
||||
GamePlayers: snapshotRepository(store.MemoryStore.gamePlayers), GamePlayerAliases: snapshotRepository(store.MemoryStore.gamePlayerAliases), GamePlayerSessions: snapshotRepository(store.MemoryStore.gamePlayerSessions), GameAccessAttempts: snapshotRepository(store.MemoryStore.gameAccessAttempts), GameSecuritySignals: snapshotRepository(store.MemoryStore.gameSecuritySignals), GamePlayerStatePatches: snapshotRepository(store.MemoryStore.gamePlayerStatePatches), GameMapTrackPoints: snapshotRepository(store.MemoryStore.gameMapTrackPoints), GamePlayerVehicleSegments: snapshotRepository(store.MemoryStore.gamePlayerVehicleSegments), GameGiftCatalogs: snapshotRepository(store.MemoryStore.gameGiftCatalogs), GameGiftRevisions: snapshotRepository(store.MemoryStore.gameGiftRevisions), GameGiftGrants: snapshotRepository(store.MemoryStore.gameGiftGrants), SCUMDataObservations: snapshotRepository(store.MemoryStore.scumDataObservations), SCUMPlayerLiveStates: snapshotRepository(store.MemoryStore.scumPlayerLiveStates), SCUMSquads: snapshotRepository(store.MemoryStore.scumSquads), SCUMSquadMembers: snapshotRepository(store.MemoryStore.scumSquadMembers), SCUMVehicles: snapshotRepository(store.MemoryStore.scumVehicles), SCUMFlags: snapshotRepository(store.MemoryStore.scumFlags), SCUMCurrentPositions: snapshotRepository(store.MemoryStore.scumCurrentPositions), SCUMOperationRequests: snapshotRepository(store.MemoryStore.scumOperationRequests), SCUMWorkflowInstances: snapshotRepository(store.MemoryStore.scumWorkflowInstances), SCUMWorkflowSteps: snapshotRepository(store.MemoryStore.scumWorkflowSteps),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,27 +301,6 @@ func (store *FileStore) loadSnapshot(snapshot StoreSnapshot) {
|
||||
loadRepository(store.MemoryStore.bridgeSnapshots.memoryRepository, snapshot.GameClientBridgeSnapshots)
|
||||
loadRepository(store.MemoryStore.bridgeStreams, snapshot.GameClientBridgeStreams)
|
||||
loadRepository(store.MemoryStore.pluginDataRecords, snapshot.PluginDataRecords)
|
||||
loadRepository(store.MemoryStore.gamePlayers, snapshot.GamePlayers)
|
||||
loadRepository(store.MemoryStore.gamePlayerAliases, snapshot.GamePlayerAliases)
|
||||
loadRepository(store.MemoryStore.gamePlayerSessions, snapshot.GamePlayerSessions)
|
||||
loadRepository(store.MemoryStore.gameAccessAttempts, snapshot.GameAccessAttempts)
|
||||
loadRepository(store.MemoryStore.gameSecuritySignals, snapshot.GameSecuritySignals)
|
||||
loadRepository(store.MemoryStore.gamePlayerStatePatches, snapshot.GamePlayerStatePatches)
|
||||
loadRepository(store.MemoryStore.gameMapTrackPoints, snapshot.GameMapTrackPoints)
|
||||
loadRepository(store.MemoryStore.gamePlayerVehicleSegments, snapshot.GamePlayerVehicleSegments)
|
||||
loadRepository(store.MemoryStore.gameGiftCatalogs, snapshot.GameGiftCatalogs)
|
||||
loadRepository(store.MemoryStore.gameGiftRevisions, snapshot.GameGiftRevisions)
|
||||
loadRepository(store.MemoryStore.gameGiftGrants, snapshot.GameGiftGrants)
|
||||
loadRepository(store.MemoryStore.scumDataObservations, snapshot.SCUMDataObservations)
|
||||
loadRepository(store.MemoryStore.scumPlayerLiveStates, snapshot.SCUMPlayerLiveStates)
|
||||
loadRepository(store.MemoryStore.scumSquads, snapshot.SCUMSquads)
|
||||
loadRepository(store.MemoryStore.scumSquadMembers, snapshot.SCUMSquadMembers)
|
||||
loadRepository(store.MemoryStore.scumVehicles, snapshot.SCUMVehicles)
|
||||
loadRepository(store.MemoryStore.scumFlags, snapshot.SCUMFlags)
|
||||
loadRepository(store.MemoryStore.scumCurrentPositions, snapshot.SCUMCurrentPositions)
|
||||
loadRepository(store.MemoryStore.scumOperationRequests, snapshot.SCUMOperationRequests)
|
||||
loadRepository(store.MemoryStore.scumWorkflowInstances, snapshot.SCUMWorkflowInstances)
|
||||
loadRepository(store.MemoryStore.scumWorkflowSteps, snapshot.SCUMWorkflowSteps)
|
||||
}
|
||||
|
||||
type mutableRepository[T any, F any] interface {
|
||||
@@ -416,6 +309,7 @@ type mutableRepository[T any, F any] interface {
|
||||
List(F) ([]T, error)
|
||||
Update(T) error
|
||||
Delete(string) error
|
||||
Apply([]T, []string) error
|
||||
}
|
||||
|
||||
type persistentRepository[T any, F any] struct {
|
||||
@@ -452,6 +346,13 @@ func (repository *persistentRepository[T, F]) Delete(id string) error {
|
||||
return repository.persist()
|
||||
}
|
||||
|
||||
func (repository *persistentRepository[T, F]) Apply(upserts []T, deleteIDs []string) error {
|
||||
if err := repository.repository.Apply(upserts, deleteIDs); err != nil {
|
||||
return err
|
||||
}
|
||||
return repository.persist()
|
||||
}
|
||||
|
||||
type persistentJobRepository struct {
|
||||
*persistentRepository[domain.Job, domain.JobFilter]
|
||||
repository JobRepository
|
||||
|
||||
Reference in New Issue
Block a user