31#ifndef A11_SERVICE_SERVING_H_
32#define A11_SERVICE_SERVING_H_
38#include <absl/status/status.h>
60template <
typename StreamT>
62 const std::shared_ptr<Service>& service,
64 std::weak_ptr<Service> weak = service;
65 return [weak = std::move(weak),
66 mode](std::shared_ptr<StreamT> stream) ->
a11::Task {
67 std::shared_ptr<Service> resolved = weak.lock();
68 if (resolved ==
nullptr) {
70 "The service this server was bound to is gone"));
72 return resolved->Serve(std::move(stream), mode);
Completion values used by every asynchronous A11 operation.
StreamMode
Whether this side starts (kStart) or accepts (kAccept) a stream during its startup handshake.
Definition session.h:112
std::function< a11::Task(std::shared_ptr< StreamT >)> AcceptInto(const std::shared_ptr< Service > &service, StreamMode mode=StreamMode::kAccept)
A callback for any transport's on-stream hook, serving into service.
Definition serving.h:61
Task FailedTask(absl::Status status)
Return an already-failed Task.
Definition future.h:419
Future< Unit > Task
Asynchronous operation whose only successful result is completion itself.
Definition future.h:411
A service: what a peer can call, decoupled from where it listens.
A11's connection-scoped runtime: the Session.