Files
2026-05-07 10:16:46 +08:00

68 lines
2.7 KiB
Go

package integration
import (
"context"
"supply-intelligence/internal/domain"
)
// AccountStateReader defines the interface for reading account routing state
// from the supply-api repository layer
type AccountStateReader interface {
GetRoutingStateContext(ctx context.Context, accountID int64) (domain.AccountRoutingState, bool)
}
// CandidateStore defines the interface for persisting model candidates
type CandidateStore interface {
GetDiscoveryCandidateByIDContext(ctx context.Context, candidateID string) (domain.DiscoveryCandidate, bool)
FindDiscoveryCandidateContext(ctx context.Context, accountID int64, platform, model string) (domain.DiscoveryCandidate, bool)
UpsertDiscoveryCandidateContext(ctx context.Context, candidate domain.DiscoveryCandidate) domain.DiscoveryCandidate
ListDiscoveryCandidatesContext(ctx context.Context, status domain.DiscoveryCandidateStatus) []domain.DiscoveryCandidate
}
// PackageEventStore defines the interface for persisting package change events
type PackageEventStore interface {
AppendPackageEventContext(ctx context.Context, evt domain.PackageChangeEvent) (domain.PackageChangeEvent, error)
ListPackageEventsAfter(cursor string) ([]domain.PackageChangeEvent, string)
AckPackageEvent(eventID, consumer string, result domain.GatewayAckResult, detail string, ackedAt interface{}) (domain.PackageChangeEvent, error)
}
// ProbeLogStore defines the interface for persisting probe execution logs
type ProbeLogStore interface {
AppendProbeLog(ctx context.Context, log ProbeExecutionLog) error
ListProbeLogsByAccount(ctx context.Context, accountID int64, limit int) ([]ProbeExecutionLog, error)
}
// ProbeExecutionLog represents a single probe execution record
type ProbeExecutionLog struct {
LogID int64
AccountID int64
Platform string
ProbeResult domain.ProbeClassification
FailureClass string
HTTPStatus int
LatencyMs int
RiskScore int
EvaluatedTransition string
ExecutedAt interface{} // time.Time or string
RequestID string
Version int64
}
// NewAccountStateAdapter creates an adapter that connects to supply-api's account store
// For now, returns nil — actual implementation requires supply-api repo access
func NewAccountStateAdapter(repo interface{}) *AccountStateAdapter {
return &AccountStateAdapter{repo: repo}
}
// AccountStateAdapter implements AccountStateReader over supply-api repository
type AccountStateAdapter struct {
repo interface{}
}
func (a *AccountStateAdapter) GetRoutingStateContext(ctx context.Context, accountID int64) (domain.AccountRoutingState, bool) {
// TODO: implement when supply-api integration is ready
// This will call into supply-api's account repository
return domain.AccountRoutingState{}, false
}