integration-example

command
v0.0.0-...-bccdb8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

mail.go demonstrates the platform/mail reference delivery flow.

Flow:

  1. Validate a well-formed Message.
  2. Send via a stub Mailer that succeeds on the first attempt.
  3. Use RetryPolicy + IsRetryable to implement transparent retry on transient failure, then verify the correct number of attempts.
  4. 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:

  1. Construct an in-memory OutboxStore.
  2. Stage two messages via OutboxPublisher (atomically with a DB transaction in a real service; here we simulate it with the in-memory store).
  3. Construct an OutboxRelay backed by an in-memory broker publisher.
  4. Run one relay tick and verify both messages were published.
  5. Verify MarkDelivered was called; IsPending returns false afterwards.

searchflow.go demonstrates the platform/search reference integration flow.

Flow:

  1. Validate a Config with HTTP endpoints (AllowHTTP=true, for local tests).
  2. Validate that HTTPS enforcement rejects non-HTTPS endpoints in production mode.
  3. Construct a search.Client and verify authentication header injection.
  4. 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:

  1. Construct a local filesystem adapter (temp dir).
  2. Upload a plain-text document using storage.Upload (server-key generation).
  3. Download the object using storage.Download and verify content round-trip.
  4. Delete the object and confirm ErrNotFound on second delete.
  5. Demonstrate AllowedTypesHook rejecting a disallowed MIME type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL