mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-23 15:17:57 +01:00
make compile
This commit is contained in:
parent
e210caf77e
commit
0ba44e4a1d
@ -6,3 +6,7 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
capnp = "0.16"
|
||||
|
||||
[build-dependencies]
|
||||
capnpc = "0.16"
|
||||
|
21
runtime/console-api/build.rs
Normal file
21
runtime/console-api/build.rs
Normal file
@ -0,0 +1,21 @@
|
||||
fn generate_api() {
|
||||
println!("cargo:rerun-if-changed=schema");
|
||||
let mut compile_command = ::capnpc::CompilerCommand::new();
|
||||
compile_command
|
||||
.src_prefix("schema")
|
||||
.default_parent_module(vec!["schema".to_string()])
|
||||
.file("schema/async_ops.capnp")
|
||||
.file("schema/common.capnp")
|
||||
.file("schema/instrument.capnp")
|
||||
.file("schema/resources.capnp")
|
||||
.file("schema/streaming.capnp")
|
||||
.file("schema/stream.capnp")
|
||||
.file("schema/tasks.capnp")
|
||||
.file("schema/trace.capnp")
|
||||
.run()
|
||||
.expect("Failed to generate API code");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
generate_api()
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
@0xd53fadcd6c8f437f;
|
||||
|
||||
using Common = import "common.capnp";
|
||||
using Stream = import "stream.capnp";
|
||||
using Stream = import "streaming.capnp";
|
||||
using Tasks = import "tasks.capnp";
|
||||
using Resources = import "resources.capnp";
|
||||
using AsyncOps = import "async_ops.capnp";
|
||||
|
@ -39,7 +39,7 @@ struct Resource {
|
||||
# The kind of this resource
|
||||
struct Kind {
|
||||
union {
|
||||
wellKnown @0 :WellKnown;
|
||||
known @0 :WellKnown;
|
||||
other @1 :Text;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,50 @@
|
||||
@0x85894bd060182ed3;
|
||||
# Copyright (c) 2019 Cloudflare, Inc. and contributors
|
||||
# Licensed under the MIT License:
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
interface Receiver(T) {
|
||||
send @0 (chunk :T) -> stream;
|
||||
done @1 ();
|
||||
}
|
||||
@0x86c366a91393f3f8;
|
||||
# Defines placeholder types used to provide backwards-compatibility while introducing streaming
|
||||
# to the language. The goal is that old code generators that don't know about streaming can still
|
||||
# generate code that functions, leaving it up to the application to implement flow control
|
||||
# manually.
|
||||
|
||||
interface Sender {
|
||||
pause @0 ();
|
||||
resume @1 ();
|
||||
stop @2 ();
|
||||
$import "/capnp/c++.capnp".namespace("capnp");
|
||||
|
||||
struct StreamResult @0x995f9a3377c0b16e {
|
||||
# Empty struct that serves as the return type for "streaming" methods.
|
||||
#
|
||||
# Defining a method like:
|
||||
#
|
||||
# write @0 (bytes :Data) -> stream;
|
||||
#
|
||||
# Is equivalent to:
|
||||
#
|
||||
# write @0 (bytes :Data) -> import "/capnp/stream.capnp".StreamResult;
|
||||
#
|
||||
# However, implementations that recognize streaming will elide the reference to StreamResult
|
||||
# and instead give write() a different signature appropriate for streaming.
|
||||
#
|
||||
# Streaming methods do not return a result -- that is, they return Promise<void>. This promise
|
||||
# resolves not to indicate that the call was actually delivered, but instead to provide
|
||||
# backpressure. When the previous call's promise resolves, it is time to make another call. On
|
||||
# the client side, the RPC system will resolve promises immediately until an appropriate number
|
||||
# of requests are in-flight, and then will delay promise resolution to apply back-pressure.
|
||||
# On the server side, the RPC system will deliver one call at a time.
|
||||
}
|
||||
|
12
runtime/console-api/schema/streaming.capnp
Normal file
12
runtime/console-api/schema/streaming.capnp
Normal file
@ -0,0 +1,12 @@
|
||||
@0x85894bd060182ed3;
|
||||
|
||||
interface Receiver(T) {
|
||||
send @0 (chunk :T) -> import "stream.capnp".StreamResult;
|
||||
done @1 ();
|
||||
}
|
||||
|
||||
interface Sender {
|
||||
pause @0 ();
|
||||
resume @1 ();
|
||||
stop @2 ();
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
@0xb021b19fd5986342;
|
||||
|
||||
using Common = import "common.capnp";
|
||||
using Stream = import "stream.capnp";
|
||||
using Stream = import "streaming.capnp";
|
||||
|
||||
interface Trace {
|
||||
watch @0 (request :WatchRequest, receiver :Stream.Receiver(TraceEvent)) -> (stream :Stream.Sender);
|
||||
|
@ -1,14 +1,11 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
mod schema;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
pub use schema::{
|
||||
async_ops_capnp as async_ops,
|
||||
common_capnp as common,
|
||||
instrument_capnp as instrument,
|
||||
resources_capnp as resource,
|
||||
streaming_capnp as streaming,
|
||||
tasks_capnp as tasks,
|
||||
trace_capnp as trace,
|
||||
};
|
||||
|
31
runtime/console-api/src/schema.rs
Normal file
31
runtime/console-api/src/schema.rs
Normal file
@ -0,0 +1,31 @@
|
||||
pub mod async_ops_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/async_ops_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod common_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/common_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod instrument_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/instrument_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod resources_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/resources_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod streaming_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/streaming_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod stream_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/stream_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod tasks_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/tasks_capnp.rs"));
|
||||
}
|
||||
|
||||
pub mod trace_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/trace_capnp.rs"));
|
||||
}
|
Loading…
Reference in New Issue
Block a user