thread-master/apps/backend/internal/module/studio/domain/repository.go

48 lines
2.3 KiB
Go
Raw Permalink Normal View History

2026-07-13 01:15:30 +00:00
package domain
import "context"
// Repository persists studio domain entities (memory or mon).
type Repository interface {
// Persona
SavePersona(ctx context.Context, p *Persona) error
GetPersona(ctx context.Context, id string) (*Persona, error)
ListPersonas(ctx context.Context, ownerUID int64) ([]*Persona, error)
DeletePersona(ctx context.Context, id string) error
GetActivePersonaID(ctx context.Context, ownerUID int64) (string, error)
SetActivePersonaID(ctx context.Context, ownerUID int64, personaID string) error
// Play
SavePlay(ctx context.Context, p *Play) error
GetPlay(ctx context.Context, id string) (*Play, error)
ListPlays(ctx context.Context, ownerUID int64) ([]*Play, error)
DeletePlay(ctx context.Context, id string) error
// Outbox
SaveOutbox(ctx context.Context, b *OutboxBundle) error
GetOutbox(ctx context.Context, id string) (*OutboxBundle, error)
ListOutbox(ctx context.Context, ownerUID int64) ([]*OutboxBundle, error)
DeleteOutbox(ctx context.Context, id string) error
ListAllOutbox(ctx context.Context) ([]*OutboxBundle, error)
2026-07-15 15:23:59 +00:00
// ClaimOutboxStep atomically moves one due scheduled (or expired publishing)
// step to publishing and assigns its fencing lease.
ClaimOutboxStep(ctx context.Context, bundleID, stepID, leaseOwner string, now, leaseExpiresAt int64) (*OutboxBundle, error)
RenewOutboxStepLease(ctx context.Context, bundleID, stepID, leaseOwner string, now, leaseExpiresAt int64) error
FinishOutboxStep(ctx context.Context, bundleID, stepID, leaseOwner string, step *OutboxStep, now int64) error
RecomputeOutboxStatus(ctx context.Context, bundleID string, now int64) error
RetryOutboxStep(ctx context.Context, bundleID, stepID string, now int64) (*OutboxBundle, error)
2026-07-13 01:15:30 +00:00
// OwnPosts
SaveOwnPost(ctx context.Context, p *OwnPost) error
GetOwnPost(ctx context.Context, id string) (*OwnPost, error)
ListOwnPosts(ctx context.Context, ownerUID int64, accountID string) ([]*OwnPost, error)
DeleteOwnPost(ctx context.Context, id string) error
GetSyncMeta(ctx context.Context, ownerUID int64) (*SyncMeta, error)
SetSyncMeta(ctx context.Context, m *SyncMeta) error
// Mentions
SaveMention(ctx context.Context, m *Mention) error
GetMention(ctx context.Context, id string) (*Mention, error)
ListMentions(ctx context.Context, ownerUID int64, accountID string) ([]*Mention, error)
}