Skip to content

Version 2 - #24

Merged
senid231 merged 8 commits into
masterfrom
version-2
May 29, 2026
Merged

Version 2#24
senid231 merged 8 commits into
masterfrom
version-2

Conversation

@senid231

@senid231 senid231 commented May 29, 2026

Copy link
Copy Markdown
Member

Full rewrite. JRPC 2.0 is not API-compatible with 1.x.

New

  • JRPC::SharedClient — one shared instance, one connection, serving many caller
    threads and/or fibers. Owns a dedicated transport thread that multiplexes
    responses by id. Supports Puma threads, rage-rb/Falcon fibers, and mixed
    thread/fiber callers. Fiber callers require a spec-compliant Fiber.scheduler.
    (Internally drafted as ThreadQueueClient; never shipped under that name.)
  • JRPC::SimpleClient — single-threaded client, the functional replacement for
    the old TcpClient.
  • concurrent-ruby (~> 1.2) added as a runtime dependency (backs the shared
    client's result futures).
  • logger added as an explicit runtime dependency (no longer guaranteed bundled
    on Ruby 3.5+).

Removed / breaking

  • JRPC::TcpClient removed — use JRPC::SimpleClient.
  • JRPC::BaseClient removed, including the BaseClient.connect block helper.
  • All top-level error constants moved under JRPC::Errors::*.
  • method_missing magic removed — pass the full method name as a String or Symbol.
  • invoke_request / invoke_notification removed.
  • perform_request removed — use request and notification.
  • namespace: option removed.
  • Umbrella timeout: option removed — use read_timeout / write_timeout /
    connect_timeout (SimpleClient), or ttl: (SharedClient).
  • close_after_sent: renamed to autoclose:.
  • connect_retry_count default changed from 10 to 0.
  • Constructors no longer connect eagerly — the first call connects.
  • Malformed responses now raise Errors::MalformedResponseError (a ServerError),
    not ClientError. In 1.x the missing-comma-terminator case raised ClientError.
  • SimpleClient read/write/connect timeouts now raise Errors::Timeout, not
    ConnectionError.
  • oj runtime dependency dropped — JRPC uses stdlib json. For Oj speed,
    require 'oj'; Oj.mimic_JSON yourself.
  • netstring is no longer a dependency — framing is owned in-tree by the transport.
  • required_ruby_version set to >= 3.3 (the floor where the
    ConditionVariableFiber.scheduler cooperation that fiber callers depend on
    is verified).
  • bin/jrpc and bin/jrpc-shell rewritten on top of SimpleClient; flag/usage
    changes (see README.md and jrpc --help).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Full rewrite of the gem as JRPC 2.0, introducing a new transport layer and two distinct client implementations (SimpleClient and SharedClient) with updated error semantics, CLI tooling, and CI/rubocop/test infrastructure.

Changes:

  • Replaced the legacy TcpClient/BaseClient stack with SimpleClient (single-caller) and SharedClient (multi-thread/fiber shared client with a dedicated transport thread).
  • Implemented an in-tree TCP transport with netstring framing and revised timeout/connection retry behavior.
  • Updated docs, executables, gem dependencies, and added a new RSpec suite + CI workflow for Ruby 3.3/3.4.

Reviewed changes

Copilot reviewed 55 out of 58 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
spec/transport/tcp_spec.rb New transport-level TCP framing/timeout/connect specs.
spec/tcp_client_spec.rb Removed legacy JRPC::TcpClient specs.
spec/support/fake_shared_transport.rb New test transport for SharedClient using UNIXSocket pair.
spec/spec_helper.rb Updated spec helper load path and support auto-require.
spec/simple_client_spec.rb New SimpleClient behavior and error-translation specs.
spec/shared_client/ticket_spec.rb New SharedClient::Ticket specs.
spec/shared_client/registry_spec.rb New SharedClient::Registry specs.
spec/shared_client/outbound_queue_spec.rb New SharedClient::OutboundQueue specs.
spec/shared_client/fiber_spec.rb New fiber-scheduler integration specs for SharedClient.
spec/shared_client_spec.rb New SharedClient integration specs (threads, TTL, reconnect, close semantics).
spec/message_spec.rb New Message envelope/build/parse/validate specs.
spec/id_generator_spec.rb New IdGenerator specs (single-thread and multi-thread).
spec/fake_transport.rb Removed legacy fake transport used by old client specs.
spec/errors_spec.rb New error hierarchy specs under JRPC::Errors.
README.md Rewritten documentation for 2.0 APIs, behavior, and upgrade notes.
Rakefile Modernized rake task definition and added frozen string literal.
lib/jrpc/version.rb Bumped version to 2.0.0.
lib/jrpc/utils.rb Removed legacy utility class.
lib/jrpc/transport/tcp.rb New TCP transport implementation with framing and connect/read/write logic.
lib/jrpc/transport/socket_tcp.rb Removed legacy socket transport implementation.
lib/jrpc/transport/socket_base.rb Removed legacy socket base implementation.
lib/jrpc/transport/base.rb New transport base API + error types.
lib/jrpc/transport.rb New transport builder entrypoint.
lib/jrpc/tcp_client.rb Removed legacy TCP client implementation.
lib/jrpc/simple_client.rb New SimpleClient implementation.
lib/jrpc/shared_client/transport_loop.rb New SharedClient transport thread event loop.
lib/jrpc/shared_client/ticket.rb New Ticket backed by concurrent-ruby futures.
lib/jrpc/shared_client/registry.rb New registry for in-flight tickets.
lib/jrpc/shared_client/outbound_queue.rb New bounded outbound queue implementation.
lib/jrpc/shared_client.rb New SharedClient implementation + lifecycle management.
lib/jrpc/message.rb New JSON-RPC message helpers (build/parse/validate/error mapping).
lib/jrpc/id_generator.rb New ID generator with optional mutex for thread safety.
lib/jrpc/errors.rb New public error hierarchy under JRPC::Errors.
lib/jrpc/error/unknown_error.rb Removed legacy error class file.
lib/jrpc/error/server_error.rb Removed legacy error class file.
lib/jrpc/error/parse_error.rb Removed legacy error class file.
lib/jrpc/error/method_not_found.rb Removed legacy error class file.
lib/jrpc/error/invalid_request.rb Removed legacy error class file.
lib/jrpc/error/invalid_params.rb Removed legacy error class file.
lib/jrpc/error/internal_server_error.rb Removed legacy error class file.
lib/jrpc/error/internal_error.rb Removed legacy error class file.
lib/jrpc/error/error.rb Removed legacy error class file.
lib/jrpc/error/connection_error.rb Removed legacy error class file.
lib/jrpc/error/connection_closed_error.rb Removed legacy error class file.
lib/jrpc/error/client_error.rb Removed legacy error class file.
lib/jrpc/error.rb Removed legacy error require aggregator.
lib/jrpc/base_client.rb Removed legacy base client implementation.
lib/jrpc.rb Rewired gem entrypoint requires to the new 2.0 architecture.
jrpc.gemspec Updated runtime deps and Ruby requirement (>= 3.3).
Gemfile Added dev tooling dependencies (rubocop, async for fiber specs).
CHANGELOG.md Added 2.0.0 release notes and breaking-change summary.
bin/jrpc-shell Rewritten shell to use SimpleClient and updated parsing/usage.
bin/jrpc Rewritten CLI to use SimpleClient and revised flags/options.
bin/console Added frozen string literal pragma.
.travis.yml Removed legacy Travis CI config.
.rubocop.yml Added RuboCop configuration and plugins.
.rspec Ensures spec_helper is required by default.
.github/workflows/ci.yml Added GitHub Actions CI for RuboCop + RSpec on Ruby 3.3/3.4.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread spec/id_generator_spec.rb Outdated
Comment thread spec/support/fake_shared_transport.rb
Comment thread spec/shared_client/ticket_spec.rb Outdated
@github-actions

Copy link
Copy Markdown
Package Line Rate Branch Rate Complexity Health
jrpc 92% 81% 0
Summary 92% (607 / 660) 81% (196 / 241) 0

@senid231
senid231 merged commit 8ca77ff into master May 29, 2026
2 checks passed
@senid231
senid231 deleted the version-2 branch May 29, 2026 13:37
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.

2 participants