-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement SSE #90
base: main
Are you sure you want to change the base?
Implement SSE #90
Conversation
b987563
to
217ec4d
Compare
Let me know if you need some more assistance here :) |
Hey @Acconut thank you for the reminder! I was occupied with other work in the meantime. I would like to continue on this soon. I let you know if I need anything :) |
61bb0dc
to
481edd5
Compare
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.
This PR is looking sharp! I have only a few comments and then we can get this on the road. Congrats on getting this so far 🎉
* @param combinedProgress Overall execution progress of the whole assembly. | ||
* @param progressPerOriginalFile JSONObject including the progress for each individual file. | ||
*/ | ||
void onAssemblyProgress(double combinedProgress, JSONObject progressPerOriginalFile); |
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.
Does every user of the Java SDK now have to update their listeners when they upgrade the Java SDK? If so, this would be a breaking change.
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.
Will be a braking change, yes. Intended to push out all of this in a major.
I thought it might make more sense to include new possible features, which SSE provides.
assemblyListener.onAssemblyUploadFinished(); | ||
break; | ||
default: | ||
LocalOperationException e = new LocalOperationException("Unknown SSE message: " + data); |
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.
We shouldn't error out on unknown events. In the future, we might add new events and SDKs should not start failing then.
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.
What do you think about piping this as "onError" Event inside the assembly listener ?
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.
Unknown events are not an error and shouldn't be forwarded to the user. If SDKs error out on unknown events, we cannot add new ones in the future.
if (streamEvent != null) { | ||
if (streamEvent instanceof MessageEvent) { | ||
handleMessageEvent((MessageEvent) streamEvent); | ||
} else if (streamEvent instanceof CommentEvent) { |
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.
Since we don't use CommentEvent, StartedEvent and FaultEvents, can we just remove them here and reduce the LOC? I also don't think we will be used them soon.
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.
I'd like to keep them, also the started event is sent by the library itself :)
@@ -0,0 +1,26 @@ | |||
id: 2b7beaddf0a046e2ada603346f2cbee1 |
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.
Can we give this file a .txt
extension?
Assertions.assertEquals(response.json().get("assembly_id"), "02ce6150ea2811e6a35a8d1e061a5b71"); | ||
Assertions.assertEquals(response.json().get("ok"), "ASSEMBLY_COMPLETED"); | ||
} | ||
|
||
@Override | ||
public void onError(Exception error) { | ||
emittedEvents.put("ASSEMBLY_ERROR", true); | ||
System.err.println("No Mockserver Response"); |
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.
Is this log line still relevant? Can we remove it?
} | ||
|
||
@Override | ||
public void onAssemblyResultFinished(String stepName, JSONObject result) { | ||
|
||
|
||
emittedEvents.put("ASSEMBLY_RESULT_FINISHED", true); |
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.
Can you add assertions to the event argments here and in the other methods? Then we can be sure that the data from SSE is passed properly to the listener.
Implement Server Sent Events (SSE) as replacement for socket polling.
This is due to SSE preference from the Transloadit API.