#8 added addDataSources convenience method #17
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.
Pull request questions
Which issue does this address
resolves #8
Why was change needed
Calling
SzGrpcConfig.addDataSource
multiple times asyncronously results inConnection Dropped
error. I had a hunch that it had something to do with the nature of non-threaded async requests over the grpc client. (I was right)Normally you would use a Generator Function along with
await
andasync
but google has made this all but impossible by requiring using the CommonJS or Closure module style instead of the newer defacto standard ESM. Until google updates their protoc compiler plugins to use ESM our hands are kind of tied on this.Creating promises one after the previous is at best tedious and at worst mind-boggling depending on how familiar a developer is with node/js. I decided to write a helper function with internal subs(basically a class masquerading as a function) that handles the wackyness of doing sequential promises. This is preferable over asking the user to work around the limitations of node/promises in a snippet/example.
What does change improve
Ability to call
SzConfig.addDataSources(configHandle, ['DS1','DS2','DS3'])
in one line instead of 50 lines of example code.