@@ -50,6 +50,14 @@ service Octopus {
5050 * subscription and the new keys will be used.
5151 */
5252 rpc Listen (stream ListenMessage ) returns (stream EventCall );
53+ /**
54+ * Creates a MongoDB index for a concrete collection.
55+ *
56+ * This is idempotent when the same index name already exists with the same
57+ * definition. If the name exists with a different definition, the server
58+ * rejects the request instead of replacing the index implicitly.
59+ */
60+ rpc CreateIndex (CreateIndexRequest ) returns (CreateIndexResponse );
5361}
5462
5563enum PersistanceTarget {
@@ -190,6 +198,49 @@ message QueryResponse {
190198 PageInfo page_info = 2 ;
191199}
192200
201+ /**
202+ * Request for creating a developer-defined MongoDB index.
203+ */
204+ message CreateIndexRequest {
205+ // Concrete collection name. Wildcard patterns are not allowed.
206+ string collection = 1 ;
207+
208+ // Optional explicit index name. If empty, the server can generate one from
209+ // the requested fields.
210+ string name = 2 ;
211+
212+ // Ordered list of fields that make up the index.
213+ repeated IndexField fields = 3 ;
214+
215+ // Whether the index should enforce unique values.
216+ bool unique = 4 ;
217+ }
218+
219+ /**
220+ * A single field inside a developer-defined index.
221+ */
222+ message IndexField {
223+ enum IndexDirection {
224+ UNKNOWN = 0 ;
225+ ASC = 1 ;
226+ DESC = 2 ;
227+ }
228+
229+ // Mongo path to index, e.g. data.player_uuid, data.server, created_at.
230+ string path = 1 ;
231+
232+ // Index sort direction for this path.
233+ IndexDirection direction = 2 ;
234+ }
235+
236+ /**
237+ * Response returned after creating or confirming an index.
238+ */
239+ message CreateIndexResponse {
240+ // The MongoDB index name.
241+ string name = 1 ;
242+ }
243+
193244/**
194245 * Message type for the listen stream.
195246 */
0 commit comments