metadata = 6;
77 | }
78 |
79 | /* The tag. Describes an event with more details. Usually using concepts from the Domain. */
80 | message Tag {
81 |
82 | /* The key of the tag. */
83 | bytes key = 1;
84 |
85 | /* The value of the tag. */
86 | bytes value = 2;
87 | }
88 |
89 | /* The event described in more details by a list of tags. */
90 | message TaggedEvent {
91 |
92 | /* The event. */
93 | Event event = 1;
94 |
95 | /* List of tags describing the given event in more details. */
96 | repeated Tag tag = 2;
97 | }
98 |
99 | /* The event retrieved from the event store with its corresponding sequence. */
100 | message SequencedEvent {
101 |
102 | /* The sequence of the event. */
103 | int64 sequence = 1;
104 |
105 | /* The event. */
106 | Event event = 2;
107 | }
108 |
109 | /* The message representing the request to append events to the event store. */
110 | message AppendEventsRequest {
111 |
112 | /* The condition used to check the validity of this request. If omitted, events will be appended unconditionally. */
113 | ConsistencyCondition condition = 1;
114 |
115 | /* A list of tagged events to be appended to the event store if the condition is met.
116 | These events are considered as a transaction - they are either all appended or none of them are appended.
117 | The event store will index the events based on provided tags for future faster retrieval. */
118 | repeated TaggedEvent event = 2;
119 | }
120 |
121 | /* The response of a successful append events request. If there was an issue with the append events request,
122 | the stream will complete with an error. */
123 | message AppendEventsResponse {
124 |
125 | /* The sequence of the first event stored in the event store.
126 | Corresponding to the list of events (a transaction) passed in the AppendEventsRequest. */
127 | int64 sequence_of_the_first_event = 1;
128 |
129 | /* The number of events appended. Matches the number of events passed in the AppendEventsRequest. */
130 | int32 transaction_size = 2;
131 |
132 | /* The consistency marker which may be used for a subsequent append events requests. Do note that during the time this
133 | consistency marker may get far behind the head of the event store which will increase the time needed for the append
134 | events request to be validated. If you don't plan to do subsequent append events requests in a "short" period of time,
135 | use the Source RPC to refresh the consistency marker. */
136 | int64 consistency_marker = 3;
137 | }
138 |
139 | /* The request to source events from the event store. It results in a finite stream of events completed by
140 | the event store. It may also be cancelled by the client. Only events matching the given criteria
141 | (a provided list of criterions) will be present in the stream. The stream is capped by the HEAD of the event store. */
142 | message SourceEventsRequest {
143 |
144 | /* An inclusive sequence of the first event to be included in the resulting stream. */
145 | int64 from_sequence = 1;
146 |
147 | /* The criteria consisting of the list of criterions. If at least one of these criterions is met,
148 | the criteria is met. */
149 | repeated Criterion criterion = 2;
150 | }
151 |
152 | /* The response to the SourceEventsRequest. It consists either of an event (with its corresponding sequence) or a
153 | consistency marker. The consistency marker should be used in a following AppendEventsRequest related to the criteria used in the SourceEventsRequest this response originates from. */
154 | message SourceEventsResponse {
155 | oneof result {
156 |
157 | /* The event matching the criteria with its corresponding sequence. */
158 | SequencedEvent event = 1;
159 |
160 | /* The consistency marker to be used for the following append related to the same criteria. */
161 | int64 consistency_marker = 2;
162 | }
163 | }
164 |
165 | /* The condition for an AppendEventsRequest. Consists of the consistency marker and the criteria
166 | (a list of criterions). */
167 | message ConsistencyCondition {
168 |
169 | /* The sequence used to start checking for the consistency of an append. If there are events with a sequence greater
170 | or equal than the consistency marker and those are matching the given criteria, the condition is not met and the transaction
171 | is rejected. Otherwise, it is accepted. */
172 | int64 consistency_marker = 1;
173 |
174 | /* The criteria. Consists of a list of criterions. If a single criterion is met, the whole criteria is met. */
175 | repeated Criterion criterion = 2;
176 | }
177 |
178 | /* The integral part of the criteria. */
179 | message Criterion {
180 |
181 | /* The criterion based on event tags and event names. */
182 | TagsAndNamesCriterion tags_and_names = 1;
183 | }
184 |
185 | /* The criterion based on event tags and event names. The event meets this criterion if ALL tags from this criterion
186 | are present in the tags of the event AND if the event name is present in one of the names of the this criterion. */
187 | message TagsAndNamesCriterion {
188 |
189 | /* A list of event names. The event meets this criterion if its name is in one of the names in this list. */
190 | repeated string name = 1;
191 |
192 | /* A list of event tags. The event meets this criterion if it contains all the tags from this list. It meets the
193 | criterion if it contains more than provided list here, but it MUST contain all from the list. */
194 | repeated Tag tag = 2;
195 | }
196 |
197 | /* The request to provide an infinite stream of events from the event store. The client may cancel the stream at any
198 | time. */
199 | message StreamEventsRequest {
200 |
201 | /* The inclusive sequence to start streaming from. */
202 | int64 from_sequence = 1;
203 |
204 | /* The criteria used to filter out events. Represented by a list of criterions. If at least one is met, the whole
205 | criteria is met. */
206 | repeated Criterion criterion = 2;
207 | }
208 |
209 | /* The response to the StreamEventsRequest. */
210 | message StreamEventsResponse {
211 |
212 | /* The event with its corresponding sequence. */
213 | SequencedEvent event = 1;
214 | }
215 |
216 | /* The request to retrieve the current HEAD of the event store. */
217 | message GetHeadRequest {
218 |
219 | }
220 |
221 | /* The current HEAD of the event store. */
222 | message GetHeadResponse {
223 |
224 | /* The sequence of the current head. Points to the position of the first event to be appended. The HEAD of an empty
225 | event store is 0. */
226 | int64 sequence = 1;
227 | }
228 |
229 | /* The request to retrieve the current TAIL of the event store. */
230 | message GetTailRequest {
231 |
232 | }
233 |
234 | /* The current TAIL of the event store. */
235 | message GetTailResponse {
236 |
237 | /* The sequence of the first event in the event store. 0 for an empty event store. 0 for a non-truncated event store.
238 | Non-zero for a truncated event store. */
239 | int64 sequence = 1;
240 | }
241 |
242 | /* The request to get the sequence of the event whose timestamp is the same as the timestamp provided in the request.
243 | If there are no events with the exact timestamp, then the sequence of the first one after the provided timestamp is
244 | returned. If the provided timestamp is greater that the sequence of the last event in the event store,
245 | the HEAD is returned. */
246 | message GetSequenceAtRequest {
247 |
248 | /* The timestamp. */
249 | int64 timestamp = 1;
250 | }
251 |
252 | /* The sequence of the event approximately close to the provided timestamp. */
253 | message GetSequenceAtResponse {
254 |
255 | /* The sequence of the event. */
256 | int64 sequence = 1;
257 | }
258 |
259 | /* The request to add tags to the event. */
260 | message AddTagsRequest {
261 |
262 | /* The sequence of the event whose tags list will be expanded with the tags from the request. */
263 | int64 sequence = 1;
264 |
265 | /* The tags to be added to the event. If the event already contains a tag from the same list
266 | (with the same key and the value) the new one will be ignored. */
267 | repeated Tag tag = 2;
268 | }
269 |
270 | /* The response indicating a successful addition of tags to the event. */
271 | message AddTagsResponse {
272 |
273 | }
274 |
275 | /* The request to remove tags from the event. */
276 | message RemoveTagsRequest {
277 |
278 | /* The sequence of the event whose tags should be removed. */
279 | int64 sequence = 1;
280 |
281 | /* Tags to be removed. If the event is not tagged with listed tags, they are skipped. */
282 | repeated Tag tag = 2;
283 | }
284 |
285 | /* The response indicating a successful removal of tags for the event. */
286 | message RemoveTagsResponse {
287 |
288 | }
289 |
290 | /* The request to retrieve tags of the event. */
291 | message GetTagsRequest {
292 |
293 | /* The sequence of the event whose tags should be retrieved. */
294 | int64 sequence = 1;
295 | }
296 |
297 | /* The response containing tags of an event. */
298 | message GetTagsResponse {
299 |
300 | /* The tags associated to the event. */
301 | repeated Tag tag = 1;
302 | }
303 |
304 | /* The snapshot. */
305 | message Snapshot {
306 |
307 | /* The name of the snapshot. */
308 | string name = 1;
309 |
310 | /* The revision of the snapshot. */
311 | string revision = 2;
312 |
313 | /* The payload of the snapshot. */
314 | bytes payload = 3;
315 | }
316 |
317 | /* The request to add the snapshot to the snapshot store. */
318 | message AddSnapshotRequest {
319 |
320 | /* The key this snapshot is added to. */
321 | bytes key = 1;
322 |
323 | /* The sequence of the snapshot. Usually linked to the sequence of the event in the event store up to which
324 | the snapshot is taken. */
325 | int64 sequence = 2;
326 |
327 | /* If set to true, older snapshots for the same key are pruned. */
328 | bool prune = 3;
329 |
330 | /* The snapshot. */
331 | Snapshot snapshot = 4;
332 | }
333 |
334 | /* The response indicating the successful addition of the snapshot. */
335 | message AddSnapshotResponse {
336 |
337 | }
338 |
339 | /* The request to delete the snapshot from the snapshot store. */
340 | message DeleteSnapshotsRequest {
341 |
342 | /* The key the snapshot is identified by. */
343 | bytes key = 1;
344 |
345 | /* The inclusive bottom bound sequence of the snapshot to start the deletion. */
346 | int64 from_sequence = 2;
347 |
348 | /* The exclusive upper bound sequence of the snapshot to end the deletion. */
349 | int64 to_sequence = 3;
350 | }
351 |
352 | /* The response indicating the successful deletion of the snapshot. */
353 | message DeleteSnapshotsResponse {
354 |
355 | }
356 |
357 | /* The request to retrieve all snapshots from the snapshot store based on the key and sequence bounds. */
358 | message ListSnapshotsRequest {
359 |
360 | /* The key of the snapshot. */
361 | bytes key = 1;
362 |
363 | /* The inclusive bottom bound sequence used to filter out snapshots. */
364 | int64 from_sequence = 2;
365 |
366 | /* The exclusive upper bound sequence used to filter out snapshots. */
367 | int64 to_sequence = 3;
368 | }
369 |
370 | /* The response to the ListSnapshotRequest. */
371 | message ListSnapshotsResponse {
372 |
373 | /* The key of the snapshot. */
374 | bytes key = 1;
375 |
376 | /* The sequence of the snapshot. */
377 | int64 sequence = 2;
378 |
379 | /* The snapshot. */
380 | Snapshot snapshot = 3;
381 | }
382 |
383 | /* The request to retrieve the snapshot with the highest sequence from the snapshot store. */
384 | message GetLastSnapshotRequest {
385 |
386 | /* The key of the snapshot. */
387 | bytes key = 1;
388 | }
389 |
390 | /* The response to GetLatestSnapshotRequest. */
391 | message GetLastSnapshotResponse {
392 |
393 | /* The key of the snapshot. */
394 | bytes key = 1;
395 |
396 | /* The sequence of the snapshot. */
397 | int64 sequence = 2;
398 |
399 | /* The snapshot. */
400 | Snapshot snapshot = 3;
401 | }
--------------------------------------------------------------------------------
/src/main/proto/event.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package io.axoniq.axonserver.grpc.event;
3 | import "common.proto";
4 | import "google/protobuf/empty.proto";
5 | option java_multiple_files = true;
6 |
7 | /* Service providing operations against the EventStore functionality of Axon Server */
8 | service EventStore {
9 |
10 | // Accepts a stream of Events returning a Confirmation when completed.
11 | rpc AppendEvent (stream Event) returns (Confirmation) {
12 | }
13 |
14 | // Accepts a Snapshot event returning a Confirmation when completed.
15 | rpc AppendSnapshot (Event) returns (Confirmation) {
16 | }
17 |
18 | // Retrieves the Events for a given aggregate. Results are streamed rather than returned at once.
19 | rpc ListAggregateEvents (GetAggregateEventsRequest) returns (stream Event) {
20 | }
21 |
22 | // Retrieves the Snapshots for a given aggregate. Results are streamed rather than returned at once.
23 | rpc ListAggregateSnapshots (GetAggregateSnapshotsRequest) returns (stream Event) {
24 | }
25 |
26 | /* Retrieves the Events from a given tracking token. However, if several GetEventsRequests are sent in the stream
27 | only first one will create the tracker, others are used for increasing number of permits or blacklisting. Results
28 | are streamed rather than returned at once. */
29 | rpc ListEvents (stream GetEventsRequest) returns (stream EventWithToken) {
30 | }
31 |
32 | // Gets the highest sequence number for a specific aggregate.
33 | rpc ReadHighestSequenceNr (ReadHighestSequenceNrRequest) returns (ReadHighestSequenceNrResponse) {
34 | }
35 |
36 | // Performs a query on the event store, returns a stream of results. Input is a stream to allow flow control from the
37 | // client
38 | rpc QueryEvents (stream QueryEventsRequest) returns (stream QueryEventsResponse) {
39 | }
40 |
41 | // Retrieves the first token available in event store (typically 0). Returns 0 when no events in store.
42 | rpc GetFirstToken (GetFirstTokenRequest) returns (TrackingToken) {
43 | }
44 |
45 | // Retrieves the last committed token in event store. Returns -1 when no events in store.
46 | rpc GetLastToken (GetLastTokenRequest) returns (TrackingToken) {
47 | }
48 |
49 | // Retrieves the token of the first token of an event from specified time in event store. Returns -1 when no events in store.
50 | rpc GetTokenAt (GetTokenAtRequest) returns (TrackingToken) {
51 | }
52 | }
53 |
54 | /* Service to use AxonServer as a provider of an EventScheduler */
55 | service EventScheduler {
56 | // Schedule the given event for publication at the given time}. The returned ScheduleToken can be used to cancel the planned publication.
57 | rpc ScheduleEvent (ScheduleEventRequest) returns (ScheduleToken) {
58 | }
59 | // Cancel a scheduled event and schedule another in its place.
60 | rpc RescheduleEvent (RescheduleEventRequest) returns (ScheduleToken) {
61 | }
62 | // Cancel the publication of a scheduled event. If the events has already been published, this method does nothing.
63 | rpc CancelScheduledEvent (CancelScheduledEventRequest) returns (InstructionAck) {
64 | }
65 | }
66 |
67 | /* Service to transform events in an event store */
68 | service EventTransformationService {
69 |
70 | // Returns the list of all transformations.
71 | rpc Transformations(google.protobuf.Empty) returns (stream Transformation) {
72 | }
73 |
74 | // Starts a new transformation.
75 | rpc StartTransformation(StartTransformationRequest) returns (TransformationId) {
76 | }
77 |
78 | // Adds requests to transform an event to a transformation.
79 | rpc TransformEvents(stream TransformRequest) returns (stream TransformRequestAck) {
80 | }
81 |
82 | // Cancels a transformation before it is applied.
83 | rpc CancelTransformation(TransformationId) returns (stream google.protobuf.Empty) {
84 | }
85 |
86 | // Applies the changes from a transformation in the event store.
87 | rpc ApplyTransformation(ApplyTransformationRequest) returns (stream google.protobuf.Empty) {
88 | }
89 |
90 | // Deletes old versions of events updated by a transformation.
91 | rpc Compact(CompactionRequest) returns (stream google.protobuf.Empty) {
92 | }
93 | }
94 |
95 | /* Request to compact event store. */
96 | message CompactionRequest {
97 | }
98 |
99 | /* The transformation data. */
100 | message Transformation {
101 |
102 | // The identifier of the transformation.
103 | TransformationId transformationId = 1;
104 |
105 | // The state of the transformation
106 | TransformationState state = 2;
107 |
108 | // The sequence of the last transformation action stored. Needed for checking sequential consistency of requests.
109 | int64 sequence = 3;
110 |
111 | // The bounded context in which this transformation is being executed.
112 | string context = 4;
113 |
114 | // The description of the transformation.
115 | string description = 5;
116 |
117 | // The timestamp at which the transformation was applied. Set to -1 if the transformation was not applied.
118 | int64 applied_at = 6;
119 |
120 | // The username of user who requested the transformation to be applied. Empty if the transformation was not applied.
121 | string apply_requester = 7;
122 |
123 | // The version of the transformation. The sequence
124 | int32 version = 8;
125 | }
126 |
127 | /* The state of the transformation. */
128 | enum TransformationState {
129 | // The transformation is opened, able to receive request to transform events, or to be applied or cancelled.
130 | ACTIVE = 0;
131 | // The transformation has been cancelled. This a final state.
132 | CANCELLED = 1;
133 | // The transformation is in progress of applying its actions to the event store.
134 | APPLYING = 2;
135 | // The transformation has been applied to the event store. This a final state.
136 | APPLIED = 3;
137 | }
138 |
139 | /* Request to start a transformation */
140 | message StartTransformationRequest {
141 | /* A description of the purpose of this transformation, for reference only */
142 | string description = 1;
143 | }
144 |
145 | /* Request to apply a transformation */
146 | message ApplyTransformationRequest {
147 | /* The identification of the transformation */
148 | TransformationId transformation_id = 1;
149 | /* The sequence of the last entry in this transformation */
150 | int64 last_sequence = 2;
151 | }
152 |
153 | /* Message containing one event to transform within a transformation */
154 | message TransformRequest {
155 | /* The identification of the transformation */
156 | TransformationId transformation_id = 1;
157 | /* The sequence of the current transformation */
158 | int64 sequence = 2;
159 | oneof request {
160 | /* Replaces the content of an event with the new content */
161 | TransformedEvent replace_event = 3;
162 | /* Deletes the content of an event */
163 | DeletedEvent delete_event = 4;
164 | }
165 | }
166 |
167 | /* Replaces the content of an event with the new content */
168 | message TransformedEvent {
169 | /* The global index of the event to replace */
170 | int64 token = 1;
171 | /* The new content of the event */
172 | Event event = 2;
173 | }
174 |
175 | /* Deletes the content of an event */
176 | message DeletedEvent {
177 | /* The global index of the event to clear */
178 | int64 token = 1;
179 | }
180 |
181 | /* Uniquely identifies a transformation */
182 | message TransformationId {
183 | // The value of the identifier.
184 | string id = 1;
185 | }
186 |
187 | /* Acknowledgement that event with given token has been transformed successfully */
188 | message TransformRequestAck {
189 |
190 | /* The sequence of the transformation request */
191 | int64 sequence = 1;
192 | }
193 |
194 |
195 | /* Request message to schedule an event */
196 | message ScheduleEventRequest {
197 | /* timestamp when to publish the event */
198 | int64 instant = 1;
199 | /* the event to publish */
200 | Event event = 2;
201 | }
202 |
203 | /* Request message to reschedule an event */
204 | message RescheduleEventRequest {
205 | /* optional token of scheduled event to cancel */
206 | string token = 1;
207 | /* timestamp when to publish the event */
208 | int64 instant = 2;
209 | /* the event to publish */
210 | Event event = 3;
211 | }
212 |
213 | /* Request message to cancel an event */
214 | message CancelScheduledEventRequest {
215 | /* token of scheduled event to cancel */
216 | string token = 1;
217 | }
218 |
219 | /* Token to manage a scheduled event */
220 | message ScheduleToken {
221 | /* Field defining the token identifier */
222 | string token = 1;
223 | }
224 |
225 | /* Request message to receive the first Token (Tail Token) of the Event Stream */
226 | message GetFirstTokenRequest {
227 | }
228 |
229 | /* Request message to receive the last Token (Head Token) of the Event Stream */
230 | message GetLastTokenRequest {
231 | }
232 |
233 | /* Request message to receive the Token that starts streaming events from the given timestamp */
234 | message GetTokenAtRequest {
235 |
236 | /* Timestamp expressed as milliseconds since epoch */
237 | int64 instant = 1;
238 | }
239 |
240 | /* Message containing the information necessary to track the position of events in the Event Stream */
241 | message TrackingToken {
242 |
243 | /* The value of the Token */
244 | int64 token = 1;
245 | }
246 |
247 | /* Message wrapping an Event and a Tracking Token */
248 | message EventWithToken {
249 |
250 | /* The Token representing the position of this Event in the Stream */
251 | int64 token = 1;
252 |
253 | /* The actual Event Message */
254 | Event event = 2;
255 | }
256 |
257 | /* Message providing the parameters for executing a Query against AxonServer. */
258 | message QueryEventsRequest {
259 |
260 | /* The query to execute against the Event Stream */
261 | string query = 1;
262 |
263 | /* The number of results AxonServer may send before new permits need to be provided */
264 | int64 number_of_permits = 2;
265 |
266 | /* Whether to keep the query running against incoming events once the Head of the Stream is reached */
267 | bool live_events = 3;
268 |
269 | /* Indicates whether to force querying events from the leader node of an Axon Server. Forcing reads from leader
270 | * reduces the staleness of the data read, but also puts extra burden on the leader, reducing overall scalability.
271 | *
272 | * This property has no effect on connections to AxonServer SE.
273 | *
274 | */
275 | bool force_read_from_leader = 4;
276 |
277 | /* If true, snapshots will be queried instead of events */
278 | bool query_snapshots = 5;
279 |
280 | /* Query from this context, not from the default context of the connection */
281 | string context_name = 6;
282 | }
283 |
284 | /* A message describing a response to a Query request */
285 | message QueryEventsResponse {
286 | /* The actual contents of this response */
287 | oneof data {
288 | /* Provided when the response contains the names of the columns the response contains. This message typically arrives first. */
289 | ColumnsResponse columns = 1;
290 |
291 | /* Provided when the response message contains results of the Query */
292 | RowResponse row = 2;
293 |
294 | /* Provided when all historic events have been included in the query results */
295 | Confirmation files_completed = 3;
296 | }
297 | }
298 |
299 | /* Message containing the names of the columns returned in a Query */
300 | message ColumnsResponse {
301 |
302 | /* The names of the columns provided in the query */
303 | repeated string column = 1;
304 | }
305 |
306 | /* Message providing Query Result data */
307 | message RowResponse {
308 |
309 | /* The values which, when combined, uniquely update this row. Any previously received values with the same identifiers should be replaced with this value */
310 | repeated QueryValue id_values = 1;
311 |
312 | /* The sorting values to use when sorting this response compared to the others. */
313 | repeated QueryValue sort_values = 2;
314 |
315 | /* The actual data values for each of the columns, as a column name -> value mapping */
316 | map values = 3;
317 | }
318 |
319 | /* Describes the combination of an Aggregate Identifier and first expected Sequence number when opening an Aggregate-specific Event Stream */
320 | message ReadHighestSequenceNrRequest {
321 | /* The Identifier of the Aggregate for which to load events */
322 | string aggregate_id = 1;
323 |
324 | /* The Sequence Number of the first event expected */
325 | int64 from_sequence_nr = 3;
326 | }
327 |
328 | /* The highest Sequence Number found for the provided request*/
329 | message ReadHighestSequenceNrResponse {
330 |
331 | /* The sequence number of the latest event */
332 | int64 to_sequence_nr = 1;
333 | }
334 |
335 | /* A confirmation to a request from the client */
336 | message Confirmation {
337 |
338 | /* True when successful, otherwise false */
339 | bool success = 1;
340 | }
341 |
342 | /* Request describing the desire to read events for a specific Aggregate */
343 | message GetAggregateEventsRequest {
344 |
345 | /* The identifier of the aggregate to read events for */
346 | string aggregate_id = 1;
347 |
348 | /* The sequence number of the first event to receive */
349 | int64 initial_sequence = 2;
350 |
351 | /* Whether a snapshot may be returned as first element in the stream */
352 | bool allow_snapshots = 3;
353 |
354 | /* The maximum sequence number (inclusive) of the events to retrieve, 0 means up to last event */
355 | int64 max_sequence = 4;
356 |
357 | /* Hint for a minimum token to search events from */
358 | int64 min_token = 5;
359 | }
360 |
361 | /* Request message to retrieve Snapshot Events for a specific Aggregate instance */
362 | message GetAggregateSnapshotsRequest {
363 |
364 | /* The identifier to fetch the snapshots for */
365 | string aggregate_id = 1;
366 |
367 | /* The minimal sequence number of the snapshots to retrieve */
368 | int64 initial_sequence = 2;
369 |
370 | /* The maximum sequence number of the snapshots to retrieve */
371 | int64 max_sequence = 3;
372 |
373 | /* The maximum number of results to stream */
374 | int32 max_results = 4;
375 | }
376 |
377 | /* Request message to open an Event Stream from the Event Store. */
378 | message GetEventsRequest {
379 |
380 | /* The token to start streaming from */
381 | int64 tracking_token = 1;
382 |
383 | /* The number of messages the server may send before it needs to wait for more permits */
384 | int64 number_of_permits = 2;
385 |
386 | /* The unique identifier of this client instance. Used for monitoring. */
387 | string client_id = 3;
388 |
389 | /* The component name of this client instance. Used for monitoring. */
390 | string component_name = 4;
391 |
392 | /* The name of the processor requesting this stream. Used for monitoring. */
393 | string processor = 5;
394 |
395 | /* An enumeration of payload types that need to be blacklisted. The Server will stop sending messages of these
396 | types in order to reduce I/O. Note that the Server may occasionally send a blacklisted message to prevent
397 | time-outs and stale tokens on clients.
398 | */
399 | repeated PayloadDescription blacklist = 6;
400 |
401 | /* Indicates whether to force reading events from the leader node of an Axon Server. Forcing reads from leader
402 | * reduces the staleness of the data read, but also puts extra burden on the leader, reducing overall scalability.
403 | *
404 | * This property has no effect on connections to AxonServer SE.
405 | *
406 | */
407 | bool force_read_from_leader = 7;
408 | }
409 |
410 | /* Message containing the information of an Event */
411 | message Event {
412 |
413 | /* The unique identifier of this event */
414 | string message_identifier = 1;
415 |
416 | /* The identifier of the Aggregate instance that published this event, if any */
417 | string aggregate_identifier = 2;
418 |
419 | /* The sequence number of the Event in the Aggregate instance that published it, if any */
420 | int64 aggregate_sequence_number = 3;
421 |
422 | /* The Type of the Aggregate instance that published this Event, if any */
423 | string aggregate_type = 4;
424 |
425 | /* The timestamp of the Event */
426 | int64 timestamp = 5;
427 |
428 | /* The Payload of the Event */
429 | SerializedObject payload = 6;
430 |
431 | /* The Meta Data of the Event */
432 | map meta_data = 7;
433 |
434 | /* Flag indicating whether the Event is a snapshot Event */
435 | bool snapshot = 8;
436 | }
437 |
438 | /* Value used in Query Responses to represent a value in its original type */
439 | message QueryValue {
440 |
441 | /* The actual value, which can be one of string, 64 bit signed integer, boolean or 64 bits floating point */
442 | oneof data {
443 |
444 | /* The text value */
445 | string text_value = 1;
446 |
447 | /* The (64 bits) integer value */
448 | sint64 number_value = 2;
449 |
450 | /* The boolean value */
451 | bool boolean_value = 3;
452 |
453 | /* The (64 bits) floating point value */
454 | double double_value = 4;
455 | }
456 | }
457 |
458 | /* Description of a Payload Type */
459 | message PayloadDescription {
460 |
461 | /* The type identifier of the Payload */
462 | string type = 1;
463 |
464 | /* The revision of the Payload Type */
465 | string revision = 2;
466 | }
467 |
--------------------------------------------------------------------------------
/src/main/proto/persistent-streams.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package io.axoniq.axonserver.grpc.streams;
3 | import "event.proto";
4 | import "google/protobuf/empty.proto";
5 | option java_multiple_files = true;
6 |
7 | /* Service providing operations for persistent event streams, event streams where Axon Server keeps
8 | track of the progress. All operations require a header (AxonIQ-Context) to be passed with each request to define
9 | the context.
10 | */
11 | service PersistentStreamService {
12 | /* Creates a persistent stream if it does not exist. */
13 | rpc CreateStream( CreateStreamRequest) returns (CreateStreamResponse) {
14 |
15 | }
16 | /* Open a persistent event stream connection from a client. Creates the stream if it does not exist. */
17 | rpc OpenStream(stream StreamRequest) returns (stream StreamSignal) {
18 |
19 | }
20 |
21 | /* Deletes a persistent event stream. All existing connections to the stream are closed. */
22 | rpc DeleteStream(DeleteStreamRequest) returns (stream google.protobuf.Empty) {
23 |
24 | }
25 |
26 | /* Change properties of a persistent event stream. */
27 | rpc UpdateStream(UpdateStreamRequest) returns (stream google.protobuf.Empty) {
28 |
29 | }
30 |
31 | /* Returns a list of all persistent event streams defined (for the context). For each event stream it returns
32 | the progress per segment. */
33 | rpc ListStreams(ListStreamsRequest) returns (stream StreamStatus) {
34 |
35 | }
36 |
37 | /* Resets the position of a persistent stream. */
38 | rpc ResetStream(ResetStreamRequest) returns (stream google.protobuf.Empty) {
39 |
40 | }
41 | }
42 |
43 | /* request to list the persistent streams for a context */
44 | message ListStreamsRequest {
45 |
46 | }
47 | /* Contains the current status of a persistent stream */
48 | message StreamStatus {
49 | string stream_id = 1; /* the unique identification of the persistent stream */
50 | string stream_name = 2; /* a name for the persistent stream */
51 | SequencingPolicy sequencing_policy = 3; /* the policy used to distribute events across segments. */
52 | string filter = 4; /* an expression to filter events, same syntax as used for ad-hoc queries on the event store */
53 | repeated SegmentPosition segments = 5; /* the last confirmed position per segment */
54 | }
55 |
56 | /* Contains the position per segment */
57 | message SegmentPosition {
58 | int32 segment = 1; /* the segment number */
59 | int64 position = 2; /* the last confirmed position */
60 | string client_id = 3; /* the connected client, empty if there is no client connected to this segment */
61 | string error = 4; /* optional error reported by the client for this segment */
62 | }
63 |
64 | /* Request to set up a connection to a stream. Clients should first submit an OpenRequest on this connection
65 | to connect to a stream and can then submit Acknowledgement messages to report progress. */
66 | message StreamRequest {
67 | oneof request {
68 | Open open = 1; /* the initial message to connect to a stream */
69 | ProgressAcknowledgement acknowledgeProgress = 2; /* sends progress in processing events to Axon Server */
70 | Requests requests = 3; /* request a number of messages for a segment */
71 | SegmentError error = 4; /* notifies an error */
72 | }
73 | }
74 |
75 | /* Request to create a persistent stream */
76 | message CreateStreamRequest {
77 | string stream_id = 1; /* the unique identification of the stream */
78 | InitializationProperties initialization_properties = 2; /* properties to create the stream if it does not exist */
79 | }
80 |
81 | /* Response for a create stream request */
82 | message CreateStreamResponse {
83 | CreateResult result = 1; /* the result (created or already existing) */
84 | }
85 |
86 |
87 | /* Request to notify Axon Server of an error on a persistent stream segment */
88 | message SegmentError {
89 | int32 segment = 1; /* the segment number */
90 | string error = 2; /* the error that occurred while processing the events for this segment */
91 | }
92 |
93 | /* Request to delete a persistent stream */
94 | message DeleteStreamRequest {
95 | string stream_id = 1; /* the unique identification of the stream */
96 | }
97 |
98 | message ResetStreamRequest {
99 | string stream_id = 1; /* the unique identification of the stream */
100 | ResetStreamConfiguration options = 2;
101 | }
102 |
103 | /* Request to update the properties of a persistent stream */
104 | message UpdateStreamRequest {
105 | string stream_id = 1; /* the unique identification of the stream */
106 | int32 segments = 2; /* Request to change the number of segments */
107 | string stream_name = 3; /* Request to change the name of the stream */
108 | }
109 |
110 |
111 | /* Request to open a connection to a persistent stream */
112 | message Open {
113 | string stream_id = 1; /* the unique identification of the stream */
114 | string client_id = 2; /* the unique identification of the client */
115 | InitializationProperties initialization_properties = 3; /* properties to create the stream if it does not exist */
116 | }
117 |
118 | /* Properties to create the stream if it does not exist */
119 | message InitializationProperties {
120 | int32 segments = 1; /* the initial number of segments */
121 | int64 initial_position = 2; /* the position in the event store to start reading from */
122 | SequencingPolicy sequencing_policy = 3; /* the sequencing policy */
123 | string filter = 4; /* an expression to filter events, same syntax as used for ad-hoc queries on the event store */
124 | string stream_name = 5; /* a name for the persistent stream */
125 | }
126 |
127 | /* Defines the policy used to distribute events across segments. The policy name must be known on the server. */
128 | message SequencingPolicy {
129 | string policy_name = 1; /* the name of the sequencing policy */
130 | repeated string parameter = 2; /* optional list of parameters used by the sequencing policy */
131 | }
132 |
133 | /* Message to report progress of event processing for a specific segment in a stream */
134 | message ProgressAcknowledgement {
135 | int32 segment = 1; /* the segment number */
136 | int64 position = 2; /* the position of the last processed event */
137 | }
138 |
139 | message Requests {
140 | int32 segment = 1; /* the segment number */
141 | int32 requests = 2; /* the number of messages to request */
142 | }
143 |
144 | /* Message sent by Axon Server to the client stream connection */
145 | message StreamSignal {
146 | int32 segment = 1; /* the segment number */
147 | oneof type {
148 | PersistentStreamEvent event = 2; /* an event to process in the client */
149 | bool closed = 3; /* indicates that the segment is closed by Axon Server */
150 | OpenSegment open = 4; /* segment assigned to the client */
151 | }
152 | }
153 |
154 | /* Event sent on a persistent stream segment */
155 | message PersistentStreamEvent {
156 | io.axoniq.axonserver.grpc.event.EventWithToken event = 1; /* an event to process in the client */
157 | bool replay = 2; /* indicates that the event is sent again after a reset stream */
158 | }
159 |
160 |
161 | /* Message to prepare client for events on a specific segment */
162 | message OpenSegment {
163 | }
164 |
165 | /* Message to provide parameters for resetting a persistent stream */
166 | message ResetStreamConfiguration {
167 | oneof type {
168 | google.protobuf.Empty head = 1; /* indicates reset to head */
169 | google.protobuf.Empty tail = 2; /* indicates reset to tail */
170 | int64 datetime = 3; /* timestamp in epoch milliseconds */
171 | int64 position = 4; /* global index (inclusive) */
172 | }
173 | }
174 |
175 | /* result of create stream */
176 | enum CreateResult {
177 | created = 0;
178 | already_exists = 1;
179 | }
--------------------------------------------------------------------------------
/src/main/proto/query.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package io.axoniq.axonserver.grpc.query;
3 | import "common.proto";
4 | option java_multiple_files = true;
5 |
6 | /* Service providing operations for the Query Messaging component of AxonServer */
7 | service QueryService {
8 |
9 | /* Opens a Query- and Instruction stream to AxonServer. */
10 | rpc OpenStream (stream QueryProviderOutbound) returns (stream QueryProviderInbound) {
11 | }
12 |
13 | /* Sends a point-to-point or scatter-gather Query */
14 | rpc Query (QueryRequest) returns (stream QueryResponse) {
15 | }
16 |
17 | /* Opens a Subscription Query */
18 | rpc Subscription (stream SubscriptionQueryRequest) returns (stream SubscriptionQueryResponse) {
19 | }
20 | }
21 |
22 | /* Message containing Query related instructions for Axon Server */
23 | message QueryProviderOutbound {
24 |
25 | /* The actual instruction to send */
26 | oneof request {
27 |
28 | /* Registers a Query Handler with AxonServer */
29 | QuerySubscription subscribe = 1;
30 |
31 | /* Unregisters a Query Handler with AxonServer */
32 | QuerySubscription unsubscribe = 2;
33 |
34 | /* Grant permits to AxonServer to send a number of messages to the client */
35 | FlowControl flow_control = 3;
36 |
37 | /* Sends a Response to a Query received via the inbound stream */
38 | QueryResponse query_response = 4;
39 |
40 | /* Indicator that all responses for Query have been sent */
41 | QueryComplete query_complete = 5;
42 |
43 | /* Sends a response for a Subscription Query that has been received via the inbound stream */
44 | SubscriptionQueryResponse subscription_query_response = 6;
45 |
46 | /* Acknowledgement of previously sent instruction via inbound stream */
47 | InstructionAck ack = 7;
48 | }
49 |
50 | /* Instruction identifier. If this identifier is set, this instruction will be acknowledged via inbound stream */
51 | string instruction_id = 8;
52 | }
53 |
54 | /* Queries or Query related instructions from AxonServer for the connected application */
55 | message QueryProviderInbound {
56 |
57 | /* The actual query or instruction */
58 | oneof request {
59 |
60 | /* Acknowledgement of previously sent instruction via outbound stream */
61 | InstructionAck ack = 1;
62 |
63 | /* Represents an incoming Query, for which this component is expected to provide a response */
64 | QueryRequest query = 2;
65 |
66 | /* Represents an incoming Subscription Query, for which this component is expected to provide a response and updates */
67 | SubscriptionQueryRequest subscription_query_request = 3;
68 |
69 | /* Indicator that receiver is no more interested in updates of this query */
70 | QueryReference query_cancel = 5;
71 |
72 | /* Indicator that receiver should send more updates of this query */
73 | QueryFlowControl query_flow_control = 6;
74 | }
75 |
76 | /* Instruction identifier. If this identifier is set, this instruction will be acknowledged via outbound stream */
77 | string instruction_id = 4;
78 | }
79 |
80 | message QueryReference {
81 |
82 | /* The identifier of the query request. */
83 | string request_id = 1;
84 | }
85 |
86 | /* Message indicating that query has been completed. */
87 | message QueryComplete {
88 |
89 | /* A unique identifier for this message */
90 | string message_id = 1;
91 |
92 | /* The identifier of the incoming query to complete */
93 | string request_id = 2;
94 | }
95 |
96 | /* Message indicating that consumer is requesting more messages from producer. */
97 | message QueryFlowControl {
98 |
99 | /* The identifier of the incoming query to complete */
100 | QueryReference query_reference = 1;
101 |
102 | /* Number of messages requested */
103 | int64 permits = 2;
104 | }
105 |
106 | /* Message representing an incoming Query */
107 | message QueryRequest {
108 |
109 | /* The message ID of the incoming Query */
110 | string message_identifier = 1;
111 |
112 | /* The name of the Query to execute */
113 | string query = 2;
114 |
115 | /* The timestamp of the Query creation */
116 | int64 timestamp = 3;
117 |
118 | /* A payload accompanying the Query */
119 | SerializedObject payload = 4;
120 |
121 | /* Meta Data providing contextual information of the Query */
122 | map meta_data = 5;
123 |
124 | /* An object describing the expectations of the Response Type */
125 | SerializedObject response_type = 6;
126 |
127 | /* Any instructions for components Routing or Handling the Query */
128 | repeated ProcessingInstruction processing_instructions = 7;
129 |
130 | /* The unique identifier of the client instance dispatching the query */
131 | string client_id = 8;
132 |
133 | /* The Name of the Component dispatching the query */
134 | string component_name = 9;
135 | }
136 |
137 | /* Message that represents the Response to a Query */
138 | message QueryResponse {
139 | /* The unique identifier of the Response Message */
140 | string message_identifier = 1;
141 |
142 | /* An Error Code identifying the type of error, if any */
143 | string error_code = 2;
144 |
145 | /* A detailed description of the error, if any */
146 | ErrorMessage error_message = 3;
147 |
148 | /* The Payload of the Response Message */
149 | SerializedObject payload = 4;
150 |
151 | /* Any Meta Data describing the context of the Response Message */
152 | map meta_data = 5;
153 |
154 | /* Any instructions for components Routing or Handling the Response Message */
155 | repeated ProcessingInstruction processing_instructions = 6;
156 |
157 | /* The unique identifier of the Query to which this is a response */
158 | string request_identifier = 7;
159 |
160 | /* Some numbers are reserved for internal use for additional properties between AxonServer nodes */
161 | reserved 15;
162 | }
163 |
164 | /* Message that represents a Subscription Query */
165 | message SubscriptionQuery {
166 |
167 | /* A unique identifier for this subscription */
168 | string subscription_identifier = 1;
169 |
170 | /* The number of messages the Server may send before needing to await additional permits */
171 | int64 number_of_permits = 2;
172 |
173 | /* The Query describing the desire for information */
174 | QueryRequest query_request = 3;
175 |
176 | /* A description of the type of Object expected as Update Responses */
177 | SerializedObject update_response_type = 4;
178 | }
179 |
180 | /* A message containing an Update of a Query Subscription Response */
181 | message QueryUpdate {
182 |
183 | /* The unique identifier of this Update */
184 | string message_identifier = 2;
185 |
186 | /* The object representing the Update */
187 | SerializedObject payload = 3;
188 |
189 | /* Meta Data providing contextual information of the Update */
190 | map meta_data = 4;
191 |
192 | /* The identifier of the Client instance providing the Update */
193 | string client_id = 5;
194 |
195 | /* The Component Name of the Client providing the Update */
196 | string component_name = 6;
197 |
198 | /* An Error Code identifying the type of error, if any */
199 | string error_code = 7;
200 |
201 | /* A detailed description of the error, if any */
202 | ErrorMessage error_message = 8;
203 | }
204 |
205 | /* Message indicating that all relevant Updates have been sent for a Subscription Query, and that no further Updates are available */
206 | message QueryUpdateComplete {
207 |
208 | /* The identifier of the Client instance providing the Update */
209 | string client_id = 2;
210 |
211 | /* The Component Name of the Client providing the Update */
212 | string component_name = 3;
213 | }
214 |
215 | /* Message indicating that an Error occurred and that no Updates will be sent for a Subscription Query */
216 | message QueryUpdateCompleteExceptionally {
217 |
218 | /* The identifier of the Client instance providing the Update */
219 | string client_id = 2;
220 |
221 | /* The Component Name of the Client providing the Update */
222 | string component_name = 3;
223 |
224 | /* The Code describing the type of Error that occurred */
225 | string error_code = 5;
226 |
227 | /* A detailed description of the error, if available */
228 | ErrorMessage error_message = 6;
229 | }
230 |
231 | /* Message describing possible interactions for a Subscription Query */
232 | message SubscriptionQueryRequest {
233 |
234 | /* The actual request. The Subscription Query is opened using a `subscribe`, which opens the flow of updates. Once
235 | successful, the `get_initial_result` retrieves the initial result of the subscription. For the server to send
236 | more updates than the initial number of permits, use the `flow_control` request to send more permits.
237 | */
238 | oneof request {
239 |
240 | /* Start a Subscription Query with the given details. */
241 | SubscriptionQuery subscribe = 1;
242 |
243 | /* Ends a previously started Subscription Query with the given details */
244 | SubscriptionQuery unsubscribe = 2;
245 |
246 | /* Requests the initial result of a subscription query to be sent. This should always be done after opening the
247 | subscription query itself, to remove concurrency conflicts with Update messages.
248 | */
249 | SubscriptionQuery get_initial_result = 3;
250 |
251 | /* Allows the Server to provide additional Updates to be sent. Only the `number_of_permits` field needs to be
252 | set on this message.
253 | */
254 | SubscriptionQuery flow_control = 4;
255 | }
256 | }
257 |
258 | /* Represents a Response Message for a Subscription Query */
259 | message SubscriptionQueryResponse {
260 |
261 | /* The unique identifier for this message */
262 | string message_identifier = 1;
263 |
264 | /* The identifier of the subscription query this is a response for */
265 | string subscription_identifier = 2;
266 |
267 | /* The actual response. The `initial_result` message is sent as a response to `get_initial_result`. An `update`
268 | messages is sent for each update available for the query, even before the Initial Result is supplied. The
269 | `complete` or `complete_exceptionally` are sent when the publishing side completed the Subscription Query,
270 | either regularly (`complete`) or because an error occurred (`complete_exceptionally`).
271 | */
272 | oneof response {
273 |
274 | /* Provides an Initial Response */
275 | QueryResponse initial_result = 3;
276 |
277 | /* Provides an Update Response */
278 | QueryUpdate update = 4;
279 |
280 | /* Indicates the Query is complete, and no more Updates will be sent */
281 | QueryUpdateComplete complete = 5;
282 |
283 | /* Indicates the Query failed exceptionally, and no more Updates will be sent */
284 | QueryUpdateCompleteExceptionally complete_exceptionally = 6;
285 | }
286 | }
287 |
288 | /* Message containing details of a Registration of a Query Handler in a component*/
289 | message QuerySubscription {
290 |
291 | /* The unique identifier of this Message */
292 | string message_id = 1;
293 |
294 | /* The name of the Query the Handler is subscribed to */
295 | string query = 2;
296 |
297 | /* The type of Result this Handler produces */
298 | string result_name = 3;
299 |
300 | /* The name of the Component containing the Query Handler */
301 | string component_name = 4;
302 |
303 | /* The unique identifier of the Client Instance containing the Query Handler */
304 | string client_id = 5;
305 |
306 | /* Deprecated field - nr_of_handlers */
307 | reserved 6;
308 | }
309 |
--------------------------------------------------------------------------------