Documentation
¶
Index ¶
- Constants
- type Deliverer
- type Delivery
- type DeliveryStore
- func (s *DeliveryStore) CreateDelivery(ctx context.Context, messageID string, lastError string) (*Delivery, error)
- func (s *DeliveryStore) DeleteExpiredDeliveries(ctx context.Context) (int64, error)
- func (s *DeliveryStore) GetPendingDeliveries(ctx context.Context, limit int) ([]Delivery, error)
- func (s *DeliveryStore) MarkAttemptFailed(ctx context.Context, messageID, errMsg string, nextRetry time.Time) error
- func (s *DeliveryStore) MarkDelivered(ctx context.Context, messageID string) error
- func (s *DeliveryStore) MarkFailed(ctx context.Context, messageID, errMsg string) error
- type Payload
- type PersistentDeliverer
- type RetryWorker
Constants ¶
View Source
const DeliveryTTL = 48 * time.Hour
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deliverer ¶
type Deliverer struct {
// contains filtered or unexported fields
}
func NewDeliverer ¶
func (*Deliverer) DeliverHTTP ¶
func (d *Deliverer) DeliverHTTP(ctx context.Context, agent *identity.AgentIdentity, p Payload) error
DeliverHTTP performs the actual HTTP POST to the agent's webhook URL.
type Delivery ¶
type Delivery struct {
AgentID string `json:"agent_id"`
MessageID string `json:"message_id"`
Status string `json:"status"`
Attempts int `json:"attempts"`
MaxAttempts int `json:"max_attempts"`
LastError string `json:"last_error"`
LastAttemptAt *time.Time `json:"last_attempt_at,omitempty"`
NextRetryAt time.Time `json:"next_retry_at"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
type DeliveryStore ¶
type DeliveryStore struct {
// contains filtered or unexported fields
}
func NewDeliveryStore ¶
func NewDeliveryStore(pool *pgxpool.Pool) *DeliveryStore
func (*DeliveryStore) CreateDelivery ¶
func (*DeliveryStore) DeleteExpiredDeliveries ¶
func (s *DeliveryStore) DeleteExpiredDeliveries(ctx context.Context) (int64, error)
func (*DeliveryStore) GetPendingDeliveries ¶
func (*DeliveryStore) MarkAttemptFailed ¶
func (*DeliveryStore) MarkDelivered ¶
func (s *DeliveryStore) MarkDelivered(ctx context.Context, messageID string) error
func (*DeliveryStore) MarkFailed ¶
func (s *DeliveryStore) MarkFailed(ctx context.Context, messageID, errMsg string) error
type Payload ¶
type Payload struct {
MessageID string `json:"message_id,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
From string `json:"from"`
To string `json:"to"`
RawMessage []byte `json:"raw_message"`
AuthHeaders map[string]string `json:"auth_headers"`
ReceivedAt time.Time `json:"received_at"`
}
type PersistentDeliverer ¶
type PersistentDeliverer struct {
// contains filtered or unexported fields
}
PersistentDeliverer wraps Deliverer with DB persistence for retry support.
func NewPersistentDeliverer ¶
func NewPersistentDeliverer(deliverer *Deliverer, store *DeliveryStore) *PersistentDeliverer
func (*PersistentDeliverer) Deliver ¶
func (pd *PersistentDeliverer) Deliver(ctx context.Context, agent *identity.AgentIdentity, p Payload) error
Deliver attempts delivery and persists the result. On failure, the delivery is queued for retry. Always returns nil — the message is safely persisted. Use this for SMTP inbound where the message is already accepted.
func (*PersistentDeliverer) DeliverSync ¶
func (pd *PersistentDeliverer) DeliverSync(ctx context.Context, agent *identity.AgentIdentity, p Payload) error
DeliverSync attempts delivery, persists the result, and returns the error. Use this for API-initiated sends where the caller needs immediate feedback.
type RetryWorker ¶
type RetryWorker struct {
// contains filtered or unexported fields
}
func NewRetryWorker ¶
func NewRetryWorker(deliveryStore *DeliveryStore, deliverer *Deliverer, identityStore *identity.Store) *RetryWorker
func (*RetryWorker) Start ¶
func (w *RetryWorker) Start(ctx context.Context)
Click to show internal directories.
Click to hide internal directories.