Class CyclicSubscriptionHandlers

Class Documentation

class CyclicSubscriptionHandlers

HTTP handlers for cyclic subscription CRUD and SSE streaming.

Implements SOVD cyclic subscription endpoints:

  • POST /{entity}/cyclic-subscriptions - create subscription

  • GET /{entity}/cyclic-subscriptions - list subscriptions

  • GET /{entity}/cyclic-subscriptions/{id} - get subscription

  • PUT /{entity}/cyclic-subscriptions/{id} - update subscription

  • DELETE /{entity}/cyclic-subscriptions/{id} - delete subscription

  • GET /{entity}/cyclic-subscriptions/{id}/events - SSE stream

All 6 routes follow the PR-403 typed RouteRegistry convention:

http::Result<dto::TResponse> X(const http::TypedRequest & req [, dto::TBody body]);

The SSE event-stream route uses the reg.sse<> escape hatch and returns a Result<SseStream> factory; the framework drives the chunked content provider. The transport’s make_sse_stream builds the next_event closure. CRUD POST uses the attachments variant so it can override the status to 201 without re-introducing a httplib::Response & parameter.

Public Functions

CyclicSubscriptionHandlers(HandlerContext &ctx, SubscriptionManager &sub_mgr, ResourceSamplerRegistry &sampler_registry, TransportRegistry &transport_registry, int max_duration_sec)
http::Result<std::pair<dto::CyclicSubscription, http::ResponseAttachments>> post_subscription(const http::TypedRequest &req, dto::CyclicSubscriptionCreateRequest body)

POST /{entity}/cyclic-subscriptions - create subscription.

On success returns the new CyclicSubscription body with a 201 status override.

http::Result<dto::Collection<dto::CyclicSubscription>> get_subscriptions(const http::TypedRequest &req)

GET /{entity}/cyclic-subscriptions - list all subscriptions for entity.

http::Result<dto::CyclicSubscription> get_subscription(const http::TypedRequest &req)

GET /{entity}/cyclic-subscriptions/{id} - get single subscription.

http::Result<dto::CyclicSubscription> put_subscription(const http::TypedRequest &req, dto::CyclicSubscriptionUpdateRequest body)

PUT /{entity}/cyclic-subscriptions/{id} - update subscription.

http::Result<http::NoContent> del_subscription(const http::TypedRequest &req)

DELETE /{entity}/cyclic-subscriptions/{id} - delete subscription.

http::Result<http::SseStream> sse_subscription_events(const http::TypedRequest &req)

GET /{entity}/cyclic-subscriptions/{id}/events - SSE event stream.

Returns a SseStream whose next_event callback the framework drives via cpp-httplib’s chunked content provider. On validation failure the factory returns tl::unexpected(ErrorInfo) and the framework renders a SOVD GenericError.

Public Static Functions

static tl::expected<ParsedResourceUri, std::string> parse_resource_uri(const std::string &resource)

Parse resource URI to extract entity type, entity id, collection, and resource path.