stream.capnp (2545B)
1 # Copyright (c) 2019 Cloudflare, Inc. and contributors 2 # Licensed under the MIT License: 3 # 4 # Permission is hereby granted, free of charge, to any person obtaining a copy 5 # of this software and associated documentation files (the "Software"), to deal 6 # in the Software without restriction, including without limitation the rights 7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 # copies of the Software, and to permit persons to whom the Software is 9 # furnished to do so, subject to the following conditions: 10 # 11 # The above copyright notice and this permission notice shall be included in 12 # all copies or substantial portions of the Software. 13 # 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 # THE SOFTWARE. 21 22 @0x86c366a91393f3f8; 23 # Defines placeholder types used to provide backwards-compatibility while introducing streaming 24 # to the language. The goal is that old code generators that don't know about streaming can still 25 # generate code that functions, leaving it up to the application to implement flow control 26 # manually. 27 28 $import "/capnp/c++.capnp".namespace("capnp"); 29 30 struct StreamResult @0x995f9a3377c0b16e { 31 # Empty struct that serves as the return type for "streaming" methods. 32 # 33 # Defining a method like: 34 # 35 # write @0 (bytes :Data) -> stream; 36 # 37 # Is equivalent to: 38 # 39 # write @0 (bytes :Data) -> import "/capnp/stream.capnp".StreamResult; 40 # 41 # However, implementations that recognize streaming will elide the reference to StreamResult 42 # and instead give write() a different signature appropriate for streaming. 43 # 44 # Streaming methods do not return a result -- that is, they return Promise<void>. This promise 45 # resolves not to indicate that the call was actually delivered, but instead to provide 46 # backpressure. When the previous call's promise resolves, it is time to make another call. On 47 # the client side, the RPC system will resolve promises immediately until an appropriate number 48 # of requests are in-flight, and then will delay promise resolution to apply back-pressure. 49 # On the server side, the RPC system will deliver one call at a time. 50 }