Tracking issue for cpp-RCP conformance against RELAY spec v0.2 §18.2.
relay namespace definitions
RELAY spec §18.2 requires these types in the relay:: namespace. cpp-RCP currently has analogues in rcp::.
relay::Context
cpp-RCP has rcp::Context with the correct API. Declare the alias:
```cpp
namespace relay { using Context = rcp::Context; }
```
Or move the type to relay:: and alias in rcp::.
relay::Channel
cpp-RCP has rcp::StatusChannel. The spec requires a generic relay::Channel<T>:
```cpp
namespace relay {
template
class Channel {
public:
explicit Channel(std::size_t capacity);
bool push(T value);
std::optional recv();
std::optional try_recv();
void close() noexcept;
bool is_closed() const noexcept;
};
} // namespace relay
```
Then alias: namespace rcp { using StatusChannel = relay::Channel<Status>; }
relay::SubscriberOptions
```cpp
namespace relay {
enum class BackPressurePolicy { drop_newest = 0, drop_oldest = 1, block = 2 };
struct SubscriberOptions {
std::size_t channel_depth = 64;
BackPressurePolicy back_pressure = BackPressurePolicy::drop_newest;
};
} // namespace relay
```
relay::Node and relay::Caller
```cpp
namespace relay {
class Node {
public:
virtual Protocol protocol() const noexcept = 0;
virtual std::error_code send(Context ctx, const Message& msg) = 0;
virtual std::pair<Channel, std::error_code>
subscribe(SubscriberOptions opts = {}) = 0;
virtual std::error_code close() noexcept = 0;
virtual ~Node() = default;
};
class Caller : public Node {
public:
virtual std::pair<Message, std::error_code>
call(Context ctx, const Message& req) = 0;
};
} // namespace relay
```
relay::Errc error category (§18.2)
```cpp
namespace relay {
enum class Errc { closed, not_connected, timeout, payload_too_large };
} // namespace relay
// Registered as std::error_category "relay"
```
rcp::Errc values MUST map to relay::Errc via std::error_condition equivalence so that std::error_code == relay::Errc::closed works across the error category boundary.
Adapt()
```cpp
namespace rcp {
std::unique_ptrrelay::Caller Adapt(std::shared_ptr c);
}
```
kRelaySpecVersion constant (§19.4)
```cpp
namespace relay {
constexpr std::string_view kRelaySpecVersion = "0.2";
}
```
References
Tracking issue for cpp-RCP conformance against RELAY spec v0.2 §18.2.
relay namespace definitions
RELAY spec §18.2 requires these types in the
relay::namespace. cpp-RCP currently has analogues inrcp::.relay::Context
cpp-RCP has
rcp::Contextwith the correct API. Declare the alias:```cpp
namespace relay { using Context = rcp::Context; }
```
Or move the type to
relay::and alias inrcp::.relay::Channel
cpp-RCP has
rcp::StatusChannel. The spec requires a genericrelay::Channel<T>:```cpp
namespace relay {
template
class Channel {
public:
explicit Channel(std::size_t capacity);
bool push(T value);
std::optional recv();
std::optional try_recv();
void close() noexcept;
bool is_closed() const noexcept;
};
} // namespace relay
```
Then alias:
namespace rcp { using StatusChannel = relay::Channel<Status>; }relay::SubscriberOptions
```cpp
namespace relay {
enum class BackPressurePolicy { drop_newest = 0, drop_oldest = 1, block = 2 };
struct SubscriberOptions {
std::size_t channel_depth = 64;
BackPressurePolicy back_pressure = BackPressurePolicy::drop_newest;
};
} // namespace relay
```
relay::Node and relay::Caller
```cpp
namespace relay {
class Node {
public:
virtual Protocol protocol() const noexcept = 0;
virtual std::error_code send(Context ctx, const Message& msg) = 0;
virtual std::pair<Channel, std::error_code>
subscribe(SubscriberOptions opts = {}) = 0;
virtual std::error_code close() noexcept = 0;
virtual ~Node() = default;
};
class Caller : public Node {
public:
virtual std::pair<Message, std::error_code>
call(Context ctx, const Message& req) = 0;
};
} // namespace relay
```
relay::Errc error category (§18.2)
```cpp
namespace relay {
enum class Errc { closed, not_connected, timeout, payload_too_large };
} // namespace relay
// Registered as std::error_category "relay"
```
rcp::Errcvalues MUST map torelay::Errcviastd::error_conditionequivalence so thatstd::error_code == relay::Errc::closedworks across the error category boundary.Adapt()
```cpp
namespace rcp {
std::unique_ptrrelay::Caller Adapt(std::shared_ptr c);
}
```
kRelaySpecVersion constant (§19.4)
```cpp
namespace relay {
constexpr std::string_view kRelaySpecVersion = "0.2";
}
```
References