Skip to content

Commit

Permalink
Set traceId for topic sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
alex268 committed Jan 13, 2025
1 parent ccb2a17 commit 9c98639
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 78 deletions.
8 changes: 6 additions & 2 deletions topic/src/main/java/tech/ydb/topic/TopicRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ CompletableFuture<Result<YdbTopic.DescribeConsumerResult>> describeConsumer(
CompletableFuture<Status> updateOffsetsInTransaction(YdbTopic.UpdateOffsetsInTransactionRequest request,
GrpcRequestSettings settings);

GrpcReadWriteStream<YdbTopic.StreamWriteMessage.FromServer, YdbTopic.StreamWriteMessage.FromClient> writeSession();
GrpcReadWriteStream<YdbTopic.StreamWriteMessage.FromServer, YdbTopic.StreamWriteMessage.FromClient> writeSession(
String traceId
);

GrpcReadWriteStream<YdbTopic.StreamReadMessage.FromServer, YdbTopic.StreamReadMessage.FromClient> readSession();
GrpcReadWriteStream<YdbTopic.StreamReadMessage.FromServer, YdbTopic.StreamReadMessage.FromClient> readSession(
String traceId
);

ScheduledExecutorService getScheduler();
}
24 changes: 12 additions & 12 deletions topic/src/main/java/tech/ydb/topic/impl/GrpcTopicRpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ public CompletableFuture<Status> updateOffsetsInTransaction(YdbTopic.UpdateOffse
}

@Override
public GrpcReadWriteStream<
YdbTopic.StreamWriteMessage.FromServer,
YdbTopic.StreamWriteMessage.FromClient
> writeSession() {
return transport.readWriteStreamCall(TopicServiceGrpc.getStreamWriteMethod(),
GrpcRequestSettings.newBuilder().build());
public GrpcReadWriteStream<YdbTopic.StreamWriteMessage.FromServer, YdbTopic.StreamWriteMessage.FromClient>
writeSession(String streamId) {
return transport.readWriteStreamCall(
TopicServiceGrpc.getStreamWriteMethod(),
GrpcRequestSettings.newBuilder().withTraceId(streamId).build()
);
}

@Override
public GrpcReadWriteStream<
YdbTopic.StreamReadMessage.FromServer,
YdbTopic.StreamReadMessage.FromClient
> readSession() {
return transport.readWriteStreamCall(TopicServiceGrpc.getStreamReadMethod(),
GrpcRequestSettings.newBuilder().build());
public GrpcReadWriteStream<YdbTopic.StreamReadMessage.FromServer, YdbTopic.StreamReadMessage.FromClient>
readSession(String streamId) {
return transport.readWriteStreamCall(
TopicServiceGrpc.getStreamReadMethod(),
GrpcRequestSettings.newBuilder().withTraceId(streamId).build()
);
}

@Override
Expand Down
7 changes: 5 additions & 2 deletions topic/src/main/java/tech/ydb/topic/read/impl/ReadSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
public abstract class ReadSession extends SessionBase<FromServer, FromClient> {
private static final Logger logger = LoggerFactory.getLogger(ReadSession.class);

public ReadSession(TopicRpc rpc) {
super(rpc.readSession());
protected final String streamId;

public ReadSession(TopicRpc rpc, String streamId) {
super(rpc.readSession(streamId));
this.streamId = streamId;
}

@Override
Expand Down
Loading

0 comments on commit 9c98639

Please sign in to comment.