unified_agent.proto 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. syntax = "proto3";
  2. import "google/protobuf/descriptor.proto";
  3. package NUnifiedAgentProto;
  4. option java_package = "com.yandex.unified_agent";
  5. option go_package = "a.yandex-team.ru/library/cpp/unified_agent_client/proto;unifiedagent";
  6. extend google.protobuf.FileOptions {
  7. bool GenerateYaStyle = 66777;
  8. }
  9. message Request {
  10. message SessionMetaItem {
  11. string name = 1;
  12. string value = 2;
  13. }
  14. message Initialize {
  15. // Session_id provided by server, use it in case of reconnects.
  16. string session_id = 1;
  17. // Session metadata
  18. repeated SessionMetaItem meta = 2;
  19. string shared_secret_key = 3;
  20. }
  21. message MessageMetaItem {
  22. // Arbitrary key-value pairs. Can be used by agent filters to modify/filter messages
  23. // or to route them to target outputs.
  24. // Meta items of all messages should be grouped by meta key, it's expected in the 'key' field.
  25. // Meta values should be passed in the 'value' sequence, it corresponds to the payload
  26. // sequence from DataBatch. If some messages don't have a meta with this key, the range of such messages
  27. // can be passed via skip_start/skip_length sequences.
  28. // For example, [{m:v1}, {}, {}, {m: v2}, {}, {m: v3}, {}, {}] can be represented as follows:
  29. // key: 'm'
  30. // value: ['v1', 'v2', 'v3']
  31. // skip_start: [1, 4]
  32. // skip_length: [2, 1]
  33. string key = 1;
  34. repeated string value = 2;
  35. repeated uint32 skip_start = 3;
  36. repeated uint32 skip_length = 4;
  37. }
  38. message DataBatch {
  39. repeated uint64 seq_no = 1;
  40. repeated uint64 timestamp = 2; //microseconds
  41. repeated bytes payload = 100;
  42. repeated MessageMetaItem meta = 101;
  43. }
  44. oneof request {
  45. Initialize initialize = 1;
  46. DataBatch data_batch = 2;
  47. }
  48. }
  49. message Response {
  50. message Initialized {
  51. // Session identifier for log and deduplication purposes.
  52. string session_id = 1;
  53. // Application can skip all formed messages by seq_no upto last_seq_no - they are consumed by server.
  54. uint64 last_seq_no = 2;
  55. }
  56. message Ack {
  57. uint64 seq_no = 1;
  58. }
  59. oneof response {
  60. Initialized initialized = 1;
  61. Ack ack = 2;
  62. }
  63. }
  64. service UnifiedAgentService {
  65. rpc Session(stream Request) returns (stream Response);
  66. }
  67. // dataflow:
  68. // Request.initialize -> UnifiedAgent;
  69. // specify session_id when this is a retry. Сlient can already have sesison_id from previous init response,
  70. // or it can use some pregenerated sessionId for each session.
  71. // Response.initializeded -> client;
  72. // Request.entry -> UnifiedAgent;
  73. // ....
  74. // Response.ack -> client;
  75. // when this record is consumed by UnifiedAgent with choosen garanties UnifiedAgent will send ack to client;
  76. // client can forget about this log record now
  77. //
  78. // grpc finish session -> client;
  79. // something went wrong; client must reconnect and retry all not acknowleged records
  80. //
  81. // Exactly once retries - when reconnect, client must provide previous session_id and same seq_no`s
  82. // for records - only in this case UnifiedAgent can dedup.