flyrain commented on code in PR #2720:
URL: https://github.com/apache/polaris/pull/2720#discussion_r2392769717
##########
runtime/service/src/main/java/org/apache/polaris/service/tracing/RequestIdGenerator.java:
##########
@@ -19,38 +19,21 @@
package org.apache.polaris.service.tracing;
-import com.google.common.annotations.VisibleForTesting;
-import jakarta.enterprise.context.ApplicationScoped;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
+import io.smallrye.mutiny.Uni;
+import jakarta.ws.rs.container.ContainerRequestContext;
-@ApplicationScoped
-public class RequestIdGenerator {
- static final Long COUNTER_SOFT_MAX = Long.MAX_VALUE / 2;
-
- record State(String uuid, long counter) {
-
- State() {
- this(UUID.randomUUID().toString(), 1);
- }
-
- String requestId() {
- return String.format("%s_%019d", uuid, counter);
- }
-
- State increment() {
- return counter >= COUNTER_SOFT_MAX ? new State() : new State(uuid,
counter + 1);
- }
- }
-
- final AtomicReference<State> state = new AtomicReference<>(new State());
-
- public String generateRequestId() {
- return state.getAndUpdate(State::increment).requestId();
- }
-
- @VisibleForTesting
- public void setCounter(long counter) {
- state.set(new State(state.get().uuid, counter));
- }
+/**
+ * A generator for request IDs.
+ *
+ * @see RequestIdFilter
+ */
+public interface RequestIdGenerator {
+
+ /**
+ * Generates a new request ID. IDs must be fast to generate and unique. If
the generation involves
+ * I/O (which is not recommended), it should be performed asynchronously.
Review Comment:
Can we remove these comments, if I/O involving is not recommended?
```suggestion
* Generates a new request ID. IDs must be fast to generate and unique.
```
--
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]