-
Notifications
You must be signed in to change notification settings - Fork 42
Setup : LiveObject plugin #1085
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c435f5d
Created and configured liveobjects as a separate module to the project
ttypic bce4ba9
1. Added jetbrains-annoations dependency to clearly define interface …
sacOO7 d81cb24
1. Updated public doc for LiveObjects, LiveMap and LiveCounter
sacOO7 d87b365
1. Added coroutinex as a runtime and test dependency to liveobjects
sacOO7 cd7d075
1. Added blocking and non-blocking annotations to sync and async methods
sacOO7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package io.ably.lib.objects; | ||
|
|
||
| import io.ably.lib.types.Callback; | ||
| import org.jetbrains.annotations.Blocking; | ||
| import org.jetbrains.annotations.NonBlocking; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Contract; | ||
|
|
||
| /** | ||
| * The LiveCounter interface provides methods to interact with a live counter. | ||
| * It allows incrementing, decrementing, and retrieving the current value of the counter, | ||
| * both synchronously and asynchronously. | ||
| */ | ||
| public interface LiveCounter { | ||
|
|
||
| /** | ||
| * Increments the value of the counter by 1. | ||
| * Send a COUNTER_INC operation to the realtime system to increment a value on this LiveCounter object. | ||
| * This does not modify the underlying data of this LiveCounter object. Instead, the change will be applied when | ||
| * the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular | ||
| * operation application procedure. | ||
| */ | ||
| @Blocking | ||
| void increment(); | ||
|
|
||
| /** | ||
| * Increments the value of the counter by 1 asynchronously. | ||
| * Send a COUNTER_INC operation to the realtime system to increment a value on this LiveCounter object. | ||
| * This does not modify the underlying data of this LiveCounter object. Instead, the change will be applied when | ||
| * the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular | ||
| * operation application procedure. | ||
| * | ||
| * @param callback the callback to be invoked upon completion of the operation. | ||
| */ | ||
| @NonBlocking | ||
| void incrementAsync(@NotNull Callback<Void> callback); | ||
|
|
||
| /** | ||
| * Decrements the value of the counter by 1. | ||
| * An alias for calling {@link LiveCounter#increment()} with a negative amount. | ||
| */ | ||
| @Blocking | ||
| void decrement(); | ||
|
|
||
| /** | ||
| * Decrements the value of the counter by 1 asynchronously. | ||
| * An alias for calling {@link LiveCounter#increment()} with a negative amount. | ||
| * | ||
| * @param callback the callback to be invoked upon completion of the operation. | ||
| */ | ||
| @NonBlocking | ||
| void decrementAsync(@NotNull Callback<Void> callback); | ||
|
|
||
| /** | ||
| * Retrieves the current value of the counter. | ||
| * | ||
| * @return the current value of the counter as a Long. | ||
| */ | ||
| @NotNull | ||
| @Contract(pure = true) // Indicates this method does not modify the state of the object. | ||
| Long value(); | ||
| } | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| package io.ably.lib.objects; | ||
|
|
||
| import io.ably.lib.types.Callback; | ||
| import org.jetbrains.annotations.Blocking; | ||
| import org.jetbrains.annotations.NonBlocking; | ||
| import org.jetbrains.annotations.Contract; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.jetbrains.annotations.Unmodifiable; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * The LiveMap interface provides methods to interact with a live, real-time map structure. | ||
| * It supports both synchronous and asynchronous operations for managing key-value pairs. | ||
| */ | ||
| public interface LiveMap { | ||
|
|
||
| /** | ||
| * Retrieves the value associated with the specified key. | ||
| * If this map object is tombstoned (deleted), `undefined` is returned. | ||
| * If no entry is associated with the specified key, `undefined` is returned. | ||
| * If map entry is tombstoned (deleted), `undefined` is returned. | ||
| * If the value associated with the provided key is an objectId string of another LiveObject, a reference to that LiveObject | ||
| * is returned, provided it exists in the local pool and is not tombstoned. Otherwise, `undefined` is returned. | ||
| * If the value is not an objectId, then that value is returned. | ||
| * | ||
| * @param keyName the key whose associated value is to be returned. | ||
| * @return the value associated with the specified key, or null if the key does not exist. | ||
| */ | ||
| @Nullable | ||
| Object get(@NotNull String keyName); | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * Retrieves all entries (key-value pairs) in the map. | ||
| * | ||
| * @return an iterable collection of all entries in the map. | ||
| */ | ||
| @NotNull | ||
| @Unmodifiable | ||
| Iterable<Map.Entry<String, Object>> entries(); | ||
|
|
||
| /** | ||
| * Retrieves all keys in the map. | ||
| * | ||
| * @return an iterable collection of all keys in the map. | ||
| */ | ||
| @NotNull | ||
| @Unmodifiable | ||
| Iterable<String> keys(); | ||
|
|
||
| /** | ||
| * Retrieves all values in the map. | ||
| * | ||
| * @return an iterable collection of all values in the map. | ||
| */ | ||
| @NotNull | ||
| @Unmodifiable | ||
| Iterable<Object> values(); | ||
|
|
||
| /** | ||
| * Sets the specified key to the given value in the map. | ||
| * Send a MAP_SET operation to the realtime system to set a key on this LiveMap object to a specified value. | ||
| * This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when | ||
| * the published MAP_SET operation is echoed back to the client and applied to the object following the regular | ||
| * operation application procedure. | ||
| * | ||
| * @param keyName the key to be set. | ||
| * @param value the value to be associated with the key. | ||
| */ | ||
| @Blocking | ||
| void set(@NotNull String keyName, @NotNull Object value); | ||
|
|
||
| /** | ||
| * Removes the specified key and its associated value from the map. | ||
| * Send a MAP_REMOVE operation to the realtime system to tombstone a key on this LiveMap object. | ||
| * This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when | ||
| * the published MAP_REMOVE operation is echoed back to the client and applied to the object following the regular | ||
| * operation application procedure. | ||
| * | ||
| * @param keyName the key to be removed. | ||
| */ | ||
| @Blocking | ||
| void remove(@NotNull String keyName); | ||
|
|
||
| /** | ||
| * Retrieves the number of entries in the map. | ||
| * | ||
| * @return the size of the map. | ||
| */ | ||
| @Contract(pure = true) // Indicates this method does not modify the state of the object. | ||
| @NotNull | ||
| Long size(); | ||
|
|
||
| /** | ||
| * Asynchronously sets the specified key to the given value in the map. | ||
| * Send a MAP_SET operation to the realtime system to set a key on this LiveMap object to a specified value. | ||
| * This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when | ||
| * the published MAP_SET operation is echoed back to the client and applied to the object following the regular | ||
| * operation application procedure. | ||
| * | ||
| * @param keyName the key to be set. | ||
| * @param value the value to be associated with the key. | ||
| * @param callback the callback to handle the result or any errors. | ||
| */ | ||
| @NonBlocking | ||
| void setAsync(@NotNull String keyName, @NotNull Object value, @NotNull Callback<Void> callback); | ||
|
|
||
| /** | ||
| * Asynchronously removes the specified key and its associated value from the map. | ||
| * Send a MAP_REMOVE operation to the realtime system to tombstone a key on this LiveMap object. | ||
| * This does not modify the underlying data of this LiveMap object. Instead, the change will be applied when | ||
| * the published MAP_REMOVE operation is echoed back to the client and applied to the object following the regular | ||
| * operation application procedure. | ||
| * | ||
| * @param keyName the key to be removed. | ||
| * @param callback the callback to handle the result or any errors. | ||
| */ | ||
| @NonBlocking | ||
| void removeAsync(@NotNull String keyName, @NotNull Callback<Void> callback); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.