Skip to content
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

Merged
merged 43 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fab1dab
Update Examples to an ENV based credential management and update Kotl…
cdr-chakotay Oct 18, 2023
217ec4d
First attempt on implementing SSE, doesn't work without the socket yet.
cdr-chakotay Oct 19, 2023
a5ced80
Second Attempt on SSE -> Still not working. Will consider CISCO SSE C…
cdr-chakotay Nov 4, 2023
7adf3b9
Second Attempt on SSE -> Still not working. Will consider CISCO SSE C…
cdr-chakotay Nov 4, 2023
76c1d55
Merge remote-tracking branch 'origin/Implement_SSE' into Implement_SSE
cdr-chakotay Nov 4, 2023
3e09e94
Revert Changes. Still not working.
cdr-chakotay Nov 6, 2023
882dc40
Added basic body of the Eventsource Runnable
cdr-chakotay Dec 3, 2023
b65e21e
Prepare Handling Methods
cdr-chakotay Dec 3, 2023
3467887
Merge main in order to benefit from the new build settings
cdr-chakotay Mar 20, 2024
7309cf5
Add the first really working implementation of SSE
cdr-chakotay Mar 22, 2024
858c890
Add the first really working implementation of SSE
cdr-chakotay Mar 22, 2024
a29f65d
Merge remote-tracking branch 'origin/Implement_SSE' into Implement_SSE
cdr-chakotay Mar 22, 2024
74c04ea
Satisfy linter
cdr-chakotay Mar 22, 2024
5efd19a
Start with fixing unit test
cdr-chakotay Mar 22, 2024
7b9a097
Merge main to maintain a conflict free merging branch
cdr-chakotay Aug 14, 2024
42a90b8
Return Point Mock Socket before transition to SSE
cdr-chakotay Aug 14, 2024
22dee3d
Remove socket from MockTusAssembly
cdr-chakotay Aug 14, 2024
cde87d3
Patch empty JSON Object errors.
cdr-chakotay Aug 28, 2024
115cc4c
Add a first attempt on SSE testing
cdr-chakotay Aug 28, 2024
24490d9
Add tests for Server Sent Events
cdr-chakotay Sep 2, 2024
76ac9af
Remove Debug Output from EventsourceRunnable
cdr-chakotay Sep 2, 2024
f8fc321
Linting
cdr-chakotay Sep 2, 2024
481edd5
Linting
cdr-chakotay Sep 2, 2024
8a11ee7
Disable auto build for examples
cdr-chakotay Sep 2, 2024
0dadd7f
Remove PI
cdr-chakotay Sep 2, 2024
a334a62
Activate Debugging
cdr-chakotay Sep 10, 2024
df7f87c
Remove unnecessary URI parameter
cdr-chakotay Sep 11, 2024
dc13232
Dont exit on error
cdr-chakotay Sep 11, 2024
1263058
Add missing imports
cdr-chakotay Oct 10, 2024
903baf0
Adjust Timeouts in Assembly.java
cdr-chakotay Nov 20, 2024
cf91413
Patch Assembly Examples in order to work with the new SSE features
cdr-chakotay Nov 20, 2024
0b7039f
Fix Linting Errors
cdr-chakotay Nov 24, 2024
6849072
Implement changes on AssemblyListener
cdr-chakotay Nov 25, 2024
3f0cda4
Implement changes on AssemblyListener
cdr-chakotay Nov 25, 2024
c2d3fc5
Flip assertion order to the correct orientation
cdr-chakotay Nov 25, 2024
92aea9f
Fix some doc-strings
cdr-chakotay Nov 25, 2024
6b284a9
Cleanup debug line
cdr-chakotay Nov 25, 2024
3031491
Fix line
cdr-chakotay Nov 25, 2024
55018aa
Attempt on checking JSON contents
cdr-chakotay Nov 27, 2024
7cdef7f
Apply some of the suggestions from code review
cdr-chakotay Dec 3, 2024
270d634
- Patch styling in Assembly.java
cdr-chakotay Dec 3, 2024
35d34a6
Update test to live without the complicated map construction.
cdr-chakotay Dec 3, 2024
652ae2e
Fix examples
cdr-chakotay Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ dependencies {
implementation 'org.json:json:20231013'
implementation 'commons-codec:commons-codec:1.15'
implementation 'io.socket:socket.io-client:2.1.0'
implementation 'com.launchdarkly:okhttp-eventsource:4.1.1'


testImplementation 'org.mock-server:mockserver-junit-jupiter-no-dependencies:5.15.0'
testImplementation 'org.mockito:mockito-core:4.8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class ImageResizer {
* @param args
*/
public static void main(String[] args) {
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));

Map<String, Object> stepOptions = new HashMap<>();
stepOptions.put("width", 75);
Expand Down Expand Up @@ -82,6 +82,11 @@ public void onFileUploadProgress(long uploadedBytes, long totalBytes) {

}

@Override
public void onAssemblyProgress(double combinedProgress, JSONObject progressPerOriginalFile) {
System.out.printf("Assembly Execution Progress: %f", combinedProgress);
}

@Override
public void onAssemblyResultFinished(String stepName, JSONObject result) {

Expand Down
10 changes: 8 additions & 2 deletions examples/src/main/java/com/transloadit/examples/KotlinExample.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class KotlinExample {
@JvmStatic
fun main(args: Array<String>) {
// Setup the TransloaditClient and a new Assembly
val transloadit = Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET")
val transloadit = Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"))

val assembly: Assembly = transloadit.newAssembly()
val kotlinExample = KotlinExample()
Expand All @@ -36,7 +36,8 @@ class KotlinExample {
JSONObject()
.put("text","Kotlin Example")
.put("color","#e61010")
.put("font","Helvetica")
.put("font","Ubuntu-Mono-Bold")
// .put("font","Helvetica") You can put Helvetica here in order to test the error handling
Acconut marked this conversation as resolved.
Show resolved Hide resolved
.put("size", 15)
)

Expand Down Expand Up @@ -89,6 +90,11 @@ class KotlinExample {
println("Uploaded $uploadedBytes from $totalBytes bytes")
}

override fun onAssemblyProgress(combinedProgress: Double, progressPerOriginalFile: JSONObject?) {
println("Assembly Progress: $combinedProgress")
println("Progress per file: ${progressPerOriginalFile.toString()}")
}

override fun onAssemblyResultFinished(stepName: String?, result: JSONObject?) {
println("Step Result available: ")
println(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class MultiStepProcessing {
*/
public static void main(String[] args) throws FileNotFoundException {
// New Transloadit Instance
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));
Assembly assembly = transloadit.newAssembly();

// Add Files and define Field name
Expand Down Expand Up @@ -134,6 +134,11 @@ public void onFileUploadProgress(long uploadedBytes, long totalBytes) {

}

@Override
public void onAssemblyProgress(double combinedProgress, JSONObject progressPerOriginalFile) {
System.out.println("Assembly Execution Progress: " + combinedProgress);
cdr-chakotay marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public void onAssemblyResultFinished(String stepName, JSONObject result) {
System.out.println("\n ---- Step Result for Step: ---- ");
Expand All @@ -154,7 +159,6 @@ public void onAssemblyResultFinished(String stepName, JSONObject result) {
Thread.sleep(3000);
assembly.resumeUploads();

System.out.println("Assembly ID: " + assembly.getClientSideGeneratedAssemblyID());
} catch (LocalOperationException | RequestException | InterruptedException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class OverrideTemplate {
* @param args
*/
public static void main(String[] args) {
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));

Map<String, Object> stepOptions = new HashMap<>();
stepOptions.put("url", "https://transloadit.com/");
Expand Down Expand Up @@ -94,6 +94,11 @@ public void onFileUploadProgress(long uploadedBytes, long totalBytes) {

}

@Override
public void onAssemblyProgress(double combinedProgress, JSONObject progressPerOriginalFile) {

}

@Override
public void onAssemblyResultFinished(String stepName, JSONObject result) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class TemplateExample {
* @param args
*/
public static void main(String[] args) {
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));

Assembly assembly = transloadit.newAssembly();
// set template id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class Watermarker {
* @param args
*/
public static void main(String[] args) {
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));

Map<String, Object> stepOptions = new HashMap<>();
stepOptions.put("use", ":original");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class AsyncExample {
* @param args
*/
public static void main(String[] args) {
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));

Map<String, Object> stepOptions = new HashMap<String, Object>();
stepOptions.put("width", 75);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class AsyncPausePlayExample {
* @param args
*/
public static void main(String[] args) {
Transloadit transloadit = new Transloadit("TRANSLOADIT_KEY", "TRANSLOADIT_SECRET");
Transloadit transloadit = new Transloadit(System.getenv("TRANSLOADIT_KEY"), System.getenv("TRANSLOADIT_SECRET"));

Map<String, Object> stepOptions = new HashMap<String, Object>();
stepOptions.put("width", 75);
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Uncomment following line if you want to use the local java-sdk
// for the example instead of pulling the JARs from JCenter.
// This is useful for debugging and testing new features.
//include ':examples'
// include ':examples'
rootProject.name = 'transloadit'
Loading
Loading