Perform GRPC route building lazily on bind #2467
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
At the moment building a GRPC route is performed right when the application registers a new one at the high level API.
Since every route needs an execution strategy when being built, the execution strategy needs to be provided at construction time of the ServiceFactory/Builder. In order to improve the user experience and to make the execution strategy an optional builder method the building of the routes needs to be moved to a later point in the build stage.
Modifications:
This changeset, in preparation to making the execution strategy optional in a later commit, makes the route building lazy by moving it inside a closure which is executed at "bind" time instead of being evaluated immediately.
To preserve the current semantics (especially that an error is thrown if two routes on the same path are provided by the user), the error reporting is still performed eagerly. The merge code also had to be changed slightly to take this invariant into account.
Result:
Lazy GRPC route building in preparation to make the execution strategy optional.