A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
service.h File Reference

A service: what a peer can call, decoupled from where it listens. More...

#include <memory>
#include <string>
#include <string_view>
#include <vector>
#include <absl/status/status.h>
#include <absl/status/statusor.h>
#include <absl/time/time.h>
#include "a11/actions/registry.h"
#include "a11/concurrency/future.h"
#include "a11/data/types.h"
#include "a11/net/describe_endpoint.h"
#include "a11/net/wire_stream.h"
#include "a11/service/session.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  a11::service::ServiceOptions
 How a service treats the connections it accepts. More...
 
class  a11::service::Service
 A registry of actions, the sessions serving them, and their lifecycle. More...
 

Namespaces

namespace  a11
 
namespace  a11::service
 

Typedefs

using a11::service::OnServiceConnection = std::function< a11::Task(std::shared_ptr< Session >, std::shared_ptr< net::WireStream >)>
 Per-connection preparation, run before the session starts pumping.
 

Detailed Description

A service: what a peer can call, decoupled from where it listens.

A Session is connection-scoped, and a transport server is socket-scoped. Nothing sat between them, so every application wired the two together by hand – make a registry, make a session per accepted stream, attach, wait – and each copy of that glue was slightly different.

Service is that glue, named. It owns the action registry and the sessions built from it, and exposes exactly one join point (Serve) shaped to be a transport's on-stream callback. What follows from having it:

  • A service with no server. Hand it an in-process stream pair and it serves, which is what an embedded gateway is.
  • One service, several servers. A WebSocket listener, an SSE listener and a WebRTC peer can all call Serve on the same instance; sessions from all of them share one registry and one lifecycle.
  • Several services, one server. Servers produce streams and do not care who consumes them, so a path router in front of one listener can send /a11 to one service and /admin to another (see a11::net::HttpRouter).

Sockets, ports, TLS, and other transport concerns remain outside this class. Service never opens a connection; a11/service/serving.h adapts it to a listener.