Documentation
¶
Overview ¶
mail.go demonstrates the platform/mail reference delivery flow.
Flow:
- Validate a well-formed Message.
- Send via a stub Mailer that succeeds on the first attempt.
- Use RetryPolicy + IsRetryable to implement transparent retry on transient failure, then verify the correct number of attempts.
- Verify that ErrRejected is not retried.
Command integration-example is the P2.6 Integration Exit Slice for the Keel platform.
It wires together all Phase 2 integration packages (storage, mail, queue, search) in a single realistic reference flow without requiring external services. All adapters run in-process using the local filesystem adapter, an in-memory mailer stub, an in-memory queue, and a mock search backend.
What this demonstrates end-to-end ¶
- storage.Upload: server-key generation, content validation, local adapter
- storage.Download: round-trip retrieval and body reading
- storage.AllowedTypesHook: restricting uploads to approved MIME types
- mail.Message.Validate: message validation before send
- mail.RetryMailer: transparent retry on transient failure
- queue.OutboxPublisher: DB-backed atomic staging via OutboxWriter
- queue.OutboxRelay: relay loop delivering staged messages to a broker
- search.Config.Validate: config validation with TLS enforcement
- search.NewClient: client bootstrap with auth header injection
- testkit.FakeClock: deterministic time for relay scheduling tests
Quick start ¶
go run ./cmd/integration-example
outbox.go demonstrates the platform/queue outbox reference flow.
Flow:
- Construct an in-memory OutboxStore.
- Stage two messages via OutboxPublisher (atomically with a DB transaction in a real service; here we simulate it with the in-memory store).
- Construct an OutboxRelay backed by an in-memory broker publisher.
- Run one relay tick and verify both messages were published.
- Verify MarkDelivered was called; IsPending returns false afterwards.
searchflow.go demonstrates the platform/search reference integration flow.
Flow:
- Validate a Config with HTTP endpoints (AllowHTTP=true, for local tests).
- Validate that HTTPS enforcement rejects non-HTTPS endpoints in production mode.
- Construct a search.Client and verify authentication header injection.
- Demonstrate retry logic via the search.DoWithRetry helper using a mock HTTP handler that fails twice then succeeds.
upload.go demonstrates the platform/storage reference upload flow.
Flow:
- Construct a local filesystem adapter (temp dir).
- Upload a plain-text document using storage.Upload (server-key generation).
- Download the object using storage.Download and verify content round-trip.
- Delete the object and confirm ErrNotFound on second delete.
- Demonstrate AllowedTypesHook rejecting a disallowed MIME type.
Click to show internal directories.
Click to hide internal directories.