Skip to content

Commit 446589f

Browse files
committed
Update proto files
1 parent 83434de commit 446589f

21 files changed

Lines changed: 879 additions & 246 deletions

src/main/java/io/kurrent/dbclient/AppendStreamFailure.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.kurrent.dbclient;
22

33
public class AppendStreamFailure {
4-
private final io.kurrentdb.v2.AppendStreamFailure inner;
4+
private final io.kurrentdb.protocol.streams.v2.AppendStreamFailure inner;
55

6-
AppendStreamFailure(io.kurrentdb.v2.AppendStreamFailure inner) {
6+
AppendStreamFailure(io.kurrentdb.protocol.streams.v2.AppendStreamFailure inner) {
77
this.inner = inner;
88
}
99

@@ -12,21 +12,21 @@ public String getStreamName() {
1212
}
1313

1414
public void visit(MultiAppendStreamErrorVisitor visitor) {
15-
if (this.inner.getErrorCase() == io.kurrentdb.v2.AppendStreamFailure.ErrorCase.WRONG_EXPECTED_REVISION) {
16-
visitor.onWrongExpectedRevision(this.inner.getWrongExpectedRevision().getStreamRevision());
15+
if (this.inner.getErrorCase() == io.kurrentdb.protocol.streams.v2.AppendStreamFailure.ErrorCase.STREAM_REVISION_CONFLICT) {
16+
visitor.onWrongExpectedRevision(this.inner.getStreamRevisionConflict().getStreamRevision());
1717
return;
1818
}
1919

20-
if (this.inner.getErrorCase() == io.kurrentdb.v2.AppendStreamFailure.ErrorCase.ACCESS_DENIED) {
21-
visitor.onAccessDenied(this.inner.getAccessDenied().getReason());
20+
if (this.inner.getErrorCase() == io.kurrentdb.protocol.streams.v2.AppendStreamFailure.ErrorCase.ACCESS_DENIED) {
21+
visitor.onAccessDenied(this.inner.getAccessDenied());
2222
}
2323

24-
if (this.inner.getErrorCase() == io.kurrentdb.v2.AppendStreamFailure.ErrorCase.STREAM_DELETED) {
24+
if (this.inner.getErrorCase() == io.kurrentdb.protocol.streams.v2.AppendStreamFailure.ErrorCase.STREAM_DELETED) {
2525
visitor.onStreamDeleted();
2626
return;
2727
}
2828

29-
if (this.inner.getErrorCase() == io.kurrentdb.v2.AppendStreamFailure.ErrorCase.TRANSACTION_MAX_SIZE_EXCEEDED) {
29+
if (this.inner.getErrorCase() == io.kurrentdb.protocol.streams.v2.AppendStreamFailure.ErrorCase.TRANSACTION_MAX_SIZE_EXCEEDED) {
3030
visitor.onTransactionMaxSizeExceeded(this.inner.getTransactionMaxSizeExceeded().getMaxSize());
3131
return;
3232
}

src/main/java/io/kurrent/dbclient/AppendStreamSuccess.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.kurrent.dbclient;
22

33
public class AppendStreamSuccess {
4-
private final io.kurrentdb.v2.AppendStreamSuccess inner;
4+
private final io.kurrentdb.protocol.streams.v2.AppendStreamSuccess inner;
55

6-
AppendStreamSuccess(io.kurrentdb.v2.AppendStreamSuccess inner) {
6+
AppendStreamSuccess(io.kurrentdb.protocol.streams.v2.AppendStreamSuccess inner) {
77
this.inner = inner;
88
}
99

src/main/java/io/kurrent/dbclient/ConnectionSettingsBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public class ConnectionSettingsBuilder {
1818
private static final Logger logger = LoggerFactory.getLogger(ConnectionSettingsBuilder.class);
1919
private static final Set<String> SUPPORTED_PROTOCOLS = new HashSet<>(Arrays.asList(
20-
"esdb", "esdb+discover", "kurrent", "kurrent+discover", "kdb", "kdb+discover", "kurrentdb", "kurrentdb+discover"
20+
"esdb", "esdb+discover", "kurrentdb", "kurrent+discover", "kdb", "kdb+discover", "kurrentdb", "kurrentdb+discover"
2121
));
2222

2323
private boolean _dnsDiscover = false;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.kurrent.dbclient;
2+
3+
import java.util.Collections;
4+
import java.util.HashMap;
5+
import java.util.Map;
6+
7+
public class ContentTypeMapper {
8+
private static final Map<String, String> CONTENT_TYPE_MAP;
9+
10+
static {
11+
Map<String, String> map = new HashMap<>();
12+
map.put("application/json", "Json");
13+
map.put("application/octet-stream", "Binary");
14+
CONTENT_TYPE_MAP = Collections.unmodifiableMap(map);
15+
}
16+
17+
public static String toSchemaDataFormat(String contentType) {
18+
return CONTENT_TYPE_MAP.getOrDefault(contentType, contentType);
19+
}
20+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package io.kurrent.dbclient;
22

3+
import io.kurrentdb.protocol.streams.v2.ErrorDetails;
4+
35
public interface MultiAppendStreamErrorVisitor {
46
default void onWrongExpectedRevision(long streamRevision) {}
5-
default void onAccessDenied(String reason) {}
7+
default void onAccessDenied(ErrorDetails.AccessDenied detail) {}
68
default void onStreamDeleted() {}
79
default void onTransactionMaxSizeExceeded(int maxSize) {}
810
}

src/main/java/io/kurrent/dbclient/MultiStreamAppend.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import io.grpc.Metadata;
55
import io.grpc.StatusRuntimeException;
66
import io.grpc.stub.StreamObserver;
7-
import io.kurrentdb.v2.AppendRecord;
8-
import io.kurrentdb.v2.MultiStreamAppendResponse;
9-
import io.kurrentdb.v2.StreamsServiceGrpc;
10-
import kurrentdb.protobuf.DynamicValueOuterClass;
7+
import io.kurrentdb.protocol.DynamicValue;
8+
import io.kurrentdb.protocol.streams.v2.AppendRecord;
9+
import io.kurrentdb.protocol.streams.v2.MultiStreamAppendResponse;
10+
import io.kurrentdb.protocol.streams.v2.StreamsServiceGrpc;
1111

1212
import java.util.ArrayList;
1313
import java.util.Iterator;
@@ -36,28 +36,26 @@ private CompletableFuture<MultiAppendWriteResult> append(WorkItemArgs args) {
3636
}
3737

3838
StreamsServiceGrpc.StreamsServiceStub client = GrpcUtils.configureStub(StreamsServiceGrpc.newStub(args.getChannel()), this.client.getSettings(), new OptionsBase<>(), null, false);
39-
StreamObserver<io.kurrentdb.v2.AppendStreamRequest> requestStream = client.multiStreamAppendSession(GrpcUtils.convertSingleResponse(result, this::onResponse));
39+
StreamObserver<io.kurrentdb.protocol.streams.v2.AppendStreamRequest> requestStream = client.multiStreamAppendSession(GrpcUtils.convertSingleResponse(result, this::onResponse));
4040

4141
try {
4242
while (this.requests.hasNext()) {
4343
AppendStreamRequest request = this.requests.next();
44-
io.kurrentdb.v2.AppendStreamRequest.Builder builder = io.kurrentdb.v2.AppendStreamRequest.newBuilder()
44+
io.kurrentdb.protocol.streams.v2.AppendStreamRequest.Builder builder = io.kurrentdb.protocol.streams.v2.AppendStreamRequest.newBuilder()
4545
.setStream(request.getStreamName());
4646

4747
while (request.getEvents().hasNext()) {
4848
EventData event = request.getEvents().next();
4949
builder.addRecords(AppendRecord.newBuilder()
5050
.setData(ByteString.copyFrom(event.getEventData()))
5151
.setRecordId(event.getEventId().toString())
52-
.putProperties(SystemMetadataKeys.DATA_FORMAT, DynamicValueOuterClass
53-
.DynamicValue
52+
.putProperties(SystemMetadataKeys.DATA_FORMAT, DynamicValue
5453
.newBuilder()
55-
.setBytesValue(ByteString.copyFromUtf8(event.getContentType()))
54+
.setStringValue(ContentTypeMapper.toSchemaDataFormat(event.getContentType()))
5655
.build())
57-
.putProperties(SystemMetadataKeys.SCHEMA_NAME, DynamicValueOuterClass
58-
.DynamicValue
56+
.putProperties(SystemMetadataKeys.SCHEMA_NAME, DynamicValue
5957
.newBuilder()
60-
.setBytesValue(ByteString.copyFromUtf8(event.getEventType()))
58+
.setStringValue(event.getEventType())
6159
.build())
6260
.build());
6361
}
@@ -93,13 +91,13 @@ public MultiAppendWriteResult onResponse(MultiStreamAppendResponse response) {
9391
if (response.hasFailure()) {
9492
failures = new ArrayList<>(response.getFailure().getOutputCount());
9593

96-
for (io.kurrentdb.v2.AppendStreamFailure failure : response.getFailure().getOutputList()) {
94+
for (io.kurrentdb.protocol.streams.v2.AppendStreamFailure failure : response.getFailure().getOutputList()) {
9795
failures.add(new AppendStreamFailure(failure));
9896
}
9997
} else {
10098
successes = new ArrayList<>(response.getSuccess().getOutputCount());
10199

102-
for (io.kurrentdb.v2.AppendStreamSuccess success : response.getSuccess().getOutputList()) {
100+
for (io.kurrentdb.protocol.streams.v2.AppendStreamSuccess success : response.getSuccess().getOutputList()) {
103101
successes.add(new AppendStreamSuccess(success));
104102
}
105103
}

src/main/proto/dynamic-value.proto

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/main/proto/code.proto renamed to src/main/proto/kurrentdb/protocol/v1/code.proto

File renamed without changes.

src/main/proto/gossip.proto renamed to src/main/proto/kurrentdb/protocol/v1/gossip.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ syntax = "proto3";
22
package event_store.client.gossip;
33
option java_package = "io.kurrent.dbclient.proto.gossip";
44

5-
import "shared.proto";
5+
import "kurrentdb/protocol/v1/shared.proto";
66

77
service Gossip {
88
rpc Read (event_store.client.Empty) returns (ClusterInfo);

src/main/proto/persistent.proto renamed to src/main/proto/kurrentdb/protocol/v1/persistent.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ syntax = "proto3";
22
package event_store.client.persistent_subscriptions;
33
option java_package = "io.kurrent.dbclient.proto.persistentsubscriptions";
44

5-
import "shared.proto";
5+
import "kurrentdb/protocol/v1/shared.proto";
66

77
service PersistentSubscriptions {
88
rpc Create (CreateReq) returns (CreateResp);

0 commit comments

Comments
 (0)