-
Notifications
You must be signed in to change notification settings - Fork 283
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
feat(cmd-api-server): add Socket.IO as transport #297 #897
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
petermetz
added
enhancement
New feature or request
API_Server
ConnectionChain
Core_API
Changes related to the Core API Package
labels
May 2, 2021
petermetz
force-pushed
the
feat-297
branch
4 times, most recently
from
May 3, 2021 20:26
25745c3
to
3a4d9da
Compare
kikoncuo
approved these changes
May 6, 2021
takeutak
approved these changes
May 10, 2021
🎉 Great news! Looks like all the dependencies have been resolved:
💡 To add or remove a dependency please update this issue/PR description. Brought to you by Dependent Issues (:robot: ). Happy coding! |
petermetz
force-pushed
the
feat-297
branch
2 times, most recently
from
May 25, 2021 16:46
854672c
to
32785ea
Compare
Primary changes: --------------- 1. The API server now has a SocketIO server running on the same port as the HTTP REST API. 2. The API server now has an ApiServerApiClient class which is an extension of the DefaultApi class that we generate from the OpenAPI specifications. The reason why this extension was necessary (something that we try to avoid like the plague normally) is because OpenAPI is strictly for defining HTTP/REST based APIs and not async/streaming ones such as WebSocket/SocketIO based ones and therefore the OpenAPI generator does not support these types of transports at all meaning that we have to manually write the client code for async endpoints which is why the class extension here is not something that we can get around. 3. The idea is that all async endpoints would declare their event names as constants in the OpenAPI specification so as to make it easier at least to some degree to implement solutions on top even if we cannot support async endpoints with the OpenAPI code generator to the same extend we do for HTTP RESTful endpoints. The five default events are Subscribe, Next, Unsubscribe, Error and Complete. These are defined in order to match what the client can do on the RxJS Observable object returned by the API client object's method that invokes the async endpoints. The difference between Unsubscribe and complete is subtle, but it definitely exists. The unsubscribe event is used by the client to tell the backend that it no longer requires updates, regardless of the streaming of data having been completed or not. The complete event on the other hand is for the backend to signal that the streaming of data is in fact completed. The complete event is only applicable for endpoints that do have an ending which is not the case for some endpoints that are usually time-series related and therefore a lot of times just stream endlessly until stopped. Secondary change(s): -------------------- 1. Added an async endpoint powered by the just now added SocketIO integration that streams the health check response every one second which is mainly added to that we can test the functionality but at could also be used for monitoring purposes by someone who'd rather implement something from scratch than use Prometheus for example. To-do: ------ 1. Socket provider singleton on client side for connection multiplexing Fixes hyperledger-cacti#297 Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
This was referenced Nov 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Dependencies
Depends on #896
Depends on #899
Depends on #902
Depends on #903
Commit to review
Author: Peter Somogyvari peter.somogyvari@accenture.com
Author Date: 2021-05-03 09:20:49 -0700
Committer: Peter Somogyvari peter.somogyvari@accenture.com
Committer Date: 2021-05-03 09:39:40 -0700
feat(cmd-api-server): add Socket.IO as transport #297
Primary changes:
The API server now has a SocketIO server running on the same port
as the HTTP REST API.
The API server now has an ApiServerApiClient class which is an
extension of the DefaultApi class that we generate from the OpenAPI
specifications. The reason why this extension was necessary (something
that we try to avoid like the plague normally) is because OpenAPI is
strictly for defining HTTP/REST based APIs and not async/streaming
ones such as WebSocket/SocketIO based ones and therefore the OpenAPI
generator does not support these types of transports at all meaning
that we have to manually write the client code for async endpoints
which is why the class extension here is not something that we can
get around.
The idea is that all async endpoints would declare their event
names as constants in the OpenAPI specification so as to make it
easier at least to some degree to implement solutions on top even
if we cannot support async endpoints with the OpenAPI code
generator to the same extend we do for HTTP RESTful endpoints.
The five default events are Subscribe, Next, Unsubscribe, Error and
Complete. These are defined in order to match what the client can
do on the RxJS Observable object returned by the API client object's
method that invokes the async endpoints.
The difference between Unsubscribe and complete is subtle, but it definitely
exists. The unsubscribe event is used by the client to tell the backend
that it no longer requires updates, regardless of the streaming of data
having been completed or not.
The complete event on the other hand is for the backend to signal that
the streaming of data is in fact completed. The complete event is only
applicable for endpoints that do have an ending which is not the case
for some endpoints that are usually time-series related and therefore
a lot of times just stream endlessly until stopped.
Secondary change(s):
integration that streams the health check response every one second
which is mainly added to that we can test the functionality but at
could also be used for monitoring purposes by someone who'd rather
implement something from scratch than use Prometheus for example.
To-do:
Fixes #297
Signed-off-by: Peter Somogyvari peter.somogyvari@accenture.com