Documentation
¶
Overview ¶
Package delivery contains the pure delivery state machine. It performs no I/O; the host supplies a plan.DeliverySink and persists records.
Index ¶
- Variables
- func CanTransition(from, to State) bool
- func ValidateTransition(from, to State) error
- type Manager
- func (m *Manager) Cleanup(ctx context.Context, id int64) (*Record, error)
- func (m *Manager) Deliver(ctx context.Context, rec *Record) (*Record, error)
- func (m *Manager) Fail(ctx context.Context, id int64, msg string) (*Record, error)
- func (m *Manager) MarkRegistered(ctx context.Context, id int64) (*Record, error)
- func (m *Manager) Verify(ctx context.Context, id int64) (*Record, error)
- type MemoryStore
- func (m *MemoryStore) Create(_ context.Context, rec *Record) (int64, error)
- func (m *MemoryStore) Get(_ context.Context, id int64) (*Record, error)
- func (m *MemoryStore) List(_ context.Context, projectID int64, limit int) ([]*Record, error)
- func (m *MemoryStore) Update(_ context.Context, rec *Record) error
- type Record
- type State
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("delivery record not found")
Functions ¶
func CanTransition ¶
CanTransition reports whether the state machine allows from -> to.
func ValidateTransition ¶
Types ¶
type Manager ¶
type Manager struct {
Store Store
Sink plan.DeliverySink
Verifier plan.Verifier
CleanupSink plan.CleanupSink
}
Manager is the host-agnostic delivery state machine. It requires a Store and a host-provided DeliverySink; it ships no uploader/executor.
func NewManager ¶
func NewManager(store Store, sink plan.DeliverySink) *Manager
func (*Manager) Deliver ¶
Deliver creates a pending record, invokes the host sink, and advances to delivered/failed.
func (*Manager) MarkRegistered ¶
MarkRegistered advances verified -> registered (the host has created a session after verification).
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is the reference Store implementation.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
type Record ¶
type Record struct {
ID int64
ProjectID int64
TaskID string
State State
Plan plan.DeliveryPlan
Result *plan.DeliveryResult
Message string
// Host metadata (mapped by the host Store).
PayloadPath string
UploadTranscript string
UploadTrafficID string
VerifyOutput string
VerifyTrafficID string
Error string
CreatedBy string
Remark string
Variant string
ConnectionID *int64
CleanedAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
Record is a host-persisted delivery record. The host owns storage; this struct is only the shared shape.
type Store ¶
type Store interface {
Create(ctx context.Context, rec *Record) (int64, error)
Update(ctx context.Context, rec *Record) error
Get(ctx context.Context, id int64) (*Record, error)
List(ctx context.Context, projectID int64, limit int) ([]*Record, error)
}
Store is the persistence contract. The reference implementation is MemoryStore; a host may implement PostgreSQL/MySQL/etc. The contract tests should run against MemoryStore first.