Skip to content

P1: RELAY conformance — relay namespace, SubscriberOptions, Node/Caller, Errc mapping, Adapt(), SpecVersion #5

Closed

Description

@SoundMatt

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

Activity

  1. SoundMatt commented on Jun 17, 2026

    @SoundMatt
    OwnerAuthor

    Implemented in PR #7 (merged). RELAY spec v0.2 conformance complete: relay:: namespace, Channel, Context alias, StatusChannel alias, Errc mapping via std::error_condition equivalence, Adapt(), and kRelaySpecVersion = "0.2". All 27/27 CI tests pass across clang-14, gcc-12 (C++17/20), macOS clang, and MSVC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions