Documentation
¶
Overview ¶
Package openrails consumes independently acknowledged OpenRails notification events. Hosts own identity mapping, optional-event policy and scheduling. OpenRails produces facts; ContentKit owns the user inbox and its read state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsumeOptions ¶
ConsumeOptions bounds one worker call. Optional events default to skip+ACK; opt in to map them, applying any per-user preferences inside RecipientMapper.
type ConsumeResult ¶
type ConsumeResult struct{ Fetched, Delivered, Skipped, Acknowledged int }
ConsumeResult counts this attempt, including idempotent destination replays. Failed events remain pending. Acknowledged counts only a successful source ACK.
type Event ¶
type Event struct {
ID string `json:"id"`
MerchantID string `json:"merchant_id"`
CustomerID string `json:"customer_id"`
EventType string `json:"event_type"`
Data json.RawMessage `json:"data"`
CreatedAt time.Time `json:"created_at"`
ActionRequested bool `json:"action_requested,omitempty"`
Optional bool `json:"optional,omitempty"`
}
Event is an immutable source fact, not an OpenRails-owned inbox item. Kind strings and JSON fields remain extensible. ActionRequested is historical, independent of a destination's tracked workflow state.
type Options ¶
type Options struct {
// Name is the complete stable origin system; defaults to openrails:URL.
Name string
URL string
MerchantID string
// Consumer is stable across restarts and unique per destination within the
// authenticated application/merchant. Tokens can rotate without losing ACKs.
Consumer string
Client *http.Client
Token func(context.Context) (string, error)
}
Options binds one trusted OpenRails deployment, merchant and independent consumer. Token supplies a merchant-authorized application access token; Client may instead authenticate through its transport. URL precedes /v1.
type RecipientMapper ¶
RecipientMapper resolves the event's verified merchant/customer coordinates through host-owned account records. deliver=false deliberately skips the event and allows its ACK. An error keeps it pending for retry. Email equality alone must never establish the association. Future event kinds pass through.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source consumes the notification events of one configured merchant.
func New ¶
New validates configuration. Every HTTP request has a 15-second deadline. Redirects are refused to keep credentials on the configured deployment.
func (*Source) Consume ¶
func (s *Source) Consume(ctx context.Context, destination notify.Publisher, mapper RecipientMapper, opts ConsumeOptions) (ConsumeResult, error)
Consume publishes one bounded pending page, then ACKs only committed or explicitly skipped events. Each consumer has independent ACKs. A failed ACK safely replays destination publication; local read/dismiss state survives. One failed mapping/publication does not prevent other events in the page. The host owns scheduling and retries; there is no cursor or time watermark.