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

Fix HTTP Protocol and overall SDK enhancements #71

Merged
merged 39 commits into from
Apr 1, 2022
Merged

Conversation

Shiranuit
Copy link
Contributor

@Shiranuit Shiranuit commented Mar 29, 2022

What does this PR do ?

Bump version to 1.2.4

Dependencies

Upgrade ktor dependencies to 1.6.8
Upgrade gradle version to 7.4

README

Describe that there are two protocols now [HTTP, Websocket]
Update dependencies list
Remove a section about BINTRAY repository that is now obsolete.
Add compatibility matrix

HTTP Protocol

Finalize HTTP Protocol implementation
HTTP Protocol is now using coroutines to avoid blocking the main thread while making HTTP Requests
Fix a bug where requests were not properly resolved because of the returned requestId from Kuzzle

Websocket Protocol

The websocket protocol was not closed properly after calling disconnect.
This behaviour was preventing the processes using the SDK from stopping.
This is now fixed

Enhance event system

The previous event system was limited, it was only possible to give one string argument to the event callback which was not ideal because if we needed to have an event with more parameters than only one string, we were forced to change the callback of every event to handle more parameters, it could cause trouble for both us and users of the SDK since it would be really hard to avoid breaking changes when adding a new parameter to an event.

The new event system is design to avoid this issue, by registering a callback to an event class, once an event is sent with the trigger method, only the callback taking the same event class as the one given to the trigger method are going to be called.
This allows us to easily add new properties to an event without breaking the callbacks parameters both internaly in the SDK and externaly for the user.

Usage example with creating a new Event

data class CustomEvent(var text: String, var value: Int)

fun onCustomEvent(event: CustomEvent) {
  println(event.text)
  println(event.value)
}

protocol.addListener<CustomEvent>(::onCustomEvent) // Add a listener on "CustomEvent"
protocol.trigger(CustomEvent("value", 42)) // Trigger every listener on CustomEvent

Snippets Tests

Fix Java template that were comparing strings with == instead of equals leading to condition to always be false
Fix Kotlin template that were missing condition to use the HTTP protocol or Websocket protocol during the different test phases
Fix NullPointerException that was occuring during snippet tests because System.getenv(<key>) was returning null when an environment variable was not set
Remove protocols configuration from each snippet to use the global snippet config and avoid repetition

@Shiranuit Shiranuit marked this pull request as ready for review March 30, 2022 14:02
@Shiranuit Shiranuit merged commit 5e76d11 into 1-dev Apr 1, 2022
@Shiranuit Shiranuit mentioned this pull request Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant