Skip to content

feat: Add generic Protocol plugin and protocol interface#348

Merged
jterapin merged 4 commits into
mainfrom
define-protocol-plugin
Jul 23, 2026
Merged

feat: Add generic Protocol plugin and protocol interface#348
jterapin merged 4 commits into
mainfrom
define-protocol-plugin

Conversation

@jterapin

@jterapin jterapin commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Context

Adds the generic Protocol plugin, a Protocol interface base class, and a NoOpProtocol default: the mechanism for per-client protocol selection built on instance-level plugins (#347).

client = Service::Client.new(protocol: :rpc_v2_cbor)  # scoped to this client

The plugin resolves the :protocol option in before_initialize and installs build/parse handlers that delegate to the resolved protocol:

  • Default (unset) — first registered protocol, or NoOpProtocol if none.
  • Named (Symbol) — resolved from client_class.protocols.
  • Custom object — used as-is (duck-typed; need not inherit Protocol).

Protocols are instances (not modules) so they can carry per-client state (e.g. query_compatible, codec instances).

Other Notes

  • Dormant / define-only. Not wired into any weld, template, or generated client — the live rpcv2Cbor path is unchanged. Hooking the mechanism up and migrating rpcv2Cbor onto this interface follows in a later PR.
  • Protocol is a base class our own protocols inherit and a documented interface custom objects merely satisfy — there is deliberately no is_a?(Protocol) check.
  • Named protocols use Symbol to match the rest of the config surface.
  • Stacked on feat: Restore instance-level plugins #347 — base that PR first; this PR's diff assumes it.
  • The spec uses a test-only protocols registry (define_singleton_method) since the generated registry isn't restored until the mechanism is hooked up; a TODO marks its removal.

@jterapin
jterapin marked this pull request as ready for review July 8, 2026 21:05
sichanyoo
sichanyoo previously approved these changes Jul 14, 2026

@sichanyoo sichanyoo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Base automatically changed from restore-instance-level-plugins to main July 23, 2026 18:05
@jterapin
jterapin dismissed stale reviews from richardwang1124 and sichanyoo July 23, 2026 18:05

The base branch was changed.

@jterapin
jterapin force-pushed the define-protocol-plugin branch from 7b81439 to acc261f Compare July 23, 2026 18:08
simplecov 1.0.2 ships a public sig/simplecov.rbs that references
SkipChunks from their internal-only sigs (sig/internal/) which are
not included in the published gem. This breaks rbs validate for any
consumer. Ignore the gem-bundled sigs so rbs falls back to the
community collection's working signatures.
@sichanyoo
sichanyoo self-requested a review July 23, 2026 18:58
@jterapin
jterapin merged commit d67121e into main Jul 23, 2026
33 checks passed
@jterapin
jterapin deleted the define-protocol-plugin branch July 23, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants