Documentation
¶
Overview ¶
Package engine contains the subscription status core.
Index ¶
- func Aggregate(verdicts []domain.SourceVerdict, banned bool) (domain.EffectiveStatus, domain.AccessDecision)
- type AlertStore
- type AuditStore
- type Effect
- type Engine
- func (e *Engine) ApplyObservations(ctx context.Context, repos Store, tgID int64, verdicts []domain.SourceVerdict) error
- func (e *Engine) HandleEvent(ctx context.Context, repos Store, event domain.SubscriptionEvent) ([]Effect, error)
- func (e *Engine) LiveSnapshot(ctx context.Context, repos Store, tgID int64) (Snapshot, error)
- func (e *Engine) PersistedDecision(ctx context.Context, repos Store, tgID int64) (domain.AccessDecision, error)
- func (e *Engine) RecomputeAccess(ctx context.Context, repos Store, tgID int64) ([]Effect, error)
- func (e *Engine) RevokeNow(ctx context.Context, repos Store, tgID int64, reason string) ([]Effect, error)
- type GrantStore
- type KeyedMutex
- type MemberChecker
- type Option
- type OutboxStore
- type RevocationConfig
- type RevocationStore
- type Snapshot
- type Store
- type SubscriptionSource
- type SubscriptionStore
- type UserStore
- type WhitelistStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶
func Aggregate( verdicts []domain.SourceVerdict, banned bool, ) (domain.EffectiveStatus, domain.AccessDecision)
Aggregate merges source verdicts into an effective access decision.
Types ¶
type AlertStore ¶
AlertStore is the operational alert surface needed by revocation.
type AuditStore ¶
type AuditStore interface {
Append(ctx context.Context, e store.AuditEntry) error
}
AuditStore is the audit repository surface needed by the engine.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine applies subscription events and computes access status.
func New ¶
func New(sources []SubscriptionSource, opts ...Option) *Engine
New returns a status engine.
func (*Engine) ApplyObservations ¶
func (e *Engine) ApplyObservations( ctx context.Context, repos Store, tgID int64, verdicts []domain.SourceVerdict, ) error
ApplyObservations persists live source observations inside handleTx.
func (*Engine) HandleEvent ¶
func (e *Engine) HandleEvent( ctx context.Context, repos Store, event domain.SubscriptionEvent, ) ([]Effect, error)
HandleEvent applies one normalized subscription event inside handleTx.
func (*Engine) LiveSnapshot ¶
LiveSnapshot collects source verdicts outside handleTx and aggregates them.
func (*Engine) PersistedDecision ¶
func (e *Engine) PersistedDecision( ctx context.Context, repos Store, tgID int64, ) (domain.AccessDecision, error)
PersistedDecision computes access from local state without network probes.
func (*Engine) RecomputeAccess ¶
RecomputeAccess re-evaluates durable local access state after callers have persisted fresh observations.
type GrantStore ¶
type GrantStore interface {
ListEligibleForRevoke(ctx context.Context, tgID int64) ([]domain.AccessGrant, error)
Revoke(ctx context.Context, tgID int64, resource domain.Resource, reason string) (bool, error)
}
GrantStore is the access grant surface needed by revocation.
type KeyedMutex ¶
type KeyedMutex struct {
// contains filtered or unexported fields
}
KeyedMutex serializes work by Telegram user ID.
func NewKeyedMutex ¶
func NewKeyedMutex() *KeyedMutex
NewKeyedMutex returns an empty process-wide keyed mutex.
func (*KeyedMutex) Lock ¶
func (m *KeyedMutex) Lock(key int64) func()
Lock locks one key and returns an unlock function.
type MemberChecker ¶
type MemberChecker interface {
GetChatMember(
ctx context.Context,
resource domain.Resource,
tgID int64,
) (*models.ChatMember, error)
}
MemberChecker reads live Telegram membership for protection checks.
type Option ¶
type Option func(*Engine)
Option configures Engine.
func WithRevocationConfig ¶
func WithRevocationConfig(cfg RevocationConfig) Option
WithRevocationConfig sets expiry-mode behavior for recomputeAccess.
type OutboxStore ¶
type OutboxStore interface {
Enqueue(
ctx context.Context,
input store.AccessActionInput,
) (domain.AccessAction, bool, error)
}
OutboxStore is the durable Telegram action surface needed by revocation.
type RevocationConfig ¶
RevocationConfig controls expiry behavior.
type RevocationStore ¶
type RevocationStore interface {
CreateIfAbsent(ctx context.Context, p domain.PendingRevocation) (bool, error)
Get(ctx context.Context, tgID int64) (domain.PendingRevocation, bool, error)
Delete(ctx context.Context, tgID int64) error
MarkNotified(ctx context.Context, tgID int64) error
}
RevocationStore is the pending-revocation surface needed by the engine.
type Snapshot ¶
type Snapshot struct {
TGID int64
Verdicts []domain.SourceVerdict
Decision domain.AccessDecision
}
Snapshot is a live, pre-transaction status snapshot.
type Store ¶
type Store struct {
Users UserStore
Subscriptions SubscriptionStore
Audit AuditStore
Revocations RevocationStore
Whitelist WhitelistStore
Grants GrantStore
Outbox OutboxStore
Alerts AlertStore
Members MemberChecker
// OperatorLog, when set, receives durable operator events emitted in the
// caller's transaction. It is optional: a nil writer disables the feed.
OperatorLog *operatorlog.Writer
}
Store is the narrow repository bundle used by engine operations.
type SubscriptionSource ¶
type SubscriptionSource interface {
Platform() domain.Platform
Verdict(ctx context.Context, tgID int64) (domain.SourceVerdict, error)
}
SubscriptionSource is the consumer-side source interface.
type SubscriptionStore ¶
type SubscriptionStore interface {
UpsertActive(ctx context.Context, s domain.Subscription) (int64, error)
ExpireActive(
ctx context.Context,
tgID int64,
platform domain.Platform,
endedAt time.Time,
signal string,
) (bool, error)
GetActive(
ctx context.Context,
tgID int64,
platform domain.Platform,
) (domain.Subscription, bool, error)
ListActiveByUser(ctx context.Context, tgID int64) ([]domain.Subscription, error)
}
SubscriptionStore is the subscription repository surface needed by the engine.