-
Notifications
You must be signed in to change notification settings - Fork 107
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
Support dynamic messages with Initializer options #630
Conversation
New field Schema of type any on Spec objects. For proto based schemas the type will be of protoreflect.MethodDescriptor. This allows for easy introspection to interceptors.
An Initializer helps to construct dynamic messages on Receive. This lets clients and servers use dynamic messages. A default initializer for dynamicpb.Message is provided. Other IDLs can provide custom Initializers using the WithInitializer option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I've merged the schema PR, so this needs a rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't looked at the implementation in detail, but the exported API makes sense to me.
Closing, reopening as a fork PR: #640 |
To support dynamic clients and servers we need to initialize messages on
Receive
. This adds two new optionsWithRequestInitializer
andWithResponseInitializer
that provideInitializerFunc
s that help construct request messages before use. Proto based schemas can use the new Schema field on Spec to introspect the method types. Other IDLs can set their own schema using theWithSchema
option.Dynamic Message Initializer
As an example to support
dynamicpb.Message
we will inspect the schema and set the message descriptor. An intializer func can be run on the client or handller. This func is provided to the examples below as an option:Dynamic Clients
Construct a client using
dynamicpb.Message
. Ensure the URL includes the suffix of the handler method to invoke and to includeWithSchema
andWithResponseInitializer
options:Dynamic Handlers
Create the server func with a signature that includes the
dynamicpb.Message
. Then construct the handler specifying the procedure URL and ensure to includeWithSchema
andWithRequestInitializer
options:Fixes #523