Skip to content

Commit 3be4569

Browse files
fix: Generate Java Code from plugin-pb (#280)
This PR was created by a scheduled workflow to regenerate the Java code from `plugin-pb`.
1 parent 36ab559 commit 3be4569

7 files changed

Lines changed: 2544 additions & 156 deletions

File tree

‎build/generated/proto-resources/main/cloudquery/plugin/v3/plugin.proto‎

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ service Plugin {
3838
// Assess how the destination plugin would apply table schema changes, without writing anything.
3939
// Plugins that do not support assessment return Unimplemented.
4040
rpc AssessTables(AssessTables.Request) returns (AssessTables.Response);
41+
// Write resources, like Write, and also accept Write.MessageFlush.
42+
// The plugin sends one Write.Response per Write.MessageFlush, once it has tried to commit every message sent before
43+
// the flush. Write.Response.flush_error is set if some messages sent since the previous flush may not have been
44+
// committed.
45+
// Only use it with plugins that set Init.Response.supports_flush.
46+
rpc WriteStream(stream Write.Request) returns (stream Write.Response);
4147
}
4248

4349
message GetName {
@@ -69,7 +75,10 @@ message Init {
6975
bool no_connection = 2; // A flag to indicate plugins should skip establishing a connection
7076
string invocation_id = 3; // unique execution_id that will identify the invocation (sync, migrate etc)
7177
}
72-
message Response {}
78+
message Response {
79+
// The plugin supports WriteStream and Write.MessageFlush
80+
bool supports_flush = 1;
81+
}
7382
}
7483

7584
message GetTables {
@@ -102,6 +111,19 @@ message Sync {
102111
string table_name = 1;
103112
string error = 2;
104113
}
114+
// State backend rows to persist once every message sent before the checkpoint is committed to all destinations.
115+
// Only sent when Sync.Request.supports_checkpoints is set.
116+
//
117+
// The record must:
118+
// - have the cq:table_name schema metadata set to Sync.BackendOptions.table_name
119+
// - have a "key" column and a "value" column, both of the arrow utf8 type (not large_utf8)
120+
// - have a "version" column of the arrow uint64 type, if the state table has one
121+
// - hold only the keys that changed. Each row is an upsert of its key; keys not in the record keep their state.
122+
// When the same key is in several checkpoints, the row with the highest version wins, or the last row without a version column.
123+
message MessageCheckpoint {
124+
// marshalled arrow.Record
125+
bytes record = 1;
126+
}
105127

106128

107129
message BackendOptions {
@@ -122,13 +144,17 @@ message Sync {
122144
BackendOptions backend = 5;
123145
optional Shard shard = 6;
124146
bool withErrorMessages = 7; // If true, the plugin will send error messages in the response stream
147+
// If true, the client persists state backend writes from Sync.MessageCheckpoint,
148+
// so the plugin sends them on the stream instead of writing to the state backend
149+
bool supports_checkpoints = 8;
125150
}
126151
message Response {
127152
oneof message {
128153
Sync.MessageMigrateTable migrate_table = 1;
129154
Sync.MessageInsert insert = 2;
130155
Sync.MessageDeleteRecord delete_record = 3;
131156
Sync.MessageError error = 4;
157+
Sync.MessageCheckpoint checkpoint = 5;
132158
}
133159
}
134160
}
@@ -198,15 +224,30 @@ message Write {
198224
repeated PredicatesGroup where_clause = 2;
199225
repeated TableRelation table_relations = 3;
200226
}
227+
// Commit every message sent before this one. Only valid on WriteStream.
228+
message MessageFlush {
229+
uint64 id = 1;
230+
}
201231
message Request {
202232
oneof message {
203233
Write.MessageMigrateTable migrate_table = 1;
204234
Write.MessageInsert insert = 2;
205235
Write.MessageDeleteStale delete = 3;
206-
Write.MessageDeleteRecord delete_record = 4;
236+
Write.MessageDeleteRecord delete_record = 4;
237+
Write.MessageFlush flush = 5;
207238
}
208239
}
209-
message Response {}
240+
message Response {
241+
// WriteStream only: id of the Write.MessageFlush that completed
242+
uint64 flush_id = 1;
243+
// WriteStream only: why some messages sent since the previous flush may not have been committed. A failure may be
244+
// reported only once, so a later flush can succeed although earlier messages were lost: clients must treat the
245+
// first failure as final. A plugin may end the stream after reporting a failure, or instead of reporting it.
246+
string flush_error = 2;
247+
// WriteStream only: with flush_error, the tables whose messages may not have been committed. Empty if the plugin
248+
// cannot tell, in which case messages of any table may have been lost.
249+
repeated string failed_tables = 3;
250+
}
210251
}
211252

212253
message Transform {

‎build/generated/sources/proto/main/grpc/io/cloudquery/plugin/v3/PluginGrpc.java‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,37 @@ io.cloudquery.plugin.v3.AssessTables.Response> getAssessTablesMethod() {
415415
return getAssessTablesMethod;
416416
}
417417

418+
private static volatile io.grpc.MethodDescriptor<io.cloudquery.plugin.v3.Write.Request,
419+
io.cloudquery.plugin.v3.Write.Response> getWriteStreamMethod;
420+
421+
@io.grpc.stub.annotations.RpcMethod(
422+
fullMethodName = SERVICE_NAME + '/' + "WriteStream",
423+
requestType = io.cloudquery.plugin.v3.Write.Request.class,
424+
responseType = io.cloudquery.plugin.v3.Write.Response.class,
425+
methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
426+
public static io.grpc.MethodDescriptor<io.cloudquery.plugin.v3.Write.Request,
427+
io.cloudquery.plugin.v3.Write.Response> getWriteStreamMethod() {
428+
io.grpc.MethodDescriptor<io.cloudquery.plugin.v3.Write.Request, io.cloudquery.plugin.v3.Write.Response> getWriteStreamMethod;
429+
if ((getWriteStreamMethod = PluginGrpc.getWriteStreamMethod) == null) {
430+
synchronized (PluginGrpc.class) {
431+
if ((getWriteStreamMethod = PluginGrpc.getWriteStreamMethod) == null) {
432+
PluginGrpc.getWriteStreamMethod = getWriteStreamMethod =
433+
io.grpc.MethodDescriptor.<io.cloudquery.plugin.v3.Write.Request, io.cloudquery.plugin.v3.Write.Response>newBuilder()
434+
.setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING)
435+
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "WriteStream"))
436+
.setSampledToLocalTracing(true)
437+
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
438+
io.cloudquery.plugin.v3.Write.Request.getDefaultInstance()))
439+
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
440+
io.cloudquery.plugin.v3.Write.Response.getDefaultInstance()))
441+
.setSchemaDescriptor(new PluginMethodDescriptorSupplier("WriteStream"))
442+
.build();
443+
}
444+
}
445+
}
446+
return getWriteStreamMethod;
447+
}
448+
418449
/**
419450
* Creates a new async stub that supports all call types for the service
420451
*/
@@ -611,6 +642,20 @@ default void assessTables(io.cloudquery.plugin.v3.AssessTables.Request request,
611642
io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.AssessTables.Response> responseObserver) {
612643
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getAssessTablesMethod(), responseObserver);
613644
}
645+
646+
/**
647+
* <pre>
648+
* Write resources, like Write, and also accept Write.MessageFlush.
649+
* The plugin sends one Write.Response per Write.MessageFlush, once it has tried to commit every message sent before
650+
* the flush. Write.Response.flush_error is set if some messages sent since the previous flush may not have been
651+
* committed.
652+
* Only use it with plugins that set Init.Response.supports_flush.
653+
* </pre>
654+
*/
655+
default io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.Write.Request> writeStream(
656+
io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.Write.Response> responseObserver) {
657+
return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall(getWriteStreamMethod(), responseObserver);
658+
}
614659
}
615660

616661
/**
@@ -786,6 +831,21 @@ public void assessTables(io.cloudquery.plugin.v3.AssessTables.Request request,
786831
io.grpc.stub.ClientCalls.asyncUnaryCall(
787832
getChannel().newCall(getAssessTablesMethod(), getCallOptions()), request, responseObserver);
788833
}
834+
835+
/**
836+
* <pre>
837+
* Write resources, like Write, and also accept Write.MessageFlush.
838+
* The plugin sends one Write.Response per Write.MessageFlush, once it has tried to commit every message sent before
839+
* the flush. Write.Response.flush_error is set if some messages sent since the previous flush may not have been
840+
* committed.
841+
* Only use it with plugins that set Init.Response.supports_flush.
842+
* </pre>
843+
*/
844+
public io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.Write.Request> writeStream(
845+
io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.Write.Response> responseObserver) {
846+
return io.grpc.stub.ClientCalls.asyncBidiStreamingCall(
847+
getChannel().newCall(getWriteStreamMethod(), getCallOptions()), responseObserver);
848+
}
789849
}
790850

791851
/**
@@ -945,6 +1005,22 @@ public io.cloudquery.plugin.v3.AssessTables.Response assessTables(io.cloudquery.
9451005
return io.grpc.stub.ClientCalls.blockingV2UnaryCall(
9461006
getChannel(), getAssessTablesMethod(), getCallOptions(), request);
9471007
}
1008+
1009+
/**
1010+
* <pre>
1011+
* Write resources, like Write, and also accept Write.MessageFlush.
1012+
* The plugin sends one Write.Response per Write.MessageFlush, once it has tried to commit every message sent before
1013+
* the flush. Write.Response.flush_error is set if some messages sent since the previous flush may not have been
1014+
* committed.
1015+
* Only use it with plugins that set Init.Response.supports_flush.
1016+
* </pre>
1017+
*/
1018+
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918")
1019+
public io.grpc.stub.BlockingClientCall<io.cloudquery.plugin.v3.Write.Request, io.cloudquery.plugin.v3.Write.Response>
1020+
writeStream() {
1021+
return io.grpc.stub.ClientCalls.blockingBidiStreamingCall(
1022+
getChannel(), getWriteStreamMethod(), getCallOptions());
1023+
}
9481024
}
9491025

9501026
/**
@@ -1212,6 +1288,7 @@ public com.google.common.util.concurrent.ListenableFuture<io.cloudquery.plugin.v
12121288
private static final int METHODID_ASSESS_TABLES = 10;
12131289
private static final int METHODID_WRITE = 11;
12141290
private static final int METHODID_TRANSFORM = 12;
1291+
private static final int METHODID_WRITE_STREAM = 13;
12151292

12161293
private static final class MethodHandlers<Req, Resp> implements
12171294
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
@@ -1290,6 +1367,9 @@ public io.grpc.stub.StreamObserver<Req> invoke(
12901367
case METHODID_TRANSFORM:
12911368
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.transform(
12921369
(io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.Transform.Response>) responseObserver);
1370+
case METHODID_WRITE_STREAM:
1371+
return (io.grpc.stub.StreamObserver<Req>) serviceImpl.writeStream(
1372+
(io.grpc.stub.StreamObserver<io.cloudquery.plugin.v3.Write.Response>) responseObserver);
12931373
default:
12941374
throw new AssertionError();
12951375
}
@@ -1389,6 +1469,13 @@ public static final io.grpc.ServerServiceDefinition bindService(AsyncService ser
13891469
io.cloudquery.plugin.v3.AssessTables.Request,
13901470
io.cloudquery.plugin.v3.AssessTables.Response>(
13911471
service, METHODID_ASSESS_TABLES)))
1472+
.addMethod(
1473+
getWriteStreamMethod(),
1474+
io.grpc.stub.ServerCalls.asyncBidiStreamingCall(
1475+
new MethodHandlers<
1476+
io.cloudquery.plugin.v3.Write.Request,
1477+
io.cloudquery.plugin.v3.Write.Response>(
1478+
service, METHODID_WRITE_STREAM)))
13921479
.build();
13931480
}
13941481

@@ -1450,6 +1537,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
14501537
.addMethod(getCloseMethod())
14511538
.addMethod(getTestConnectionMethod())
14521539
.addMethod(getAssessTablesMethod())
1540+
.addMethod(getWriteStreamMethod())
14531541
.build();
14541542
}
14551543
}

0 commit comments

Comments
 (0)