@@ -43,6 +43,63 @@ service CRUDService {
4343// Transactionally executes a set of read and write operations.
4444
4545message ExecuteRequest {
46+ // Message queue push section in a transaction request.
47+ message Push {
48+ // Definition of messages pushed to a shard-local queue.
49+ message Message {
50+ // Topic of the message.
51+ string topic = 1 ;
52+ // Data of the message.
53+ Value data = 2 ;
54+ // Time to live of the message.
55+ double ttl = 3 ;
56+ }
57+ // The source code of the Lua function that will be used to generate
58+ // messages. It's optional: if omitted, messages from the `messages`
59+ // field will be sent instead.
60+ //
61+ // The function is passed three arguments: the resulting read set,
62+ // the resulting write set, and an optional additional argument specified
63+ // as `func_arg`. If the function raises an error, the error will be
64+ // returned in the `push_err` field. The transaction will not be affected.
65+ //
66+ // The function must return an array of messages. Message is an array
67+ // of `{topic, data, ttl}`, where `topic` is required and is a string
68+ // value, `data` is required and is of any supported value type,
69+ // and `ttl` is optional and represents a number of seconds.
70+ //
71+ // A read/write operation is passed in an array: {space, key, tuple}.
72+ // (without string key names).
73+ //
74+ // Below is an example of a Lua function that returns messages
75+ // with `read_topic` as topic and the first fields of the read tuples
76+ // as data if the optional argument is `true`, and `write_topic`
77+ // as topic and the first fields of the written tuples as data otherwise.
78+ //
79+ // function(rs, ws, arg)
80+ // local messages = {}
81+ // if arg == true then
82+ // for _, r in ipairs(rs) do
83+ // if r.tuple ~= nil then
84+ // table.insert(messages, {'read_topic', r.tuple[1]})
85+ // end
86+ // end
87+ // else
88+ // for _, w in ipairs(ws) do
89+ // if w.tuple ~= nil then
90+ // table.insert(messages, {'write_topic', w.tuple[1]})
91+ // end
92+ // end
93+ // end
94+ // return messages
95+ // end
96+ //
97+ string func = 1 ;
98+ // Additional argument to the push function. Optional.
99+ Value func_arg = 2 ;
100+ // Messages to send if the push function is not provided.
101+ repeated Message messages = 3 ;
102+ }
46103 // Array of read operations.
47104 repeated Operation read_set = 1 ;
48105 // Array of write operations.
@@ -89,6 +146,8 @@ message ExecuteRequest {
89146 // Map : space name -> tuple format.
90147 // Contains formats of all provided tuples. Optional.
91148 map <string , TupleFormat > tuple_formats = 6 ;
149+ // Description of messages to push when executing a transaction.
150+ Push push = 7 ;
92151}
93152
94153message ExecuteResponse {
@@ -103,6 +162,9 @@ message ExecuteResponse {
103162 // Map : space name -> tuple format.
104163 // Contains formats of all returned tuples.
105164 map <string , TupleFormat > tuple_formats = 5 ;
165+ // PushErr is the error returned by the push function, or nil
166+ // if no error occurred.
167+ Error push_err = 6 ;
106168}
107169
108170// Transactionally inserts tuples into a space.
0 commit comments