Expand description
§socle
Opinionated axum service bootstrap: telemetry, database, rate limiting, and shutdown in one builder. Public open-source facade extracted from an internal service kit.
§Recommended middleware ordering
RequestIdLayer → auth (placeholder) → OrgIsolationLayer → rate-limit → audit → handleruse socle::{ServiceBootstrap, BootstrapCtx, Result};
use axum::{Router, routing::get};
ServiceBootstrap::new("billing-service")
.with_telemetry()
.with_database("postgres://localhost/billing")
.with_router(|_ctx: &BootstrapCtx| Router::new().route("/health", get(|| async { "ok" })))
.serve("0.0.0.0:8080")
.awaitRe-exports§
pub use audit::AuditAnnotation;pub use audit::AuditAnnotationSlot;pub use audit::AuditEvent;pub use audit::AuditFilter;pub use audit::AuditLayer;pub use audit::AuditService;pub use audit::AuditSink;pub use audit::AuditSinkError;pub use audit::TracingAuditSink;pub use etag::check_if_match;pub use etag::etag_from_updated_at;pub use org_isolation::OrgContextExtractor;pub use org_isolation::OrgContextSource;pub use org_isolation::OrgIsolationLayer;pub use org_isolation::OrgIsolationService;pub use org_policy::AncestryOrgPolicy;pub use org_policy::OrgPolicy;pub use extract::Valid;pub use ports::auth::AuthProvider;pub use ports::health::ReadinessCheckFn;pub use ports::rate_limit::RateLimitProvider;pub use ports::telemetry::BasicTelemetryProvider;pub use ports::telemetry::TelemetryProvider;
Modules§
- audit
- Audit capture Tower layer with pluggable sinks.
- etag
- ETag / conditional-request helpers.
- extract
- Axum extractors provided by socle.
- org_
isolation - Org isolation extractor and enforcement middleware.
- org_
policy - Org-scoped access policy trait and default ancestry implementation.
- pagination
- Re-exports of api-bones pagination and query types.
- ports
- Ports — trait definitions the bootstrap application depends on.
- reexports
- Re-exports of the underlying crates.
- testing
- Test helpers shared across services built on socle.
Macros§
- assert_
span - Assert that at least one span in
$spanshas the givenname.
Structs§
- ApiError
- RFC 9457 Problem Details error response.
- ApiResponse
- Generic API response envelope.
- ApiResponse
Builder - Builder for
ApiResponse. - Audit
Info - Audit metadata embedded in API resource structs.
- Bootstrap
Config - Layered configuration consumed by
crate::ServiceBootstrap::from_config. - Bootstrap
Ctx - Context handed to the user’s router builder closure.
- Bulk
Request - A batch of items to be processed in a single API call.
- Bulk
Response - The response to a
BulkRequest, containing per-item results. - Correlation
Id - An opaque cross-service correlation identifier, transported via
X-Correlation-Id. - Cors
Config - Structured CORS configuration.
- Cursor
- URL-safe base64 cursor codec.
- Cursor
Paginated Response - Cursor-based paginated response envelope (PLATFORM-003).
- Cursor
Pagination - Cursor-based pagination metadata (PLATFORM-003).
- Cursor
Pagination Params - Query parameters for cursor-based list endpoints.
- ETag
- An HTTP entity tag as defined by RFC 7232 §2.3.
- Handler
Error - Error type for axum handlers. Wraps
ApiErrorand implementsIntoResponse. - Idempotency
Key - A validated idempotency key for safe POST/PATCH retry semantics.
- Keyset
Paginated Response - A page of results from a keyset-paginated endpoint.
- Keyset
Pagination Params - Query parameters for keyset (seek-based) pagination.
- Link
- A single HATEOAS link with a relation type, target URL, and optional HTTP method hint.
- Links
- An ordered collection of
Linkvalues. - OrgId
- A UUID v4 tenant identifier, typically propagated via the
X-Org-IdHTTP header. - OrgPath
- An ordered org-path (root to self, inclusive), transported via
X-Org-Path. - Organization
Context - Platform context bundle — org, principal, request-id, roles, org-path, attestation.
- Paginated
Response - Offset-based paginated response envelope with a flat shape.
- Pagination
Params - Query parameters for offset-based list endpoints.
- Problem
Json - RFC 7807 / 9457 Problem Details response body with optional extension members.
- Rate
Limit Backend - In-process GCRA rate limiter configuration.
- Rate
Limit Config - Rate-limiting configuration for
BootstrapConfig. - Rate
Limit Info - Structured rate-limit metadata matching
X-RateLimit-*headers. - Request
Id - A UUID v4 request identifier, typically propagated via the
X-Request-IdHTTP header. - Response
Meta - Metadata attached to every
ApiResponse. - Service
Bootstrap - Builder for a microservice runtime.
- Slug
- A validated, URL-friendly identifier.
- Sort
Params - Query parameters for sorting a collection endpoint.
- Unconstrained
Response - Explicit opt-out from RFC-oriented response enforcement.
- Validation
Error - A single field-level validation error, used in
ApiError::errors.
Enums§
- Bulk
Item Result - The outcome of processing a single item in a
BulkRequest. - Correlation
IdError - Error returned when constructing a
CorrelationIdfrom a string fails. - Cursor
Error - Error returned when a cursor cannot be decoded or its signature is invalid.
- Error
- Errors that can occur while bootstrapping or running a service.
- Error
Code - Machine-readable error code included in every API error response.
- Idempotency
KeyError - Errors that can occur when constructing an
IdempotencyKey. - IfMatch
- Models the
If-Matchconditional request header (RFC 7232 §3.1). - IfNone
Match - Models the
If-None-Matchconditional request header (RFC 7232 §3.2). - LogFormat
- Logging output format.
- Rate
Limit Extractor - Determines what gets rate-limited.
- Rate
Limit Kind - Backend store selection for
RateLimitConfig. - Slug
Error - Errors that can occur when constructing a
Slug. - Sort
Direction - Sort order for list endpoints.
Functions§
- created
- created_
at - created_
under - etagged
- listed
- listed_
page - Paginate a fully-loaded
Vec<T>, map each item toU, and return aHandlerListResponse. - ok
Type Aliases§
- Created
AtResponse - Return type for handlers that create a resource with a
Locationheader (201 Created). - Created
Response - Return type for handlers that create a resource (201 Created).
- Etagged
Handler Response - Return type for read/update handlers that carry an
ETagresponse header (200 OK). - Handler
List Response - Return type for handlers that return a paginated collection (200 OK).
- Handler
Response - Return type for handlers that return a single resource (200 OK).
- Request
IdParse Error - Backwards-compatible alias — prefer
RequestIdError. - Resource
Id - RFC 4122 UUID v4 resource identifier.
- Result
- Result alias used throughout
socle. - Shutdown
Hook Fn - Async drain callback registered via
ServiceBootstrap::with_shutdown_hook. - Timestamp
- RFC 3339 timestamp alias for API responses.