功能修改
This commit is contained in:
@@ -178,6 +178,52 @@ type BackupRepository interface {
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
type AlertRepository interface {
|
||||
Create(domain.AlertRecord) error
|
||||
Get(id string) (domain.AlertRecord, error)
|
||||
List(domain.AlertFilter) ([]domain.AlertRecord, error)
|
||||
Update(domain.AlertRecord) error
|
||||
}
|
||||
|
||||
type PluginLifecycleRepository interface {
|
||||
Create(domain.PluginLifecycleInstallation) error
|
||||
Get(id string) (domain.PluginLifecycleInstallation, error)
|
||||
List(domain.PluginLifecycleFilter) ([]domain.PluginLifecycleInstallation, error)
|
||||
Update(domain.PluginLifecycleInstallation) error
|
||||
}
|
||||
|
||||
type AIConfigDiffRepository interface {
|
||||
Create(domain.AIConfigDiffPreview) error
|
||||
Get(id string) (domain.AIConfigDiffPreview, error)
|
||||
List(domain.AIConfigDiffFilter) ([]domain.AIConfigDiffPreview, error)
|
||||
Update(domain.AIConfigDiffPreview) error
|
||||
}
|
||||
|
||||
type GameClientBridgeCommandRepository interface {
|
||||
Create(domain.GameClientBridgeCommand) error
|
||||
Get(id string) (domain.GameClientBridgeCommand, error)
|
||||
GetByIdempotency(serverInstanceID, requesterID, commandType, idempotencyKey string) (domain.GameClientBridgeCommand, error)
|
||||
List(domain.GameClientBridgeCommandFilter) ([]domain.GameClientBridgeCommand, error)
|
||||
Update(domain.GameClientBridgeCommand) error
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
type GameClientBridgeSnapshotRepository interface {
|
||||
Create(domain.GameClientBridgeSnapshot) error
|
||||
Get(id string) (domain.GameClientBridgeSnapshot, error)
|
||||
List(domain.GameClientBridgeSnapshotFilter) ([]domain.GameClientBridgeSnapshot, error)
|
||||
Update(domain.GameClientBridgeSnapshot) error
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
type GameClientBridgeSnapshotStreamRepository interface {
|
||||
Create(domain.GameClientBridgeSnapshotStream) error
|
||||
Get(id string) (domain.GameClientBridgeSnapshotStream, error)
|
||||
List(domain.GameClientBridgeSnapshotStreamFilter) ([]domain.GameClientBridgeSnapshotStream, error)
|
||||
Update(domain.GameClientBridgeSnapshotStream) error
|
||||
Delete(id string) error
|
||||
}
|
||||
|
||||
type Store interface {
|
||||
Users() UserRepository
|
||||
AuthSessions() AuthSessionRepository
|
||||
@@ -202,6 +248,12 @@ type Store interface {
|
||||
AuditEvents() AuditEventRepository
|
||||
MetricSamples() MetricSampleRepository
|
||||
Backups() BackupRepository
|
||||
Alerts() AlertRepository
|
||||
PluginLifecycles() PluginLifecycleRepository
|
||||
AIConfigDiffs() AIConfigDiffRepository
|
||||
GameClientBridgeCommands() GameClientBridgeCommandRepository
|
||||
GameClientBridgeSnapshots() GameClientBridgeSnapshotRepository
|
||||
GameClientBridgeSnapshotStreams() GameClientBridgeSnapshotStreamRepository
|
||||
}
|
||||
|
||||
type MemoryStore struct {
|
||||
@@ -228,6 +280,12 @@ type MemoryStore struct {
|
||||
auditEvents *memoryRepository[domain.AuditEvent, domain.AuditEventFilter]
|
||||
metricSamples *memoryRepository[domain.MetricSample, domain.MetricSampleFilter]
|
||||
backups *memoryRepository[domain.BackupRecord, domain.BackupFilter]
|
||||
alerts *memoryRepository[domain.AlertRecord, domain.AlertFilter]
|
||||
pluginLifecycle *memoryRepository[domain.PluginLifecycleInstallation, domain.PluginLifecycleFilter]
|
||||
aiConfigDiffs *memoryRepository[domain.AIConfigDiffPreview, domain.AIConfigDiffFilter]
|
||||
bridgeCommands *memoryGameClientBridgeCommandRepository
|
||||
bridgeSnapshots *memoryGameClientBridgeSnapshotRepository
|
||||
bridgeStreams *memoryRepository[domain.GameClientBridgeSnapshotStream, domain.GameClientBridgeSnapshotStreamFilter]
|
||||
}
|
||||
|
||||
func NewMemoryStore() *MemoryStore {
|
||||
@@ -343,6 +401,28 @@ func NewMemoryStore() *MemoryStore {
|
||||
domain.CopyBackupRecord,
|
||||
matchBackup,
|
||||
),
|
||||
alerts: newMemoryRepository(
|
||||
func(alert domain.AlertRecord) string { return alert.ID },
|
||||
domain.CopyAlertRecord,
|
||||
matchAlert,
|
||||
),
|
||||
pluginLifecycle: newMemoryRepository(
|
||||
func(installation domain.PluginLifecycleInstallation) string { return installation.ID },
|
||||
domain.CopyPluginLifecycleInstallation,
|
||||
matchPluginLifecycle,
|
||||
),
|
||||
aiConfigDiffs: newMemoryRepository(
|
||||
func(preview domain.AIConfigDiffPreview) string { return preview.ID },
|
||||
domain.CopyAIConfigDiffPreview,
|
||||
matchAIConfigDiff,
|
||||
),
|
||||
bridgeCommands: newMemoryGameClientBridgeCommandRepository(),
|
||||
bridgeSnapshots: newMemoryGameClientBridgeSnapshotRepository(),
|
||||
bridgeStreams: newMemoryRepository(
|
||||
func(stream domain.GameClientBridgeSnapshotStream) string { return stream.ID },
|
||||
domain.CopyGameClientBridgeSnapshotStream,
|
||||
matchGameClientBridgeSnapshotStream,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,6 +461,20 @@ func (store *MemoryStore) LogStreams() LogStreamRepository { return store.
|
||||
func (store *MemoryStore) AuditEvents() AuditEventRepository { return store.auditEvents }
|
||||
func (store *MemoryStore) MetricSamples() MetricSampleRepository { return store.metricSamples }
|
||||
func (store *MemoryStore) Backups() BackupRepository { return store.backups }
|
||||
func (store *MemoryStore) Alerts() AlertRepository { return store.alerts }
|
||||
func (store *MemoryStore) PluginLifecycles() PluginLifecycleRepository {
|
||||
return store.pluginLifecycle
|
||||
}
|
||||
func (store *MemoryStore) AIConfigDiffs() AIConfigDiffRepository { return store.aiConfigDiffs }
|
||||
func (store *MemoryStore) GameClientBridgeCommands() GameClientBridgeCommandRepository {
|
||||
return store.bridgeCommands
|
||||
}
|
||||
func (store *MemoryStore) GameClientBridgeSnapshots() GameClientBridgeSnapshotRepository {
|
||||
return store.bridgeSnapshots
|
||||
}
|
||||
func (store *MemoryStore) GameClientBridgeSnapshotStreams() GameClientBridgeSnapshotStreamRepository {
|
||||
return store.bridgeStreams
|
||||
}
|
||||
|
||||
type memoryRepository[T any, F any] struct {
|
||||
mu sync.RWMutex
|
||||
@@ -632,3 +726,52 @@ func matchBackup(record domain.BackupRecord, filter domain.BackupFilter) bool {
|
||||
return (filter.ServerInstanceID == "" || record.ServerInstanceID == filter.ServerInstanceID) &&
|
||||
(filter.State == "" || record.State == filter.State)
|
||||
}
|
||||
|
||||
func matchAlert(alert domain.AlertRecord, filter domain.AlertFilter) bool {
|
||||
return (filter.State == "" || alert.State == filter.State) &&
|
||||
(filter.SourceKind == "" || alert.SourceKind == filter.SourceKind) &&
|
||||
(filter.SourceID == "" || alert.SourceID == filter.SourceID) &&
|
||||
(filter.Severity == "" || alert.Severity == filter.Severity)
|
||||
}
|
||||
|
||||
func matchPluginLifecycle(installation domain.PluginLifecycleInstallation, filter domain.PluginLifecycleFilter) bool {
|
||||
return (filter.PluginID == "" || installation.PluginID == filter.PluginID) &&
|
||||
(filter.ServerInstanceID == "" || installation.ServerInstanceID == filter.ServerInstanceID) &&
|
||||
(filter.CurrentState == "" || installation.CurrentState == filter.CurrentState)
|
||||
}
|
||||
|
||||
func matchAIConfigDiff(preview domain.AIConfigDiffPreview, filter domain.AIConfigDiffFilter) bool {
|
||||
return (filter.ServerInstanceID == "" || preview.ServerInstanceID == filter.ServerInstanceID) &&
|
||||
(filter.PluginID == "" || preview.PluginID == filter.PluginID) &&
|
||||
(filter.State == "" || preview.State == filter.State)
|
||||
}
|
||||
|
||||
func matchGameClientBridgeCommand(command domain.GameClientBridgeCommand, filter domain.GameClientBridgeCommandFilter) bool {
|
||||
return (filter.ServerInstanceID == "" || command.ServerInstanceID == filter.ServerInstanceID) &&
|
||||
(filter.PluginID == "" || command.PluginID == filter.PluginID) &&
|
||||
(filter.ProfileKey == "" || command.ProfileKey == filter.ProfileKey) &&
|
||||
(filter.State == "" || command.State == filter.State) &&
|
||||
(filter.RequesterID == "" || command.RequesterID == filter.RequesterID) &&
|
||||
(filter.CommandType == "" || command.CommandType == filter.CommandType) &&
|
||||
(filter.IdempotencyKey == "" || command.IdempotencyKey == filter.IdempotencyKey) &&
|
||||
(filter.ExpiresBefore.IsZero() || !command.ExpiresAt.After(filter.ExpiresBefore)) &&
|
||||
(filter.CompletedBefore.IsZero() || (!command.CompletedAt.IsZero() && !command.CompletedAt.After(filter.CompletedBefore)))
|
||||
}
|
||||
|
||||
func matchGameClientBridgeSnapshot(snapshot domain.GameClientBridgeSnapshot, filter domain.GameClientBridgeSnapshotFilter) bool {
|
||||
return (filter.ServerInstanceID == "" || snapshot.ServerInstanceID == filter.ServerInstanceID) &&
|
||||
(filter.PluginID == "" || snapshot.PluginID == filter.PluginID) &&
|
||||
(filter.ProfileKey == "" || snapshot.ProfileKey == filter.ProfileKey) &&
|
||||
(filter.Type == "" || snapshot.Type == filter.Type) &&
|
||||
(filter.StreamKey == "" || snapshot.StreamKey == filter.StreamKey) &&
|
||||
(filter.ObservedAfter.IsZero() || snapshot.ObservedAt.After(filter.ObservedAfter)) &&
|
||||
(filter.ExpiresBefore.IsZero() || !snapshot.ExpiresAt.After(filter.ExpiresBefore))
|
||||
}
|
||||
|
||||
func matchGameClientBridgeSnapshotStream(stream domain.GameClientBridgeSnapshotStream, filter domain.GameClientBridgeSnapshotStreamFilter) bool {
|
||||
return (filter.ServerInstanceID == "" || stream.ServerInstanceID == filter.ServerInstanceID) &&
|
||||
(filter.PluginID == "" || stream.PluginID == filter.PluginID) &&
|
||||
(filter.ProfileKey == "" || stream.ProfileKey == filter.ProfileKey) &&
|
||||
(filter.Type == "" || stream.Type == filter.Type) &&
|
||||
(filter.StreamKey == "" || stream.StreamKey == filter.StreamKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user