BewareMyPower commented on code in PR #24186:
URL: https://github.com/apache/pulsar/pull/24186#discussion_r2049901357


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/api/MetadataCache.java:
##########
@@ -102,6 +102,22 @@ public interface MetadataCache<T> {
      */
     CompletableFuture<T> readModifyUpdateOrCreate(String path, 
Function<Optional<T>, T> modifyFunction);
 
+    /**
+     * Perform an atomic read-modify-update of the value with the cached 
version.
+     * <p>
+     * This fail-fasts without retries (e.g. fail-fast upon 
BadVersionException)
+     * <p>
+     * If the object does not exist yet, the <code>modifyFunction</code> will 
get passed an {@link Optional#empty()}
+     * object.
+     *
+     * @param path
+     *            the path of the object in the metadata store
+     * @param modifyFunction
+     *            a function that will be passed the current value and returns 
a modified value to be stored
+     * @return a future to track the completion of the operation
+     */
+    CompletableFuture<T> readModifyUpdateOrCreateOnce(String path, 
Function<Optional<T>, T> modifyFunction);

Review Comment:
   It would be better to add a config (e.g. `maxRetries`) to 
`MetadataCacheConfig` rather than adding a new API.
   
   Currently we already have a `retryBackoff` config to control the retry 
backoff. But it cannot prevent the 1st retry.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to