Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): allow overriding the service identifier #683

Merged
merged 1 commit into from
Oct 12, 2022

Conversation

paralin
Copy link
Collaborator

@paralin paralin commented Oct 11, 2022

Currently the service identifier is the fully qualified "fullName" of the service, for example, "simple.Echoer"

This identifier is hard-coded in the auto-generated client with string literals.

Instead, allow overriding the service ID with a new optional argument in the client constructor, default the service ID to the fullName, and store the ID in a read-only field on the client object.

This allows the user to override the service ID if desired while still maintaining the old behavior otherwise.

@paralin paralin requested a review from stephenh October 11, 2022 22:16
integration/async-iterable-services/simple.ts Outdated Show resolved Hide resolved
Currently the service identifier is the fully qualified "fullName" of the
service, for example, "simple.Echoer"

This identifier is hard-coded in the auto-generated client with string literals.

Instead, allow overriding the service ID with a new optional argument in the
client constructor, default the service ID to the fullName, and store the ID in
a read-only field on the client object.

This allows the user to override the service ID if desired while still
maintaining the old behavior otherwise.

Signed-off-by: Christian Stewart <christian@paral.in>
@paralin
Copy link
Collaborator Author

paralin commented Oct 12, 2022

Updated syntax:

  constructor(rpc: Rpc, opts?: { service?: string }) {
    this.service = opts?.service || "simple.PingService";

@stephenh
Copy link
Owner

Looks great!

@stephenh stephenh merged commit 10c7c99 into stephenh:main Oct 12, 2022
stephenh pushed a commit that referenced this pull request Oct 12, 2022
# [1.127.0](v1.126.1...v1.127.0) (2022-10-12)

### Features

* **client:** allow overriding the service identifier ([#683](#683)) ([10c7c99](10c7c99))
* Import CallContext and CallOptions as type ([#684](#684)) ([8b388f6](8b388f6)), closes [#677](#677)
@stephenh
Copy link
Owner

🎉 This PR is included in version 1.127.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@paralin paralin deleted the client-override-service-id branch October 19, 2022 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants