Skip to content
File

Blob: src/workerd/io/actor-storage.capnp

2.0 KB
1# Copyright (c) 2017-2022 Cloudflare, Inc.
2# Licensed under the Apache 2.0 license found in the LICENSE file or at:
3# https://opensource.org/licenses/Apache-2.0
4 
5@0xb200a391b94343f1;
6 
7using Cxx = import "/capnp/c++.capnp";
8$Cxx.namespace("workerd::rpc");
9$Cxx.allowCancellation;
10 
11interface ActorStorage @0xd7759d7fc87c08e4 {
12 struct KeyValue {
13 key @0 :Data;
14 value @1 :Data;
15 }
16 
17 struct KeyRename {
18 oldKey @0 :Data;
19 newKey @1 :Data;
20 }
21 
22 getStage @0 (stableId :Text) -> (stage :Stage);
23 # Get the storage capability for the given stage of the pipeline, identified by its stable ID.
24 
25 interface Operations @0xb512f2ce1f544439 {
26 get @0 (key :Data) -> (value :Data);
27 list @3 (start :Data, end :Data, limit :Int32, reverse :Bool, stream :ListStream, prefix :Data);
28 put @1 (entries :List(KeyValue));
29 delete @2 (keys :List(Data)) -> (numDeleted :Int32);
30 
31 getMultiple @4 (keys :List(Data), stream :ListStream);
32 deleteAll @5 () -> (numDeleted :Int32);
33 
34 rename @9 (entries :List(KeyRename)) -> (renamed :List(Data));
35 
36 getAlarm @6 () -> (scheduledTimeMs :Int64);
37 setAlarm @7 (scheduledTimeMs :Int64);
38 deleteAlarm @8 (timeToDeleteMs :Int64) -> (deleted :Bool);
39 }
40 
41 struct DbSettings {
42 enum Priority {
43 default @0;
44 low @1;
45 }
46 priority @0 :Priority;
47 asOfTimeMs @1 :Int64;
48 }
49 
50 interface Stage @0xdc35f52864c57550 extends(Operations) {
51 txn @0 (settings :DbSettings) -> (transaction :Transaction);
52 
53 interface Transaction extends(Operations) {
54 commit @0 ();
55 rollback @1 ();
56 }
57 }
58 
59 interface ListStream {
60 values @0 (list :List(KeyValue)) -> stream;
61 end @1 ();
62 }
63 
64 const maxKeys :UInt32 = 128;
65 # The maximum number of keys that clients should be allowed to modify in a single storage
66 # operation. This should be enforced for operations that access or modify multiple keys. This
67 # limit will not be enforced upon the total count of keys involved in explicit transactions.
68 
69 const renameLimit :UInt32 = 1000;
70 # The maximum number of keys in a rename() operation.
71}