protobuf-es icon indicating copy to clipboard operation
protobuf-es copied to clipboard

Expose `add` method on registry object

Open jafaircl opened this issue 2 years ago • 1 comments

Is it possible to expose the add method on the registry object so that we can add new message/enum/service types after the registry is created? Looking at the source code, it should really just be a typing update. The method already exists on the object. I’m happy to submit a PR to do it. But, I wanted to make sure there wasn’t a reason not to before doing that.

I’m working on a CEL implementation and it would be beneficial to allow users to supply their own registry and then add standard message types to that.

jafaircl avatar Jan 28 '24 17:01 jafaircl

Hey @jafaircl, today, registries are very simple interfaces that do not allow mutation. And it wouldn't be trivial to add an add method to the interface because of cases like createRegistryFromDescriptors().

In the long term, we'd love to extend the capabilities (also see https://github.com/bufbuild/protobuf-es/issues/708). For now, the best approach is to implement the interface yourself, and provide an add method.

timostamm avatar Feb 20 '24 10:02 timostamm

@jafaircl, https://github.com/bufbuild/protobuf-es/pull/899 adds the function createMutableRegistry(), which creates a registry with a method add().

https://github.com/bufbuild/protobuf-es/pull/898 adds a similar function to the upcoming version 2.

timostamm avatar Jun 21 '24 11:06 timostamm