protobuf-ts
protobuf-ts copied to clipboard
Accessing "built-in" `MethodOptions` shouldn't be less convenient than accessing custom options
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;