Skip to content

Commit 882cdbb

Browse files
authored
Merge pull request #1182 from ably/AIT-99/message-appends
[AIT-99] feat: protocol v5 + message appends
2 parents c8c1f1e + 6563568 commit 882cdbb

15 files changed

Lines changed: 416 additions & 281 deletions

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/setup-java@v4
2020
with:
2121
java-version: '17'
22-
distribution: 'temurin'
22+
distribution: 'corretto'
2323

2424
- name: Set up Gradle
2525
uses: gradle/actions/setup-gradle@v3

java/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ tasks.register<Test>("testRestSuite") {
7979
}
8080
jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED")
8181
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
82+
jvmArgs("--add-opens", "java.base/java.net=ALL-UNNAMED")
83+
jvmArgs("--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED")
8284
beforeTest(closureOf<TestDescriptor> { logger.lifecycle("-> $this") })
8385
outputs.upToDateWhen { false }
8486
testLogging {

lib/src/main/java/io/ably/lib/realtime/ChannelBase.java

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@
4343
import io.ably.lib.types.ProtocolMessage.Action;
4444
import io.ably.lib.types.ProtocolMessage.Flag;
4545
import io.ably.lib.types.Summary;
46+
import io.ably.lib.types.UpdateDeleteResult;
4647
import io.ably.lib.util.CollectionUtils;
4748
import io.ably.lib.util.EventEmitter;
4849
import io.ably.lib.util.Log;
4950
import io.ably.lib.util.ReconnectionStrategy;
5051
import io.ably.lib.util.StringUtils;
52+
import org.jetbrains.annotations.Blocking;
53+
import org.jetbrains.annotations.NonBlocking;
5154
import org.jetbrains.annotations.Nullable;
5255

5356
/**
@@ -1214,9 +1217,10 @@ public void getMessageAsync(String serial, Callback<Message> callback) {
12141217
* Only non-null fields will be applied to the existing message.
12151218
* @param operation operation metadata such as clientId, description, or metadata in the version field
12161219
* @throws AblyException If the update operation fails.
1220+
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
12171221
*/
1218-
public void updateMessage(Message message, MessageOperation operation) throws AblyException {
1219-
messageEditsMixin.updateMessage(ably.http, message, operation);
1222+
public UpdateDeleteResult updateMessage(Message message, MessageOperation operation) throws AblyException {
1223+
return messageEditsMixin.updateMessage(ably.http, message, operation);
12201224
}
12211225

12221226
/**
@@ -1228,34 +1232,35 @@ public void updateMessage(Message message, MessageOperation operation) throws Ab
12281232
* @param message A {@link Message} object containing the fields to update and the serial identifier.
12291233
* Only non-null fields will be applied to the existing message.
12301234
* @throws AblyException If the update operation fails.
1235+
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
12311236
*/
1232-
public void updateMessage(Message message) throws AblyException {
1233-
updateMessage(message, null);
1237+
public UpdateDeleteResult updateMessage(Message message) throws AblyException {
1238+
return updateMessage(message, null);
12341239
}
12351240

12361241
/**
12371242
* Asynchronously updates an existing message.
12381243
*
12391244
* @param message A {@link Message} object containing the fields to update and the serial identifier.
12401245
* @param operation operation metadata such as clientId, description, or metadata in the version field
1241-
* @param listener A listener to be notified of the outcome of this operation.
1246+
* @param callback A callback to be notified of the outcome of this operation.
12421247
* <p>
1243-
* This listener is invoked on a background thread.
1248+
* This callback is invoked on a background thread.
12441249
*/
1245-
public void updateMessageAsync(Message message, MessageOperation operation, CompletionListener listener) {
1246-
messageEditsMixin.updateMessageAsync(ably.http, message, operation, listener);
1250+
public void updateMessageAsync(Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
1251+
messageEditsMixin.updateMessageAsync(ably.http, message, operation, callback);
12471252
}
12481253

12491254
/**
12501255
* Asynchronously updates an existing message.
12511256
*
12521257
* @param message A {@link Message} object containing the fields to update and the serial identifier.
1253-
* @param listener A listener to be notified of the outcome of this operation.
1258+
* @param callback A callback to be notified of the outcome of this operation.
12541259
* <p>
1255-
* This listener is invoked on a background thread.
1260+
* This callback is invoked on a background thread.
12561261
*/
1257-
public void updateMessageAsync(Message message, CompletionListener listener) {
1258-
updateMessageAsync(message, null, listener);
1262+
public void updateMessageAsync(Message message, Callback<UpdateDeleteResult> callback) {
1263+
updateMessageAsync(message, null, callback);
12591264
}
12601265

12611266
/**
@@ -1268,9 +1273,10 @@ public void updateMessageAsync(Message message, CompletionListener listener) {
12681273
* @param message A {@link Message} message containing the serial identifier.
12691274
* @param operation operation metadata such as clientId, description, or metadata in the version field
12701275
* @throws AblyException If the delete operation fails.
1276+
* @return A {@link UpdateDeleteResult} containing the deleted message version serial.
12711277
*/
1272-
public void deleteMessage(Message message, MessageOperation operation) throws AblyException {
1273-
messageEditsMixin.deleteMessage(ably.http, message, operation);
1278+
public UpdateDeleteResult deleteMessage(Message message, MessageOperation operation) throws AblyException {
1279+
return messageEditsMixin.deleteMessage(ably.http, message, operation);
12741280
}
12751281

12761282
/**
@@ -1282,34 +1288,83 @@ public void deleteMessage(Message message, MessageOperation operation) throws Ab
12821288
*
12831289
* @param message A {@link Message} message containing the serial identifier.
12841290
* @throws AblyException If the delete operation fails.
1291+
* @return A {@link UpdateDeleteResult} containing the deleted message version serial.
12851292
*/
1286-
public void deleteMessage(Message message) throws AblyException {
1287-
deleteMessage(message, null);
1293+
public UpdateDeleteResult deleteMessage(Message message) throws AblyException {
1294+
return deleteMessage(message, null);
12881295
}
12891296

12901297
/**
12911298
* Asynchronously marks a message as deleted.
12921299
*
12931300
* @param message A {@link Message} object containing the serial identifier and operation metadata.
12941301
* @param operation operation metadata such as clientId, description, or metadata in the version field
1295-
* @param listener A listener to be notified of the outcome of this operation.
1302+
* @param callback A callback to be notified of the outcome of this operation.
12961303
* <p>
1297-
* This listener is invoked on a background thread.
1304+
* This callback is invoked on a background thread.
12981305
*/
1299-
public void deleteMessageAsync(Message message, MessageOperation operation, CompletionListener listener) {
1300-
messageEditsMixin.deleteMessageAsync(ably.http, message, operation, listener);
1306+
public void deleteMessageAsync(Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
1307+
messageEditsMixin.deleteMessageAsync(ably.http, message, operation, callback);
13011308
}
13021309

13031310
/**
13041311
* Asynchronously marks a message as deleted.
13051312
*
13061313
* @param message A {@link Message} object containing the serial identifier and operation metadata.
1307-
* @param listener A listener to be notified of the outcome of this operation.
1314+
* @param callback A callback to be notified of the outcome of this operation.
13081315
* <p>
1309-
* This listener is invoked on a background thread.
1316+
* This callback is invoked on a background thread.
1317+
*/
1318+
public void deleteMessageAsync(Message message, Callback<UpdateDeleteResult> callback) {
1319+
deleteMessageAsync(message, null, callback);
1320+
}
1321+
1322+
/**
1323+
* Appends message text to the end of the message data.
1324+
*
1325+
* @param message A {@link Message} object containing the serial identifier and data to append.
1326+
* @param operation operation details such as clientId, description, or metadata
1327+
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
1328+
* @throws AblyException If the append operation fails.
1329+
*/
1330+
public UpdateDeleteResult appendMessage(Message message, MessageOperation operation) throws AblyException {
1331+
return messageEditsMixin.appendMessage(ably.http, message, operation);
1332+
}
1333+
1334+
/**
1335+
* Appends message text to the end of the message.
1336+
*
1337+
* @param message A {@link Message} object containing the serial identifier and data to append.
1338+
* @return A {@link UpdateDeleteResult} containing the updated message version serial.
1339+
* @throws AblyException If the append operation fails.
1340+
*/
1341+
public UpdateDeleteResult appendMessage(Message message) throws AblyException {
1342+
return appendMessage(message, null);
1343+
}
1344+
1345+
/**
1346+
* Asynchronously appends message text to the end of the message.
1347+
*
1348+
* @param message A {@link Message} object containing the serial identifier and data to append.
1349+
* @param operation operation details such as clientId, description, or metadata
1350+
* @param callback A callback to be notified of the outcome of this operation.
1351+
* <p>
1352+
* This callback is invoked on a background thread.
1353+
*/
1354+
public void appendMessageAsync(Message message, MessageOperation operation, Callback<UpdateDeleteResult> callback) {
1355+
messageEditsMixin.appendMessageAsync(ably.http, message, operation, callback);
1356+
}
1357+
1358+
/**
1359+
* Asynchronously appends message text to the end of the message.
1360+
*
1361+
* @param message A {@link Message} object containing the serial identifier and data to append.
1362+
* @param callback A callback to be notified of the outcome of this operation.
1363+
* <p>
1364+
* This callback is invoked on a background thread.
13101365
*/
1311-
public void deleteMessageAsync(Message message, CompletionListener listener) {
1312-
deleteMessageAsync(message, null, listener);
1366+
public void appendMessageAsync(Message message, Callback<UpdateDeleteResult> callback) {
1367+
appendMessageAsync(message, null, callback);
13131368
}
13141369

13151370
/**
@@ -1325,6 +1380,7 @@ public void deleteMessageAsync(Message message, CompletionListener listener) {
13251380
* representing all versions of the message.
13261381
* @throws AblyException If the versions cannot be retrieved.
13271382
*/
1383+
@Blocking
13281384
public PaginatedResult<Message> getMessageVersions(String serial, Param[] params) throws AblyException {
13291385
return messageEditsMixin.getMessageVersions(ably.http, serial, params);
13301386
}
@@ -1336,6 +1392,7 @@ public PaginatedResult<Message> getMessageVersions(String serial, Param[] params
13361392
* @param params Query parameters for filtering or pagination.
13371393
* @param callback A callback to handle the result asynchronously.
13381394
*/
1395+
@NonBlocking
13391396
public void getMessageVersionsAsync(String serial, Param[] params, Callback<AsyncPaginatedResult<Message>> callback) throws AblyException {
13401397
messageEditsMixin.getMessageVersionsAsync(ably.http, serial, params, callback);
13411398
}

0 commit comments

Comments
 (0)