pulsar_sdk 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +51 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE +201 -0
  5. data/README.md +107 -0
  6. data/Rakefile +2 -0
  7. data/bin/console +15 -0
  8. data/bin/setup +8 -0
  9. data/lib/protobuf/pulsar_api.pb.rb +710 -0
  10. data/lib/protobuf/pulsar_api.proto +934 -0
  11. data/lib/protobuf/validate.rb +41 -0
  12. data/lib/pulsar_admin.rb +14 -0
  13. data/lib/pulsar_admin/api.rb +215 -0
  14. data/lib/pulsar_sdk.rb +55 -0
  15. data/lib/pulsar_sdk/client.rb +13 -0
  16. data/lib/pulsar_sdk/client/connection.rb +371 -0
  17. data/lib/pulsar_sdk/client/connection_pool.rb +79 -0
  18. data/lib/pulsar_sdk/client/rpc.rb +67 -0
  19. data/lib/pulsar_sdk/consumer.rb +13 -0
  20. data/lib/pulsar_sdk/consumer/base.rb +148 -0
  21. data/lib/pulsar_sdk/consumer/manager.rb +127 -0
  22. data/lib/pulsar_sdk/consumer/message_tracker.rb +86 -0
  23. data/lib/pulsar_sdk/options.rb +6 -0
  24. data/lib/pulsar_sdk/options/base.rb +10 -0
  25. data/lib/pulsar_sdk/options/connection.rb +51 -0
  26. data/lib/pulsar_sdk/options/consumer.rb +34 -0
  27. data/lib/pulsar_sdk/options/producer.rb +14 -0
  28. data/lib/pulsar_sdk/options/reader.rb +7 -0
  29. data/lib/pulsar_sdk/options/tls.rb +8 -0
  30. data/lib/pulsar_sdk/producer.rb +14 -0
  31. data/lib/pulsar_sdk/producer/base.rb +154 -0
  32. data/lib/pulsar_sdk/producer/manager.rb +67 -0
  33. data/lib/pulsar_sdk/producer/message.rb +47 -0
  34. data/lib/pulsar_sdk/producer/router.rb +100 -0
  35. data/lib/pulsar_sdk/protocol.rb +8 -0
  36. data/lib/pulsar_sdk/protocol/frame.rb +53 -0
  37. data/lib/pulsar_sdk/protocol/lookup.rb +55 -0
  38. data/lib/pulsar_sdk/protocol/message.rb +55 -0
  39. data/lib/pulsar_sdk/protocol/namespace.rb +22 -0
  40. data/lib/pulsar_sdk/protocol/partitioned.rb +54 -0
  41. data/lib/pulsar_sdk/protocol/reader.rb +67 -0
  42. data/lib/pulsar_sdk/protocol/structure.rb +93 -0
  43. data/lib/pulsar_sdk/protocol/topic.rb +74 -0
  44. data/lib/pulsar_sdk/tweaks.rb +10 -0
  45. data/lib/pulsar_sdk/tweaks/assign_attributes.rb +30 -0
  46. data/lib/pulsar_sdk/tweaks/base_command.rb +66 -0
  47. data/lib/pulsar_sdk/tweaks/binary_heap.rb +133 -0
  48. data/lib/pulsar_sdk/tweaks/clean_inspect.rb +15 -0
  49. data/lib/pulsar_sdk/tweaks/time_at_microsecond.rb +27 -0
  50. data/lib/pulsar_sdk/tweaks/timeout_queue.rb +52 -0
  51. data/lib/pulsar_sdk/tweaks/wait_map.rb +81 -0
  52. data/lib/pulsar_sdk/version.rb +3 -0
  53. data/pulsar_sdk.gemspec +31 -0
  54. metadata +151 -0
@@ -0,0 +1,934 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ syntax = "proto2";
20
+
21
+ package pulsar.proto;
22
+ option java_package = "org.apache.pulsar.common.api.proto";
23
+ option optimize_for = LITE_RUNTIME;
24
+
25
+ message Schema {
26
+ enum Type {
27
+ None = 0;
28
+ String = 1;
29
+ Json = 2;
30
+ Protobuf = 3;
31
+ Avro = 4;
32
+ Bool = 5;
33
+ Int8 = 6;
34
+ Int16 = 7;
35
+ Int32 = 8;
36
+ Int64 = 9;
37
+ Float = 10;
38
+ Double = 11;
39
+ Date = 12;
40
+ Time = 13;
41
+ Timestamp = 14;
42
+ KeyValue = 15;
43
+ }
44
+
45
+ required string name = 1;
46
+ required bytes schema_data = 3;
47
+ required Type type = 4;
48
+ repeated KeyValue properties = 5;
49
+
50
+ }
51
+
52
+ message MessageIdData {
53
+ required uint64 ledgerId = 1;
54
+ required uint64 entryId = 2;
55
+ optional int32 partition = 3 [default = -1];
56
+ optional int32 batch_index = 4 [default = -1];
57
+ }
58
+
59
+ message KeyValue {
60
+ required string key = 1;
61
+ required string value = 2;
62
+ }
63
+
64
+ message KeyLongValue {
65
+ required string key = 1;
66
+ required uint64 value = 2;
67
+ }
68
+
69
+ message IntRange {
70
+ required int32 start = 1;
71
+ required int32 end = 2;
72
+ }
73
+
74
+ message EncryptionKeys {
75
+ required string key = 1;
76
+ required bytes value = 2;
77
+ repeated KeyValue metadata = 3;
78
+ }
79
+
80
+ enum CompressionType {
81
+ NONE = 0;
82
+ LZ4 = 1;
83
+ ZLIB = 2;
84
+ ZSTD = 3;
85
+ SNAPPY = 4;
86
+ }
87
+
88
+ message MessageMetadata {
89
+ required string producer_name = 1;
90
+ required uint64 sequence_id = 2;
91
+ required uint64 publish_time = 3;
92
+ repeated KeyValue properties = 4;
93
+
94
+ // Property set on replicated message,
95
+ // includes the source cluster name
96
+ optional string replicated_from = 5;
97
+ //key to decide partition for the msg
98
+ optional string partition_key = 6;
99
+ // Override namespace's replication
100
+ repeated string replicate_to = 7;
101
+ optional CompressionType compression = 8 [default = NONE];
102
+ optional uint32 uncompressed_size = 9 [default = 0];
103
+ // Removed below checksum field from Metadata as
104
+ // it should be part of send-command which keeps checksum of header + payload
105
+ //optional sfixed64 checksum = 10;
106
+ // differentiate single and batch message metadata
107
+ optional int32 num_messages_in_batch = 11 [default = 1];
108
+
109
+ // the timestamp that this event occurs. it is typically set by applications.
110
+ // if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
111
+ optional uint64 event_time = 12 [default = 0];
112
+ // Contains encryption key name, encrypted key and metadata to describe the key
113
+ repeated EncryptionKeys encryption_keys = 13;
114
+ // Algorithm used to encrypt data key
115
+ optional string encryption_algo = 14;
116
+ // Additional parameters required by encryption
117
+ optional bytes encryption_param = 15;
118
+ optional bytes schema_version = 16;
119
+
120
+ optional bool partition_key_b64_encoded = 17 [ default = false ];
121
+ // Specific a key to overwrite the message key which used for ordering dispatch in Key_Shared mode.
122
+ optional bytes ordering_key = 18;
123
+
124
+ // Mark the message to be delivered at or after the specified timestamp
125
+ optional int64 deliver_at_time = 19;
126
+
127
+ // Identify whether a message is a "marker" message used for
128
+ // internal metadata instead of application published data.
129
+ // Markers will generally not be propagated back to clients
130
+ optional int32 marker_type = 20;
131
+
132
+ // transaction related message info
133
+ optional uint64 txnid_least_bits = 22 [default = 0];
134
+ optional uint64 txnid_most_bits = 23 [default = 0];
135
+
136
+ /// Add highest sequence id to support batch message with external sequence id
137
+ optional uint64 highest_sequence_id = 24 [default = 0];
138
+ }
139
+
140
+ message SingleMessageMetadata {
141
+ repeated KeyValue properties = 1;
142
+ optional string partition_key = 2;
143
+ required int32 payload_size = 3;
144
+ optional bool compacted_out = 4 [default = false];
145
+
146
+ // the timestamp that this event occurs. it is typically set by applications.
147
+ // if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
148
+ optional uint64 event_time = 5 [default = 0];
149
+ optional bool partition_key_b64_encoded = 6 [ default = false ];
150
+ // Specific a key to overwrite the message key which used for ordering dispatch in Key_Shared mode.
151
+ optional bytes ordering_key = 7;
152
+ // Allows consumer retrieve the sequence id that the producer set.
153
+ optional uint64 sequence_id = 8;
154
+ }
155
+
156
+ enum ServerError {
157
+ UnknownError = 0;
158
+ MetadataError = 1; // Error with ZK/metadata
159
+ PersistenceError = 2; // Error writing reading from BK
160
+ AuthenticationError = 3; // Non valid authentication
161
+ AuthorizationError = 4; // Not authorized to use resource
162
+
163
+ ConsumerBusy = 5; // Unable to subscribe/unsubscribe because
164
+ // other consumers are connected
165
+ ServiceNotReady = 6; // Any error that requires client retry operation with a fresh lookup
166
+ ProducerBlockedQuotaExceededError = 7; // Unable to create producer because backlog quota exceeded
167
+ ProducerBlockedQuotaExceededException = 8; // Exception while creating producer because quota exceeded
168
+ ChecksumError = 9; // Error while verifying message checksum
169
+ UnsupportedVersionError = 10; // Error when an older client/version doesn't support a required feature
170
+ TopicNotFound = 11; // Topic not found
171
+ SubscriptionNotFound = 12; // Subscription not found
172
+ ConsumerNotFound = 13; // Consumer not found
173
+ TooManyRequests = 14; // Error with too many simultaneously request
174
+ TopicTerminatedError = 15; // The topic has been terminated
175
+
176
+ ProducerBusy = 16; // Producer with same name is already connected
177
+ InvalidTopicName = 17; // The topic name is not valid
178
+
179
+ IncompatibleSchema = 18; // Specified schema was incompatible with topic schema
180
+ ConsumerAssignError = 19; // Dispatcher assign consumer error
181
+
182
+ TransactionCoordinatorNotFound = 20; // Transaction coordinator not found error
183
+ InvalidTxnStatus = 21; // Invalid txn status error
184
+ }
185
+
186
+ enum AuthMethod {
187
+ AuthMethodNone = 0;
188
+ AuthMethodYcaV1 = 1;
189
+ AuthMethodAthens = 2;
190
+ }
191
+
192
+ // Each protocol version identify new features that are
193
+ // incrementally added to the protocol
194
+ enum ProtocolVersion {
195
+ v0 = 0; // Initial versioning
196
+ v1 = 1; // Added application keep-alive
197
+ v2 = 2; // Added RedeliverUnacknowledgedMessages Command
198
+ v3 = 3; // Added compression with LZ4 and ZLib
199
+ v4 = 4; // Added batch message support
200
+ v5 = 5; // Added disconnect client w/o closing connection
201
+ v6 = 6; // Added checksum computation for metadata + payload
202
+ v7 = 7; // Added CommandLookupTopic - Binary Lookup
203
+ v8 = 8; // Added CommandConsumerStats - Client fetches broker side consumer stats
204
+ v9 = 9; // Added end of topic notification
205
+ v10 = 10;// Added proxy to broker
206
+ v11 = 11;// C++ consumers before this version are not correctly handling the checksum field
207
+ v12 = 12;// Added get topic's last messageId from broker
208
+ // Added CommandActiveConsumerChange
209
+ // Added CommandGetTopicsOfNamespace
210
+ v13 = 13; // Schema-registry : added avro schema format for json
211
+ v14 = 14; // Add CommandAuthChallenge and CommandAuthResponse for mutual auth
212
+ // Added Key_Shared subscription
213
+ v15 = 15; // Add CommandGetOrCreateSchema and CommandGetOrCreateSchemaResponse
214
+ }
215
+
216
+ message CommandConnect {
217
+ required string client_version = 1;
218
+ optional AuthMethod auth_method = 2; // Deprecated. Use "auth_method_name" instead.
219
+ optional string auth_method_name = 5;
220
+ optional bytes auth_data = 3;
221
+ optional int32 protocol_version = 4 [default = 0];
222
+
223
+ // Client can ask to be proxyied to a specific broker
224
+ // This is only honored by a Pulsar proxy
225
+ optional string proxy_to_broker_url = 6;
226
+
227
+ // Original principal that was verified by
228
+ // a Pulsar proxy. In this case the auth info above
229
+ // will be the auth of the proxy itself
230
+ optional string original_principal = 7;
231
+
232
+ // Original auth role and auth Method that was passed
233
+ // to the proxy. In this case the auth info above
234
+ // will be the auth of the proxy itself
235
+ optional string original_auth_data = 8;
236
+ optional string original_auth_method = 9;
237
+
238
+ }
239
+
240
+ message CommandConnected {
241
+ required string server_version = 1;
242
+ optional int32 protocol_version = 2 [default = 0];
243
+ optional int32 max_message_size = 3;
244
+ }
245
+
246
+ message CommandAuthResponse {
247
+ optional string client_version = 1;
248
+ optional AuthData response = 2;
249
+ optional int32 protocol_version = 3 [default = 0];
250
+ }
251
+
252
+ message CommandAuthChallenge {
253
+ optional string server_version = 1;
254
+ optional AuthData challenge = 2;
255
+ optional int32 protocol_version = 3 [default = 0];
256
+ }
257
+
258
+ // To support mutual authentication type, such as Sasl, reuse this command to mutual auth.
259
+ message AuthData {
260
+ optional string auth_method_name = 1;
261
+ optional bytes auth_data = 2;
262
+ }
263
+
264
+ enum KeySharedMode {
265
+ AUTO_SPLIT = 0;
266
+ STICKY = 1;
267
+ }
268
+
269
+ message KeySharedMeta {
270
+ required KeySharedMode keySharedMode = 1;
271
+ repeated IntRange hashRanges = 3;
272
+ }
273
+
274
+ message CommandSubscribe {
275
+ enum SubType {
276
+ Exclusive = 0;
277
+ Shared = 1;
278
+ Failover = 2;
279
+ Key_Shared = 3;
280
+ }
281
+ required string topic = 1;
282
+ required string subscription = 2;
283
+ required SubType subType = 3;
284
+
285
+ required uint64 consumer_id = 4;
286
+ required uint64 request_id = 5;
287
+ optional string consumer_name = 6;
288
+ optional int32 priority_level = 7;
289
+
290
+ // Signal wether the subscription should be backed by a
291
+ // durable cursor or not
292
+ optional bool durable = 8 [default = true];
293
+
294
+ // If specified, the subscription will position the cursor
295
+ // markd-delete position on the particular message id and
296
+ // will send messages from that point
297
+ optional MessageIdData start_message_id = 9;
298
+
299
+ /// Add optional metadata key=value to this consumer
300
+ repeated KeyValue metadata = 10;
301
+
302
+ optional bool read_compacted = 11;
303
+
304
+ optional Schema schema = 12;
305
+ enum InitialPosition {
306
+ Latest = 0;
307
+ Earliest = 1;
308
+ }
309
+ // Signal whether the subscription will initialize on latest
310
+ // or not -- earliest
311
+ optional InitialPosition initialPosition = 13 [default = Latest];
312
+
313
+ // Mark the subscription as "replicated". Pulsar will make sure
314
+ // to periodically sync the state of replicated subscriptions
315
+ // across different clusters (when using geo-replication).
316
+ optional bool replicate_subscription_state = 14;
317
+
318
+ // If true, the subscribe operation will cause a topic to be
319
+ // created if it does not exist already (and if topic auto-creation
320
+ // is allowed by broker.
321
+ // If false, the subscribe operation will fail if the topic
322
+ // does not exist.
323
+ optional bool force_topic_creation = 15 [default = true];
324
+
325
+ // If specified, the subscription will reset cursor's position back
326
+ // to specified seconds and will send messages from that point
327
+ optional uint64 start_message_rollback_duration_sec = 16 [default = 0];
328
+
329
+ optional KeySharedMeta keySharedMeta = 17;
330
+ }
331
+
332
+ message CommandPartitionedTopicMetadata {
333
+ required string topic = 1;
334
+ required uint64 request_id = 2;
335
+ // TODO - Remove original_principal, original_auth_data, original_auth_method
336
+ // Original principal that was verified by
337
+ // a Pulsar proxy.
338
+ optional string original_principal = 3;
339
+
340
+ // Original auth role and auth Method that was passed
341
+ // to the proxy.
342
+ optional string original_auth_data = 4;
343
+ optional string original_auth_method = 5;
344
+ }
345
+
346
+ message CommandPartitionedTopicMetadataResponse {
347
+ enum LookupType {
348
+ Success = 0;
349
+ Failed = 1;
350
+ }
351
+ optional uint32 partitions = 1; // Optional in case of error
352
+ required uint64 request_id = 2;
353
+ optional LookupType response = 3;
354
+ optional ServerError error = 4;
355
+ optional string message = 5;
356
+ }
357
+
358
+ message CommandLookupTopic {
359
+ required string topic = 1;
360
+ required uint64 request_id = 2;
361
+ optional bool authoritative = 3 [default = false];
362
+
363
+ // TODO - Remove original_principal, original_auth_data, original_auth_method
364
+ // Original principal that was verified by
365
+ // a Pulsar proxy.
366
+ optional string original_principal = 4;
367
+
368
+ // Original auth role and auth Method that was passed
369
+ // to the proxy.
370
+ optional string original_auth_data = 5;
371
+ optional string original_auth_method = 6;
372
+ }
373
+
374
+ message CommandLookupTopicResponse {
375
+ enum LookupType {
376
+ Redirect = 0;
377
+ Connect = 1;
378
+ Failed = 2;
379
+ }
380
+
381
+ optional string brokerServiceUrl = 1; // Optional in case of error
382
+ optional string brokerServiceUrlTls = 2;
383
+ optional LookupType response = 3;
384
+ required uint64 request_id = 4;
385
+ optional bool authoritative = 5 [default = false];
386
+ optional ServerError error = 6;
387
+ optional string message = 7;
388
+
389
+ // If it's true, indicates to the client that it must
390
+ // always connect through the service url after the
391
+ // lookup has been completed.
392
+ optional bool proxy_through_service_url = 8 [default = false];
393
+ }
394
+
395
+ /// Create a new Producer on a topic, assigning the given producer_id,
396
+ /// all messages sent with this producer_id will be persisted on the topic
397
+ message CommandProducer {
398
+ required string topic = 1;
399
+ required uint64 producer_id = 2;
400
+ required uint64 request_id = 3;
401
+
402
+ /// If a producer name is specified, the name will be used,
403
+ /// otherwise the broker will generate a unique name
404
+ optional string producer_name = 4;
405
+
406
+ optional bool encrypted = 5 [default = false];
407
+
408
+ /// Add optional metadata key=value to this producer
409
+ repeated KeyValue metadata = 6;
410
+
411
+ optional Schema schema = 7;
412
+
413
+ // If producer reconnect to broker, the epoch of this producer will +1
414
+ optional uint64 epoch = 8 [default = 0];
415
+
416
+ // Indicate the name of the producer is generated or user provided
417
+ // Use default true here is in order to be forward compatible with the client
418
+ optional bool user_provided_producer_name = 9 [default = true];
419
+ }
420
+
421
+ message CommandSend {
422
+ required uint64 producer_id = 1;
423
+ required uint64 sequence_id = 2;
424
+ optional int32 num_messages = 3 [default = 1];
425
+ optional uint64 txnid_least_bits = 4 [default = 0];
426
+ optional uint64 txnid_most_bits = 5 [default = 0];
427
+
428
+ /// Add highest sequence id to support batch message with external sequence id
429
+ optional uint64 highest_sequence_id = 6 [default = 0];
430
+ }
431
+
432
+ message CommandSendReceipt {
433
+ required uint64 producer_id = 1;
434
+ required uint64 sequence_id = 2;
435
+ optional MessageIdData message_id = 3;
436
+ optional uint64 highest_sequence_id = 4 [default = 0];
437
+ }
438
+
439
+ message CommandSendError {
440
+ required uint64 producer_id = 1;
441
+ required uint64 sequence_id = 2;
442
+ required ServerError error = 3;
443
+ required string message = 4;
444
+ }
445
+
446
+ message CommandMessage {
447
+ required uint64 consumer_id = 1;
448
+ required MessageIdData message_id = 2;
449
+ optional uint32 redelivery_count = 3 [default = 0];
450
+ }
451
+
452
+ message CommandAck {
453
+ enum AckType {
454
+ Individual = 0;
455
+ Cumulative = 1;
456
+ }
457
+
458
+ required uint64 consumer_id = 1;
459
+ required AckType ack_type = 2;
460
+
461
+ // In case of individual acks, the client can pass a list of message ids
462
+ repeated MessageIdData message_id = 3;
463
+
464
+ // Acks can contain a flag to indicate the consumer
465
+ // received an invalid message that got discarded
466
+ // before being passed on to the application.
467
+ enum ValidationError {
468
+ UncompressedSizeCorruption = 0;
469
+ DecompressionError = 1;
470
+ ChecksumMismatch = 2;
471
+ BatchDeSerializeError = 3;
472
+ DecryptionError = 4;
473
+ }
474
+
475
+ optional ValidationError validation_error = 4;
476
+ repeated KeyLongValue properties = 5;
477
+
478
+ optional uint64 txnid_least_bits = 6 [default = 0];
479
+ optional uint64 txnid_most_bits = 7 [default = 0];
480
+ }
481
+
482
+ message CommandAckResponse {
483
+ required uint64 consumer_id = 1;
484
+ optional uint64 txnid_least_bits = 2 [default = 0];
485
+ optional uint64 txnid_most_bits = 3 [default = 0];
486
+ optional ServerError error = 4;
487
+ optional string message = 5;
488
+ }
489
+
490
+ // changes on active consumer
491
+ message CommandActiveConsumerChange {
492
+ required uint64 consumer_id = 1;
493
+ optional bool is_active = 2 [default = false];
494
+ }
495
+
496
+ message CommandFlow {
497
+ required uint64 consumer_id = 1;
498
+
499
+ // Max number of messages to prefetch, in addition
500
+ // of any number previously specified
501
+ required uint32 messagePermits = 2;
502
+ }
503
+
504
+ message CommandUnsubscribe {
505
+ required uint64 consumer_id = 1;
506
+ required uint64 request_id = 2;
507
+ }
508
+
509
+ // Reset an existing consumer to a particular message id
510
+ message CommandSeek {
511
+ required uint64 consumer_id = 1;
512
+ required uint64 request_id = 2;
513
+
514
+ optional MessageIdData message_id = 3;
515
+ optional uint64 message_publish_time = 4;
516
+ }
517
+
518
+ // Message sent by broker to client when a topic
519
+ // has been forcefully terminated and there are no more
520
+ // messages left to consume
521
+ message CommandReachedEndOfTopic {
522
+ required uint64 consumer_id = 1;
523
+ }
524
+
525
+ message CommandCloseProducer {
526
+ required uint64 producer_id = 1;
527
+ required uint64 request_id = 2;
528
+ }
529
+
530
+ message CommandCloseConsumer {
531
+ required uint64 consumer_id = 1;
532
+ required uint64 request_id = 2;
533
+ }
534
+
535
+ message CommandRedeliverUnacknowledgedMessages {
536
+ required uint64 consumer_id = 1;
537
+ repeated MessageIdData message_ids = 2;
538
+ }
539
+
540
+ message CommandSuccess {
541
+ required uint64 request_id = 1;
542
+ optional Schema schema = 2;
543
+ }
544
+
545
+ /// Response from CommandProducer
546
+ message CommandProducerSuccess {
547
+ required uint64 request_id = 1;
548
+ required string producer_name = 2;
549
+
550
+ // The last sequence id that was stored by this producer in the previous session
551
+ // This will only be meaningful if deduplication has been enabled.
552
+ optional int64 last_sequence_id = 3 [default = -1];
553
+ optional bytes schema_version = 4;
554
+ }
555
+
556
+ message CommandError {
557
+ required uint64 request_id = 1;
558
+ required ServerError error = 2;
559
+ required string message = 3;
560
+ }
561
+
562
+ // Commands to probe the state of connection.
563
+ // When either client or broker doesn't receive commands for certain
564
+ // amount of time, they will send a Ping probe.
565
+ message CommandPing {
566
+ }
567
+ message CommandPong {
568
+ }
569
+
570
+ message CommandConsumerStats {
571
+ required uint64 request_id = 1;
572
+ // required string topic_name = 2;
573
+ // required string subscription_name = 3;
574
+ required uint64 consumer_id = 4;
575
+ }
576
+
577
+ message CommandConsumerStatsResponse {
578
+ required uint64 request_id = 1;
579
+ optional ServerError error_code = 2;
580
+ optional string error_message = 3;
581
+
582
+ /// Total rate of messages delivered to the consumer. msg/s
583
+ optional double msgRateOut = 4;
584
+
585
+ /// Total throughput delivered to the consumer. bytes/s
586
+ optional double msgThroughputOut = 5;
587
+
588
+ /// Total rate of messages redelivered by this consumer. msg/s
589
+ optional double msgRateRedeliver = 6;
590
+
591
+ /// Name of the consumer
592
+ optional string consumerName = 7;
593
+
594
+ /// Number of available message permits for the consumer
595
+ optional uint64 availablePermits = 8;
596
+
597
+ /// Number of unacknowledged messages for the consumer
598
+ optional uint64 unackedMessages = 9;
599
+
600
+ /// Flag to verify if consumer is blocked due to reaching threshold of unacked messages
601
+ optional bool blockedConsumerOnUnackedMsgs = 10;
602
+
603
+ /// Address of this consumer
604
+ optional string address = 11;
605
+
606
+ /// Timestamp of connection
607
+ optional string connectedSince = 12;
608
+
609
+ /// Whether this subscription is Exclusive or Shared or Failover
610
+ optional string type = 13;
611
+
612
+ /// Total rate of messages expired on this subscription. msg/s
613
+ optional double msgRateExpired = 14;
614
+
615
+ /// Number of messages in the subscription backlog
616
+ optional uint64 msgBacklog = 15;
617
+ }
618
+
619
+ message CommandGetLastMessageId {
620
+ required uint64 consumer_id = 1;
621
+ required uint64 request_id = 2;
622
+ }
623
+
624
+ message CommandGetLastMessageIdResponse {
625
+ required MessageIdData last_message_id = 1;
626
+ required uint64 request_id = 2;
627
+ }
628
+
629
+ message CommandGetTopicsOfNamespace {
630
+ enum Mode {
631
+ PERSISTENT = 0;
632
+ NON_PERSISTENT = 1;
633
+ ALL = 2;
634
+ }
635
+ required uint64 request_id = 1;
636
+ required string namespace = 2;
637
+ optional Mode mode = 3 [default = PERSISTENT];
638
+ }
639
+
640
+ message CommandGetTopicsOfNamespaceResponse {
641
+ required uint64 request_id = 1;
642
+ repeated string topics = 2;
643
+ }
644
+
645
+ message CommandGetSchema {
646
+ required uint64 request_id = 1;
647
+ required string topic = 2;
648
+
649
+ optional bytes schema_version = 3;
650
+ }
651
+
652
+ message CommandGetSchemaResponse {
653
+ required uint64 request_id = 1;
654
+ optional ServerError error_code = 2;
655
+ optional string error_message = 3;
656
+
657
+ optional Schema schema = 4;
658
+ optional bytes schema_version = 5;
659
+ }
660
+
661
+ message CommandGetOrCreateSchema {
662
+ required uint64 request_id = 1;
663
+ required string topic = 2;
664
+ required Schema schema = 3;
665
+ }
666
+
667
+ message CommandGetOrCreateSchemaResponse {
668
+ required uint64 request_id = 1;
669
+ optional ServerError error_code = 2;
670
+ optional string error_message = 3;
671
+
672
+ optional bytes schema_version = 4;
673
+ }
674
+
675
+ /// --- transaction related ---
676
+
677
+ enum TxnAction {
678
+ COMMIT = 0;
679
+ ABORT = 1;
680
+ }
681
+
682
+ message CommandNewTxn {
683
+ required uint64 request_id = 1;
684
+ optional uint64 txn_ttl_seconds = 2 [default = 0];
685
+ optional uint64 tc_id = 3 [default = 0];
686
+ }
687
+
688
+ message CommandNewTxnResponse {
689
+ required uint64 request_id = 1;
690
+ optional uint64 txnid_least_bits = 2 [default = 0];
691
+ optional uint64 txnid_most_bits = 3 [default = 0];
692
+ optional ServerError error = 4;
693
+ optional string message = 5;
694
+ }
695
+
696
+ message CommandAddPartitionToTxn {
697
+ required uint64 request_id = 1;
698
+ optional uint64 txnid_least_bits = 2 [default = 0];
699
+ optional uint64 txnid_most_bits = 3 [default = 0];
700
+ repeated string partitions = 4;
701
+ }
702
+
703
+ message CommandAddPartitionToTxnResponse {
704
+ required uint64 request_id = 1;
705
+ optional uint64 txnid_least_bits = 2 [default = 0];
706
+ optional uint64 txnid_most_bits = 3 [default = 0];
707
+ optional ServerError error = 4;
708
+ optional string message = 5;
709
+ }
710
+
711
+ message Subscription {
712
+ required string topic = 1;
713
+ required string subscription = 2;
714
+ }
715
+ message CommandAddSubscriptionToTxn {
716
+ required uint64 request_id = 1;
717
+ optional uint64 txnid_least_bits = 2 [default = 0];
718
+ optional uint64 txnid_most_bits = 3 [default = 0];
719
+ repeated Subscription subscription = 4;
720
+ }
721
+
722
+ message CommandAddSubscriptionToTxnResponse {
723
+ required uint64 request_id = 1;
724
+ optional uint64 txnid_least_bits = 2 [default = 0];
725
+ optional uint64 txnid_most_bits = 3 [default = 0];
726
+ optional ServerError error = 4;
727
+ optional string message = 5;
728
+ }
729
+
730
+ message CommandEndTxn {
731
+ required uint64 request_id = 1;
732
+ optional uint64 txnid_least_bits = 2 [default = 0];
733
+ optional uint64 txnid_most_bits = 3 [default = 0];
734
+ optional TxnAction txn_action = 4;
735
+ }
736
+
737
+ message CommandEndTxnResponse {
738
+ required uint64 request_id = 1;
739
+ optional uint64 txnid_least_bits = 2 [default = 0];
740
+ optional uint64 txnid_most_bits = 3 [default = 0];
741
+ optional ServerError error = 4;
742
+ optional string message = 5;
743
+ }
744
+
745
+ message CommandEndTxnOnPartition {
746
+ required uint64 request_id = 1;
747
+ optional uint64 txnid_least_bits = 2 [default = 0];
748
+ optional uint64 txnid_most_bits = 3 [default = 0];
749
+ optional string topic = 4;
750
+ optional TxnAction txn_action = 5;
751
+ }
752
+
753
+ message CommandEndTxnOnPartitionResponse {
754
+ required uint64 request_id = 1;
755
+ optional uint64 txnid_least_bits = 2 [default = 0];
756
+ optional uint64 txnid_most_bits = 3 [default = 0];
757
+ optional ServerError error = 4;
758
+ optional string message = 5;
759
+ }
760
+
761
+ message CommandEndTxnOnSubscription {
762
+ required uint64 request_id = 1;
763
+ optional uint64 txnid_least_bits = 2 [default = 0];
764
+ optional uint64 txnid_most_bits = 3 [default = 0];
765
+ optional Subscription subscription= 4;
766
+ optional TxnAction txn_action = 5;
767
+ }
768
+
769
+ message CommandEndTxnOnSubscriptionResponse {
770
+ required uint64 request_id = 1;
771
+ optional uint64 txnid_least_bits = 2 [default = 0];
772
+ optional uint64 txnid_most_bits = 3 [default = 0];
773
+ optional ServerError error = 4;
774
+ optional string message = 5;
775
+ }
776
+
777
+ message BaseCommand {
778
+ enum Type {
779
+ CONNECT = 2;
780
+ CONNECTED = 3;
781
+ SUBSCRIBE = 4;
782
+
783
+ PRODUCER = 5;
784
+
785
+ SEND = 6;
786
+ SEND_RECEIPT= 7;
787
+ SEND_ERROR = 8;
788
+
789
+ MESSAGE = 9;
790
+ ACK = 10;
791
+ FLOW = 11;
792
+
793
+ UNSUBSCRIBE = 12;
794
+
795
+ SUCCESS = 13;
796
+ ERROR = 14;
797
+
798
+ CLOSE_PRODUCER = 15;
799
+ CLOSE_CONSUMER = 16;
800
+
801
+ PRODUCER_SUCCESS = 17;
802
+
803
+ PING = 18;
804
+ PONG = 19;
805
+
806
+ REDELIVER_UNACKNOWLEDGED_MESSAGES = 20;
807
+
808
+ PARTITIONED_METADATA = 21;
809
+ PARTITIONED_METADATA_RESPONSE = 22;
810
+
811
+ LOOKUP = 23;
812
+ LOOKUP_RESPONSE = 24;
813
+
814
+ CONSUMER_STATS = 25;
815
+ CONSUMER_STATS_RESPONSE = 26;
816
+
817
+ REACHED_END_OF_TOPIC = 27;
818
+
819
+ SEEK = 28;
820
+
821
+ GET_LAST_MESSAGE_ID = 29;
822
+ GET_LAST_MESSAGE_ID_RESPONSE = 30;
823
+
824
+ ACTIVE_CONSUMER_CHANGE = 31;
825
+
826
+
827
+ GET_TOPICS_OF_NAMESPACE = 32;
828
+ GET_TOPICS_OF_NAMESPACE_RESPONSE = 33;
829
+
830
+ GET_SCHEMA = 34;
831
+ GET_SCHEMA_RESPONSE = 35;
832
+
833
+ AUTH_CHALLENGE = 36;
834
+ AUTH_RESPONSE = 37;
835
+
836
+ ACK_RESPONSE = 38;
837
+
838
+ GET_OR_CREATE_SCHEMA = 39;
839
+ GET_OR_CREATE_SCHEMA_RESPONSE = 40;
840
+
841
+ // transaction related
842
+ NEW_TXN = 50;
843
+ NEW_TXN_RESPONSE = 51;
844
+
845
+ ADD_PARTITION_TO_TXN = 52;
846
+ ADD_PARTITION_TO_TXN_RESPONSE = 53;
847
+
848
+ ADD_SUBSCRIPTION_TO_TXN = 54;
849
+ ADD_SUBSCRIPTION_TO_TXN_RESPONSE = 55;
850
+
851
+ END_TXN = 56;
852
+ END_TXN_RESPONSE = 57;
853
+
854
+ END_TXN_ON_PARTITION = 58;
855
+ END_TXN_ON_PARTITION_RESPONSE = 59;
856
+
857
+ END_TXN_ON_SUBSCRIPTION = 60;
858
+ END_TXN_ON_SUBSCRIPTION_RESPONSE = 61;
859
+
860
+ }
861
+
862
+
863
+ required Type type = 1;
864
+
865
+ optional CommandConnect connect = 2;
866
+ optional CommandConnected connected = 3;
867
+
868
+ optional CommandSubscribe subscribe = 4;
869
+ optional CommandProducer producer = 5;
870
+ optional CommandSend send = 6;
871
+ optional CommandSendReceipt send_receipt = 7;
872
+ optional CommandSendError send_error = 8;
873
+ optional CommandMessage message = 9;
874
+ optional CommandAck ack = 10;
875
+ optional CommandFlow flow = 11;
876
+ optional CommandUnsubscribe unsubscribe = 12;
877
+
878
+ optional CommandSuccess success = 13;
879
+ optional CommandError error = 14;
880
+
881
+ optional CommandCloseProducer close_producer = 15;
882
+ optional CommandCloseConsumer close_consumer = 16;
883
+
884
+ optional CommandProducerSuccess producer_success = 17;
885
+ optional CommandPing ping = 18;
886
+ optional CommandPong pong = 19;
887
+ optional CommandRedeliverUnacknowledgedMessages redeliverUnacknowledgedMessages = 20;
888
+
889
+ optional CommandPartitionedTopicMetadata partitionMetadata = 21;
890
+ optional CommandPartitionedTopicMetadataResponse partitionMetadataResponse = 22;
891
+
892
+ optional CommandLookupTopic lookupTopic = 23;
893
+ optional CommandLookupTopicResponse lookupTopicResponse = 24;
894
+
895
+ optional CommandConsumerStats consumerStats = 25;
896
+ optional CommandConsumerStatsResponse consumerStatsResponse = 26;
897
+
898
+ optional CommandReachedEndOfTopic reachedEndOfTopic = 27;
899
+
900
+ optional CommandSeek seek = 28;
901
+
902
+ optional CommandGetLastMessageId getLastMessageId = 29;
903
+ optional CommandGetLastMessageIdResponse getLastMessageIdResponse = 30;
904
+
905
+ optional CommandActiveConsumerChange active_consumer_change = 31;
906
+
907
+ optional CommandGetTopicsOfNamespace getTopicsOfNamespace = 32;
908
+ optional CommandGetTopicsOfNamespaceResponse getTopicsOfNamespaceResponse = 33;
909
+
910
+ optional CommandGetSchema getSchema = 34;
911
+ optional CommandGetSchemaResponse getSchemaResponse = 35;
912
+
913
+ optional CommandAuthChallenge authChallenge = 36;
914
+ optional CommandAuthResponse authResponse = 37;
915
+
916
+ optional CommandAckResponse ackResponse = 38;
917
+
918
+ optional CommandGetOrCreateSchema getOrCreateSchema = 39;
919
+ optional CommandGetOrCreateSchemaResponse getOrCreateSchemaResponse = 40;
920
+
921
+ // transaction related
922
+ optional CommandNewTxn newTxn = 50;
923
+ optional CommandNewTxnResponse newTxnResponse = 51;
924
+ optional CommandAddPartitionToTxn addPartitionToTxn= 52;
925
+ optional CommandAddPartitionToTxnResponse addPartitionToTxnResponse = 53;
926
+ optional CommandAddSubscriptionToTxn addSubscriptionToTxn = 54;
927
+ optional CommandAddSubscriptionToTxnResponse addSubscriptionToTxnResponse = 55;
928
+ optional CommandEndTxn endTxn = 56;
929
+ optional CommandEndTxnResponse endTxnResponse = 57;
930
+ optional CommandEndTxnOnPartition endTxnOnPartition = 58;
931
+ optional CommandEndTxnOnPartitionResponse endTxnOnPartitionResponse = 59;
932
+ optional CommandEndTxnOnSubscription endTxnOnSubscription = 60;
933
+ optional CommandEndTxnOnSubscriptionResponse endTxnOnSubscriptionResponse = 61;
934
+ }