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

Accessing "built-in" MethodOptions shouldn't be less convenient than accessing custom options #535

Open
jcready opened this issue May 9, 2023 · 0 comments

Comments

@jcready
Copy link
Contributor

jcready commented May 9, 2023

Trying to access the IdempotencyLevel MethodOption is arguably more challenging than accessing other custom method options. One can use the convenient readMethodOption() from @protobuf-ts/runtime-rpc to get custom options which handles finding the correct MethodInfo from the list of methods on the service.

But when trying to discover a method's IdempotencyLevel one must instead manually iterate over the ServiceType.method array. At the very least it'd be convenient to have some exported function similar to readMethodOption() which would return the MethodInfo given a method name and service. Something like:

// Proposed function
function readMethodOption<I extends object = any, O extends object = any>(service: ServiceInfo, methodName: string | number): MethodInfo<I, O>;

// Usage
const idempotency = readMethodInfo(AnnotatedService, "get").idempotency;
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

No branches or pull requests

1 participant