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

Handing a Service to a transport listener. More...

#include <functional>
#include <memory>
#include <utility>
#include <absl/status/status.h>
#include "a11/concurrency/future.h"
#include "a11/service/service.h"
#include "a11/service/session.h"

Go to the source code of this file.

Namespaces

namespace  a11
 
namespace  a11::service
 

Functions

template<typename StreamT >
std::function< a11::Task(std::shared_ptr< StreamT >)> a11::service::AcceptInto (const std::shared_ptr< Service > &service, StreamMode mode=StreamMode::kAccept)
 A callback for any transport's on-stream hook, serving into service.
 

Detailed Description

Handing a Service to a transport listener.

Servers stay dumb on purpose. Every listener in a11/net takes its on-stream callback at construction – WebSocketWireServer::Create(OnWebSocketStream, options), HttpSseServer::Create(host, port, OnHttpSseConnect, options), WebRtcWireServer::Create(identity, signalling, on_stream, config) – so a hypothetical Service::Attach(server) would have to know every one of those option structs, which is the coupling a11::service::Service exists to remove.

What is needed instead is one adapter, and this is it.