1+ syntax = "proto3" ;
2+
3+ package kurrentdb.protocol.v2 ;
4+
5+ option csharp_namespace = "KurrentDB.Protocol.Streams.V2" ;
6+ option java_package = "io.kurrentdb.streams.v2" ;
7+ option java_multiple_files = true ;
8+
9+ import "google/protobuf/timestamp.proto" ;
10+ import "google/protobuf/duration.proto" ;
11+ import "google/protobuf/struct.proto" ;
12+
13+ service StreamsService {
14+ // Executes an atomic operation to append records to multiple streams.
15+ // This transactional method ensures that all appends either succeed
16+ // completely, or are entirely rolled back, thereby maintaining strict data
17+ // consistency across all involved streams.
18+ rpc MultiStreamAppend (MultiStreamAppendRequest ) returns (MultiStreamAppendResponse );
19+
20+ // Streaming version of MultiStreamAppend that allows clients to send multiple
21+ // append requests over a single connection. When the stream completes, all
22+ // records are appended transactionally (all succeed or fail together).
23+ // Provides improved efficiency for high-throughput scenarios while
24+ // maintaining the same transactional guarantees.
25+ rpc MultiStreamAppendSession (stream AppendStreamRequest ) returns (MultiStreamAppendResponse );
26+ }
27+
28+ message ProtocolDataUnit {
29+ string id = 1 ;
30+ map <string , DynamicValue > properties = 2 ;
31+ bytes data = 3 ;
32+ google.protobuf.Timestamp timestamp = 4 ;
33+ }
34+
35+ // Record to be appended to a stream.
36+ message AppendRecord {
37+ // Universally Unique identifier for the record.
38+ // If not provided, the server will generate a new one.
39+ optional string record_id = 1 ;
40+ // A collection of properties providing additional system information about the
41+ // record.
42+ map <string , DynamicValue > properties = 2 ;
43+ // The actual data payload of the record, stored as bytes.
44+ bytes data = 3 ;
45+ // // Optional timestamp indicating when the record was created.
46+ // // If not provided, the server will use the current time.
47+ // optional google.protobuf.Timestamp timestamp = 4;
48+ }
49+
50+ // Constants that match the expected state of a stream during an
51+ // append operation. It can be used to specify whether the stream should exist,
52+ // not exist, or can be in any state.
53+ enum ExpectedRevisionConstants {
54+ // The stream should exist and the expected revision should match the current
55+ EXPECTED_REVISION_CONSTANTS_SINGLE_EVENT = 0 ;
56+ // It is not important whether the stream exists or not.
57+ EXPECTED_REVISION_CONSTANTS_ANY = -2 ;
58+ // The stream should not exist. If it does, the append will fail.
59+ EXPECTED_REVISION_CONSTANTS_NO_STREAM = -1 ;
60+ // The stream should exist
61+ EXPECTED_REVISION_CONSTANTS_EXISTS = -4 ;
62+ }
63+
64+ // Represents the input for appending records to a specific stream.
65+ message AppendStreamRequest {
66+ // The name of the stream to append records to.
67+ string stream = 1 ;
68+ // The records to append to the stream.
69+ repeated AppendRecord records = 2 ;
70+ // The expected revision of the stream. If the stream's current revision does
71+ // not match, the append will fail.
72+ // The expected revision can also be one of the special values
73+ // from ExpectedRevisionConstants.
74+ // Missing value means no expectation, the same as EXPECTED_REVISION_CONSTANTS_ANY
75+ optional sint64 expected_revision = 3 ;
76+ }
77+
78+ // Success represents the successful outcome of an append operation.
79+ message AppendStreamSuccess {
80+ // The name of the stream to which records were appended.
81+ string stream = 1 ;
82+ // The position of the last appended record in the stream.
83+ int64 position = 2 ;
84+ // The expected revision of the stream after the append operation.
85+ int64 stream_revision = 3 ;
86+ }
87+
88+ // Failure represents the detailed error information when an append operation fails.
89+ message AppendStreamFailure {
90+ // The name of the stream to which records were appended.
91+ string stream = 1 ;
92+
93+ // The error details
94+ oneof error {
95+ // Failed because the actual stream revision didn't match the expected revision.
96+ ErrorDetails.WrongExpectedRevision wrong_expected_revision = 2 ;
97+ // Failed because the client lacks sufficient permissions.
98+ ErrorDetails.AccessDenied access_denied = 3 ;
99+ // Failed because the target stream has been deleted.
100+ ErrorDetails.StreamDeleted stream_deleted = 4 ;
101+ }
102+ }
103+
104+ // AppendStreamOutput represents the output of appending records to a specific
105+ // stream.
106+ message AppendStreamResponse {
107+ // The result of the append operation.
108+ oneof result {
109+ // Success represents the successful outcome of an append operation.
110+ AppendStreamSuccess success = 1 ;
111+ // Failure represents the details of a failed append operation.
112+ AppendStreamFailure failure = 2 ;
113+ }
114+ }
115+
116+ // MultiStreamAppendRequest represents a request to append records to multiple streams.
117+ message MultiStreamAppendRequest {
118+ // A list of AppendStreamInput messages, each representing a stream to which records should be appended.
119+ repeated AppendStreamRequest input = 1 ;
120+ }
121+
122+ // Response from the MultiStreamAppend operation.
123+ message MultiStreamAppendResponse {
124+ oneof result {
125+ // Success represents the successful outcome of a multi-stream append operation.
126+ Success success = 1 ;
127+ // Failure represents the details of a failed multi-stream append operation.
128+ Failure failure = 2 ;
129+ }
130+
131+ message Success {
132+ repeated AppendStreamSuccess output = 1 ;
133+ }
134+
135+ message Failure {
136+ repeated AppendStreamFailure output = 1 ;
137+ }
138+ }
139+
140+ // ErrorDetails provides detailed information about specific error conditions.
141+ message ErrorDetails {
142+ // When the user does not have sufficient permissions to perform the operation.
143+ message AccessDenied {
144+ // The simplified reason for access denial.
145+ string reason = 1 ;
146+ }
147+
148+ // When the stream has been deleted.
149+ message StreamDeleted {
150+ // The time when the stream was deleted.
151+ google.protobuf.Timestamp deleted_at = 1 ;
152+
153+ // If the stream was hard deleted, you cannot reuse the stream name,
154+ // it will raise an exception if you try to append to it again.
155+ bool tombstoned = 2 ;
156+ }
157+
158+ // When the expected revision of the stream does not match the actual revision.
159+ message WrongExpectedRevision {
160+ // The actual revision of the stream.
161+ int64 stream_revision = 1 ;
162+ }
163+
164+ // When the transaction exceeds the maximum size allowed
165+ // (its bigger than the configured chunk size).
166+ message TransactionMaxSizeExceeded {
167+ // The maximum allowed size of the transaction.
168+ uint32 max_size = 1 ;
169+ }
170+ }
171+
172+ //===================================================================
173+ // Shared
174+ //===================================================================
175+
176+ // Represents a list of dynamically typed values.
177+ message ListDynamicValue {
178+ // Repeated property of dynamically typed values.
179+ repeated DynamicValue values = 1 ;
180+ }
181+
182+ // Represents a dynamic value
183+ message DynamicValue {
184+ oneof kind {
185+ // Represents a null value.
186+ google.protobuf.NullValue null_value = 1 ;
187+ // Represents a 32-bit signed integer value.
188+ sint32 int32_value = 2 ;
189+ // Represents a 64-bit signed integer value.
190+ sint64 int64_value = 3 ;
191+ // Represents a byte array value.
192+ bytes bytes_value = 4 ;
193+ // Represents a 64-bit double-precision floating-point value.
194+ double double_value = 5 ;
195+ // Represents a 32-bit single-precision floating-point value
196+ float float_value = 6 ;
197+ // Represents a string value.
198+ string string_value = 7 ;
199+ // Represents a boolean value.
200+ bool boolean_value = 8 ;
201+ // Represents a timestamp value.
202+ google.protobuf.Timestamp timestamp_value = 9 ;
203+ // Represents a duration value.
204+ google.protobuf.Duration duration_value = 10 ;
205+ // // Represents a list of dynamic values.
206+ // ListDynamicValue list_value = 11;
207+ // // Represents a json struct
208+ // google.protobuf.Struct struct_value = 12;
209+ }
210+ }
0 commit comments