Skip to content

Conversation

@cmaglie
Copy link
Member

@cmaglie cmaglie commented Dec 17, 2025

Motivation

Improves the API of the msgpackrpc package.

Change description

Previously, the msgpackrpc.Connection had two methods requiring an array of parameters:

SendRequest(ctx context.Context, method string, params []any) (reqResult any, reqError any, err error)
SendNotification(method string, params []any) error

Now those methods do not require an explicit array anymore, but use the ellipsis ... notation:

SendRequest(ctx context.Context, method string, params ...any) (reqResult any, reqError any, err error)
SendNotification(method string, params ...any) error

This change makes the use of the API cleaner and less ambiguous, for example:

conn.SendRequest(ctx, "ping", []any{"hello", 12}) // calls ping("hello", 12)
conn.SendRequest(ctx, "ping", []any{})            // calls ping()
conn.SendRequest(ctx, "ping", nil)                // invalid call

can now be written as:

conn.SendRequest(ctx, "ping", "hello", 12) // calls ping("hello", 12)
conn.SendRequest(ctx, "ping")              // calls ping()
conn.SendRequest(ctx, "ping", nil)         // calls ping(nil)

Additional Notes

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

@cmaglie cmaglie self-assigned this Dec 17, 2025
@cmaglie cmaglie added the enhancement New feature or request label Dec 17, 2025
@cmaglie cmaglie requested a review from a team December 17, 2025 13:53
Copy link
Contributor

@dido18 dido18 left a comment

Choose a reason for hiding this comment

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

I like it 🦸

@cmaglie cmaglie merged commit 8cffcb8 into main Dec 17, 2025
8 checks passed
@cmaglie cmaglie deleted the use_parametrized_notifications branch December 17, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants