conduit 0.6.0
Modern C++23 header-only event-dispatching / event-transport library
Loading...
Searching...
No Matches
transport.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <conduit/bus.hpp>
10#include <conduit/listener.hpp>
12#include <conduit/transport.hpp>
13
14#include <chrono>
15#include <cstdint>
16#include <memory>
17#include <optional>
18#include <string>
19
20namespace conduit::amqp {
21
24public:
25 using conduit::TransportError::TransportError;
26};
27
29enum class Format : std::uint8_t { Json, Cbor };
30
31struct TlsConfig {
32 std::string ca_file;
33 std::optional<std::string> cert_file;
34 std::optional<std::string> key_file;
35 bool verify_peer = true;
36};
37
38struct Config {
39 std::string url; // "amqp://user:pass@host:5672/vhost" or "amqps://..."
40 std::string connection_name; // empty -> "conduit-<ulid>"
41 std::optional<TlsConfig> tls; // populated when scheme is amqps://
42
43 // Topology (defaults: topic exchange + auto queue bound on routing_key).
44 std::string exchange = "conduit";
45 std::string exchange_type = "topic"; // "topic" | "direct" | "fanout"
46 bool exchange_durable = true;
48
51 std::string routing_key = "conduit.envelope";
52 std::string queue; // empty -> server-generated, exclusive, auto-delete
53 bool queue_durable = false;
54 bool queue_exclusive = true;
55 bool queue_auto_delete = true;
56
57 bool persistent = false; // delivery_mode=2 on publish if true
58 bool publisher_confirms = false; // enable confirm.select; required for RequireAck
59
60 std::chrono::seconds connect_timeout{10};
61 std::chrono::seconds heartbeat{30};
62
65};
66
73public:
74 explicit Transport(Config config, std::shared_ptr<EventRegistry> registry = {});
75
76 Transport(const Transport&) = delete;
77 Transport& operator=(const Transport&) = delete;
78 Transport(Transport&&) = delete;
80
81 ~Transport() override;
82
83 [[nodiscard]] TransportScope scope() const noexcept override {
85 }
86
87 void attach_with_sink(Bus& bus, InboundSink sink) override;
88 void detach() noexcept override;
89
90 void dispatch(const EventEnvelopeView& v) override;
91 void flush() override;
92
93 [[nodiscard]] bool is_connected() const noexcept;
94
95private:
96 struct Impl;
97 std::unique_ptr<Impl> impl_;
98};
99
100} // namespace conduit::amqp
Bus — owns transports, middleware, listeners; dispatches envelopes.
Definition bus.hpp:58
Polymorphic envelope cell.
Definition envelope.hpp:62
Operational/runtime failure inside a transport adapter (connect, subscribe, publish,...
Definition exception.hpp:48
Definition transport.hpp:30
Bus * bus() const noexcept
Definition transport.hpp:68
Operational/runtime failure inside the AMQP transport adapter.
Definition transport.hpp:23
AMQP pipe — one instance binds to a single AMQP routing key and carries traffic in both directions: o...
Definition transport.hpp:72
Transport & operator=(const Transport &)=delete
bool is_connected() const noexcept
void detach() noexcept override
Transport(const Transport &)=delete
TransportScope scope() const noexcept override
Definition transport.hpp:83
void attach_with_sink(Bus &bus, InboundSink sink) override
Attach to a bus using a caller-supplied inbound sink.
Transport(Transport &&)=delete
void dispatch(const EventEnvelopeView &v) override
void flush() override
Transport(Config config, std::shared_ptr< EventRegistry > registry={})
Transport & operator=(Transport &&)=delete
EventEnvelope — a parcel cell carrying conduit's envelope metadata plus a polymorphic payload cell.
Root exception hierarchy for the conduit library.
Transport interface and the local/remote scope enum used for flag-based filtering.
Listener / Subscription / Subscriber primitives.
Definition transport.hpp:20
Format
Wire format used for encoded envelopes.
Definition transport.hpp:29
std::function< void(const EventEnvelopeView &)> InboundSink
Callable installed on a Transport at attach time that receives inbound envelopes the transport pulled...
Definition transport.hpp:28
TransportScope
Distinguishes in-process transports from off-machine ones.
Definition transport.hpp:21
Thin EventRegistry wrapper around parcel::ParcelRegistry, plus envelope encode/decode helpers for JSO...
Definition transport.hpp:38
bool exchange_auto_delete
Definition transport.hpp:47
std::optional< TlsConfig > tls
Definition transport.hpp:41
bool exchange_durable
Definition transport.hpp:46
std::string routing_key
Outbound publish routing key AND inbound binding pattern.
Definition transport.hpp:51
std::chrono::seconds connect_timeout
Definition transport.hpp:60
bool queue_durable
Definition transport.hpp:53
std::string url
Definition transport.hpp:39
bool queue_exclusive
Definition transport.hpp:54
std::chrono::seconds heartbeat
Definition transport.hpp:61
bool persistent
Definition transport.hpp:57
Format format
Wire format used for both outbound publishes and inbound decoding.
Definition transport.hpp:64
std::string connection_name
Definition transport.hpp:40
bool queue_auto_delete
Definition transport.hpp:55
bool publisher_confirms
Definition transport.hpp:58
std::string exchange_type
Definition transport.hpp:45
std::string exchange
Definition transport.hpp:44
std::string queue
Definition transport.hpp:52
Definition transport.hpp:31
std::string ca_file
Definition transport.hpp:32
std::optional< std::string > key_file
Definition transport.hpp:34
std::optional< std::string > cert_file
Definition transport.hpp:33
bool verify_peer
Definition transport.hpp:35