summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/thrift/lib/rs/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/jaegertracing/thrift/lib/rs/test')
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/Cargo.toml15
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/Makefile.am55
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_client.rs239
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_server.rs313
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/src/lib.rs55
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/thrifts/Base_One.thrift84
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/thrifts/Base_Two.thrift50
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/thrifts/Midlayer.thrift71
-rw-r--r--src/jaegertracing/thrift/lib/rs/test/thrifts/Ultimate.thrift66
9 files changed, 948 insertions, 0 deletions
diff --git a/src/jaegertracing/thrift/lib/rs/test/Cargo.toml b/src/jaegertracing/thrift/lib/rs/test/Cargo.toml
new file mode 100644
index 000000000..dc4ffe32b
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/Cargo.toml
@@ -0,0 +1,15 @@
+[package]
+name = "kitchen-sink"
+version = "0.1.0"
+license = "Apache-2.0"
+authors = ["Apache Thrift Developers <dev@thrift.apache.org>"]
+publish = false
+
+[dependencies]
+clap = "<2.28.0"
+ordered-float = "1.0"
+try_from = "0.3"
+
+[dependencies.thrift]
+path = "../"
+
diff --git a/src/jaegertracing/thrift/lib/rs/test/Makefile.am b/src/jaegertracing/thrift/lib/rs/test/Makefile.am
new file mode 100644
index 000000000..486188cfe
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/Makefile.am
@@ -0,0 +1,55 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+THRIFT = $(top_builddir)/compiler/cpp/thrift
+
+stubs: thrifts/Base_One.thrift thrifts/Base_Two.thrift thrifts/Midlayer.thrift thrifts/Ultimate.thrift $(top_builddir)/test/Recursive.thrift $(THRIFT)
+ $(THRIFT) -I ./thrifts -out src --gen rs thrifts/Base_One.thrift
+ $(THRIFT) -I ./thrifts -out src --gen rs thrifts/Base_Two.thrift
+ $(THRIFT) -I ./thrifts -out src --gen rs thrifts/Midlayer.thrift
+ $(THRIFT) -I ./thrifts -out src --gen rs thrifts/Ultimate.thrift
+ $(THRIFT) -out src --gen rs $(top_builddir)/test/Recursive.thrift
+ $(THRIFT) -out src --gen rs $(top_builddir)/test/Identifiers.thrift #THRIFT-4953
+
+check: stubs
+ $(CARGO) build
+ $(CARGO) test
+ [ -d bin ] || mkdir bin
+ cp target/debug/kitchen_sink_server bin/kitchen_sink_server
+ cp target/debug/kitchen_sink_client bin/kitchen_sink_client
+
+clean-local:
+ $(CARGO) clean
+ -$(RM) Cargo.lock
+ -$(RM) src/base_one.rs
+ -$(RM) src/base_two.rs
+ -$(RM) src/midlayer.rs
+ -$(RM) src/ultimate.rs
+ -$(RM) -r bin
+
+EXTRA_DIST = \
+ Cargo.toml \
+ thrifts/Base_One.thrift \
+ thrifts/Base_Two.thrift \
+ thrifts/Midlayer.thrift \
+ thrifts/Ultimate.thrift \
+ src/lib.rs \
+ src/bin/kitchen_sink_server.rs \
+ src/bin/kitchen_sink_client.rs
+
diff --git a/src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_client.rs b/src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_client.rs
new file mode 100644
index 000000000..d295c8870
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_client.rs
@@ -0,0 +1,239 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#[macro_use]
+extern crate clap;
+
+extern crate kitchen_sink;
+extern crate thrift;
+
+use std::convert::Into;
+
+use kitchen_sink::base_two::{TNapkinServiceSyncClient, TRamenServiceSyncClient};
+use kitchen_sink::midlayer::{MealServiceSyncClient, TMealServiceSyncClient};
+use kitchen_sink::recursive;
+use kitchen_sink::recursive::{CoRec, CoRec2, RecList, RecTree, TTestServiceSyncClient};
+use kitchen_sink::ultimate::{FullMealServiceSyncClient, TFullMealServiceSyncClient};
+use thrift::protocol::{
+ TBinaryInputProtocol, TBinaryOutputProtocol, TCompactInputProtocol, TCompactOutputProtocol,
+ TInputProtocol, TOutputProtocol,
+};
+use thrift::transport::{
+ ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel, TTcpChannel, WriteHalf,
+};
+
+fn main() {
+ match run() {
+ Ok(()) => println!("kitchen sink client completed successfully"),
+ Err(e) => {
+ println!("kitchen sink client failed with error {:?}", e);
+ std::process::exit(1);
+ }
+ }
+}
+
+fn run() -> thrift::Result<()> {
+ let matches = clap_app!(rust_kitchen_sink_client =>
+ (version: "0.1.0")
+ (author: "Apache Thrift Developers <dev@thrift.apache.org>")
+ (about: "Thrift Rust kitchen sink client")
+ (@arg host: --host +takes_value "Host on which the Thrift test server is located")
+ (@arg port: --port +takes_value "Port on which the Thrift test server is listening")
+ (@arg protocol: --protocol +takes_value "Thrift protocol implementation to use (\"binary\", \"compact\")")
+ (@arg service: --service +takes_value "Service type to contact (\"part\", \"full\", \"recursive\")")
+ )
+ .get_matches();
+
+ let host = matches.value_of("host").unwrap_or("127.0.0.1");
+ let port = value_t!(matches, "port", u16).unwrap_or(9090);
+ let protocol = matches.value_of("protocol").unwrap_or("compact");
+ let service = matches.value_of("service").unwrap_or("part");
+
+ let (i_chan, o_chan) = tcp_channel(host, port)?;
+ let (i_tran, o_tran) = (
+ TFramedReadTransport::new(i_chan),
+ TFramedWriteTransport::new(o_chan),
+ );
+
+ let (i_prot, o_prot): (Box<TInputProtocol>, Box<TOutputProtocol>) = match protocol {
+ "binary" => (
+ Box::new(TBinaryInputProtocol::new(i_tran, true)),
+ Box::new(TBinaryOutputProtocol::new(o_tran, true)),
+ ),
+ "compact" => (
+ Box::new(TCompactInputProtocol::new(i_tran)),
+ Box::new(TCompactOutputProtocol::new(o_tran)),
+ ),
+ unmatched => return Err(format!("unsupported protocol {}", unmatched).into()),
+ };
+
+ run_client(service, i_prot, o_prot)
+}
+
+fn run_client(
+ service: &str,
+ i_prot: Box<TInputProtocol>,
+ o_prot: Box<TOutputProtocol>,
+) -> thrift::Result<()> {
+ match service {
+ "full" => exec_full_meal_client(i_prot, o_prot),
+ "part" => exec_meal_client(i_prot, o_prot),
+ "recursive" => exec_recursive_client(i_prot, o_prot),
+ _ => Err(thrift::Error::from(format!(
+ "unknown service type {}",
+ service
+ ))),
+ }
+}
+
+fn tcp_channel(
+ host: &str,
+ port: u16,
+) -> thrift::Result<(ReadHalf<TTcpChannel>, WriteHalf<TTcpChannel>)> {
+ let mut c = TTcpChannel::new();
+ c.open(&format!("{}:{}", host, port))?;
+ c.split()
+}
+
+fn exec_meal_client(
+ i_prot: Box<TInputProtocol>,
+ o_prot: Box<TOutputProtocol>,
+) -> thrift::Result<()> {
+ let mut client = MealServiceSyncClient::new(i_prot, o_prot);
+
+ // client.full_meal(); // <-- IMPORTANT: if you uncomment this, compilation *should* fail
+ // this is because the MealService struct does not contain the appropriate service marker
+
+ // only the following three calls work
+ execute_call("part", "ramen", || client.ramen(50)).map(|_| ())?;
+ execute_call("part", "meal", || client.meal()).map(|_| ())?;
+ execute_call("part", "napkin", || client.napkin()).map(|_| ())?;
+
+ Ok(())
+}
+
+fn exec_full_meal_client(
+ i_prot: Box<TInputProtocol>,
+ o_prot: Box<TOutputProtocol>,
+) -> thrift::Result<()> {
+ let mut client = FullMealServiceSyncClient::new(i_prot, o_prot);
+
+ execute_call("full", "ramen", || client.ramen(100)).map(|_| ())?;
+ execute_call("full", "meal", || client.meal()).map(|_| ())?;
+ execute_call("full", "napkin", || client.napkin()).map(|_| ())?;
+ execute_call("full", "full meal", || client.full_meal()).map(|_| ())?;
+
+ Ok(())
+}
+
+fn exec_recursive_client(
+ i_prot: Box<TInputProtocol>,
+ o_prot: Box<TOutputProtocol>,
+) -> thrift::Result<()> {
+ let mut client = recursive::TestServiceSyncClient::new(i_prot, o_prot);
+
+ let tree = RecTree {
+ children: Some(vec![Box::new(RecTree {
+ children: Some(vec![
+ Box::new(RecTree {
+ children: None,
+ item: Some(3),
+ }),
+ Box::new(RecTree {
+ children: None,
+ item: Some(4),
+ }),
+ ]),
+ item: Some(2),
+ })]),
+ item: Some(1),
+ };
+
+ let expected_tree = RecTree {
+ children: Some(vec![Box::new(RecTree {
+ children: Some(vec![
+ Box::new(RecTree {
+ children: Some(Vec::new()), // remote returns an empty list
+ item: Some(3),
+ }),
+ Box::new(RecTree {
+ children: Some(Vec::new()), // remote returns an empty list
+ item: Some(4),
+ }),
+ ]),
+ item: Some(2),
+ })]),
+ item: Some(1),
+ };
+
+ let returned_tree = execute_call("recursive", "echo_tree", || client.echo_tree(tree.clone()))?;
+ if returned_tree != expected_tree {
+ return Err(format!(
+ "mismatched recursive tree {:?} {:?}",
+ expected_tree, returned_tree
+ )
+ .into());
+ }
+
+ let list = RecList {
+ nextitem: Some(Box::new(RecList {
+ nextitem: Some(Box::new(RecList {
+ nextitem: None,
+ item: Some(3),
+ })),
+ item: Some(2),
+ })),
+ item: Some(1),
+ };
+ let returned_list = execute_call("recursive", "echo_list", || client.echo_list(list.clone()))?;
+ if returned_list != list {
+ return Err(format!("mismatched recursive list {:?} {:?}", list, returned_list).into());
+ }
+
+ let co_rec = CoRec {
+ other: Some(Box::new(CoRec2 {
+ other: Some(CoRec {
+ other: Some(Box::new(CoRec2 { other: None })),
+ }),
+ })),
+ };
+ let returned_co_rec = execute_call("recursive", "echo_co_rec", || {
+ client.echo_co_rec(co_rec.clone())
+ })?;
+ if returned_co_rec != co_rec {
+ return Err(format!("mismatched co_rec {:?} {:?}", co_rec, returned_co_rec).into());
+ }
+
+ Ok(())
+}
+
+fn execute_call<F, R>(service_type: &str, call_name: &str, mut f: F) -> thrift::Result<R>
+where
+ F: FnMut() -> thrift::Result<R>,
+{
+ let res = f();
+
+ match res {
+ Ok(_) => println!("{}: completed {} call", service_type, call_name),
+ Err(ref e) => println!(
+ "{}: failed {} call with error {:?}",
+ service_type, call_name, e
+ ),
+ }
+
+ res
+}
diff --git a/src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_server.rs b/src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_server.rs
new file mode 100644
index 000000000..73801eaf8
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/src/bin/kitchen_sink_server.rs
@@ -0,0 +1,313 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#[macro_use]
+extern crate clap;
+extern crate kitchen_sink;
+extern crate thrift;
+
+use thrift::protocol::{
+ TBinaryInputProtocolFactory, TBinaryOutputProtocolFactory, TCompactInputProtocolFactory,
+ TCompactOutputProtocolFactory, TInputProtocolFactory, TOutputProtocolFactory,
+};
+use thrift::server::TServer;
+use thrift::transport::{
+ TFramedReadTransportFactory, TFramedWriteTransportFactory, TReadTransportFactory,
+ TWriteTransportFactory,
+};
+
+use kitchen_sink::base_one::Noodle;
+use kitchen_sink::base_two::{
+ BrothType, Napkin, NapkinServiceSyncHandler, Ramen, RamenServiceSyncHandler,
+};
+use kitchen_sink::midlayer::{
+ Dessert, Meal, MealServiceSyncHandler, MealServiceSyncProcessor, Pie,
+};
+use kitchen_sink::recursive;
+use kitchen_sink::ultimate::FullMealAndDrinksServiceSyncHandler;
+use kitchen_sink::ultimate::{
+ Drink, FullMeal, FullMealAndDrinks, FullMealAndDrinksServiceSyncProcessor,
+ FullMealServiceSyncHandler,
+};
+
+fn main() {
+ match run() {
+ Ok(()) => println!("kitchen sink server completed successfully"),
+ Err(e) => {
+ println!("kitchen sink server failed with error {:?}", e);
+ std::process::exit(1);
+ }
+ }
+}
+
+fn run() -> thrift::Result<()> {
+ let matches = clap_app!(rust_kitchen_sink_server =>
+ (version: "0.1.0")
+ (author: "Apache Thrift Developers <dev@thrift.apache.org>")
+ (about: "Thrift Rust kitchen sink test server")
+ (@arg port: --port +takes_value "port on which the test server listens")
+ (@arg protocol: --protocol +takes_value "Thrift protocol implementation to use (\"binary\", \"compact\")")
+ (@arg service: --service +takes_value "Service type to contact (\"part\", \"full\", \"recursive\")")
+ )
+ .get_matches();
+
+ let port = value_t!(matches, "port", u16).unwrap_or(9090);
+ let protocol = matches.value_of("protocol").unwrap_or("compact");
+ let service = matches.value_of("service").unwrap_or("part");
+ let listen_address = format!("127.0.0.1:{}", port);
+
+ println!("binding to {}", listen_address);
+
+ let r_transport_factory = TFramedReadTransportFactory::new();
+ let w_transport_factory = TFramedWriteTransportFactory::new();
+
+ let (i_protocol_factory, o_protocol_factory): (
+ Box<TInputProtocolFactory>,
+ Box<TOutputProtocolFactory>,
+ ) = match &*protocol {
+ "binary" => (
+ Box::new(TBinaryInputProtocolFactory::new()),
+ Box::new(TBinaryOutputProtocolFactory::new()),
+ ),
+ "compact" => (
+ Box::new(TCompactInputProtocolFactory::new()),
+ Box::new(TCompactOutputProtocolFactory::new()),
+ ),
+ unknown => {
+ return Err(format!("unsupported transport type {}", unknown).into());
+ }
+ };
+
+ // FIXME: should processor be boxed as well?
+ //
+ // [sigh] I hate Rust generics implementation
+ //
+ // I would have preferred to build a server here, return it, and then do
+ // the common listen-and-handle stuff, but since the server doesn't have a
+ // common type (because each match arm instantiates a server with a
+ // different processor) this isn't possible.
+ //
+ // Since what I'm doing is uncommon I'm just going to duplicate the code
+ match &*service {
+ "part" => run_meal_server(
+ &listen_address,
+ r_transport_factory,
+ i_protocol_factory,
+ w_transport_factory,
+ o_protocol_factory,
+ ),
+ "full" => run_full_meal_server(
+ &listen_address,
+ r_transport_factory,
+ i_protocol_factory,
+ w_transport_factory,
+ o_protocol_factory,
+ ),
+ "recursive" => run_recursive_server(
+ &listen_address,
+ r_transport_factory,
+ i_protocol_factory,
+ w_transport_factory,
+ o_protocol_factory,
+ ),
+ unknown => Err(format!("unsupported service type {}", unknown).into()),
+ }
+}
+
+fn run_meal_server<RTF, IPF, WTF, OPF>(
+ listen_address: &str,
+ r_transport_factory: RTF,
+ i_protocol_factory: IPF,
+ w_transport_factory: WTF,
+ o_protocol_factory: OPF,
+) -> thrift::Result<()>
+where
+ RTF: TReadTransportFactory + 'static,
+ IPF: TInputProtocolFactory + 'static,
+ WTF: TWriteTransportFactory + 'static,
+ OPF: TOutputProtocolFactory + 'static,
+{
+ let processor = MealServiceSyncProcessor::new(PartHandler {});
+ let mut server = TServer::new(
+ r_transport_factory,
+ i_protocol_factory,
+ w_transport_factory,
+ o_protocol_factory,
+ processor,
+ 1,
+ );
+
+ server.listen(listen_address)
+}
+
+fn run_full_meal_server<RTF, IPF, WTF, OPF>(
+ listen_address: &str,
+ r_transport_factory: RTF,
+ i_protocol_factory: IPF,
+ w_transport_factory: WTF,
+ o_protocol_factory: OPF,
+) -> thrift::Result<()>
+where
+ RTF: TReadTransportFactory + 'static,
+ IPF: TInputProtocolFactory + 'static,
+ WTF: TWriteTransportFactory + 'static,
+ OPF: TOutputProtocolFactory + 'static,
+{
+ let processor = FullMealAndDrinksServiceSyncProcessor::new(FullHandler {});
+ let mut server = TServer::new(
+ r_transport_factory,
+ i_protocol_factory,
+ w_transport_factory,
+ o_protocol_factory,
+ processor,
+ 1,
+ );
+
+ server.listen(listen_address)
+}
+
+struct PartHandler;
+
+impl MealServiceSyncHandler for PartHandler {
+ fn handle_meal(&self) -> thrift::Result<Meal> {
+ println!("part: handling meal call");
+ Ok(meal())
+ }
+}
+
+impl RamenServiceSyncHandler for PartHandler {
+ fn handle_ramen(&self, _: i32) -> thrift::Result<Ramen> {
+ println!("part: handling ramen call");
+ Ok(ramen())
+ }
+}
+
+impl NapkinServiceSyncHandler for PartHandler {
+ fn handle_napkin(&self) -> thrift::Result<Napkin> {
+ println!("part: handling napkin call");
+ Ok(napkin())
+ }
+}
+
+// full service
+//
+
+struct FullHandler;
+
+impl FullMealAndDrinksServiceSyncHandler for FullHandler {
+ fn handle_full_meal_and_drinks(&self) -> thrift::Result<FullMealAndDrinks> {
+ println!("full_meal_and_drinks: handling full meal and drinks call");
+ Ok(FullMealAndDrinks::new(full_meal(), Drink::CanadianWhisky))
+ }
+
+ fn handle_best_pie(&self) -> thrift::Result<Pie> {
+ println!("full_meal_and_drinks: handling pie call");
+ Ok(Pie::MississippiMud) // I prefer Pie::Pumpkin, but I have to check that casing works
+ }
+}
+
+impl FullMealServiceSyncHandler for FullHandler {
+ fn handle_full_meal(&self) -> thrift::Result<FullMeal> {
+ println!("full: handling full meal call");
+ Ok(full_meal())
+ }
+}
+
+impl MealServiceSyncHandler for FullHandler {
+ fn handle_meal(&self) -> thrift::Result<Meal> {
+ println!("full: handling meal call");
+ Ok(meal())
+ }
+}
+
+impl RamenServiceSyncHandler for FullHandler {
+ fn handle_ramen(&self, _: i32) -> thrift::Result<Ramen> {
+ println!("full: handling ramen call");
+ Ok(ramen())
+ }
+}
+
+impl NapkinServiceSyncHandler for FullHandler {
+ fn handle_napkin(&self) -> thrift::Result<Napkin> {
+ println!("full: handling napkin call");
+ Ok(napkin())
+ }
+}
+
+fn full_meal() -> FullMeal {
+ FullMeal::new(meal(), Dessert::Port("Graham's Tawny".to_owned()))
+}
+
+fn meal() -> Meal {
+ Meal::new(noodle(), ramen())
+}
+
+fn noodle() -> Noodle {
+ Noodle::new("spelt".to_owned(), 100)
+}
+
+fn ramen() -> Ramen {
+ Ramen::new("Mr Ramen".to_owned(), 72, BrothType::Miso)
+}
+
+fn napkin() -> Napkin {
+ Napkin {}
+}
+
+fn run_recursive_server<RTF, IPF, WTF, OPF>(
+ listen_address: &str,
+ r_transport_factory: RTF,
+ i_protocol_factory: IPF,
+ w_transport_factory: WTF,
+ o_protocol_factory: OPF,
+) -> thrift::Result<()>
+where
+ RTF: TReadTransportFactory + 'static,
+ IPF: TInputProtocolFactory + 'static,
+ WTF: TWriteTransportFactory + 'static,
+ OPF: TOutputProtocolFactory + 'static,
+{
+ let processor = recursive::TestServiceSyncProcessor::new(RecursiveTestServerHandler {});
+ let mut server = TServer::new(
+ r_transport_factory,
+ i_protocol_factory,
+ w_transport_factory,
+ o_protocol_factory,
+ processor,
+ 1,
+ );
+
+ server.listen(listen_address)
+}
+
+struct RecursiveTestServerHandler;
+impl recursive::TestServiceSyncHandler for RecursiveTestServerHandler {
+ fn handle_echo_tree(&self, tree: recursive::RecTree) -> thrift::Result<recursive::RecTree> {
+ println!("{:?}", tree);
+ Ok(tree)
+ }
+
+ fn handle_echo_list(&self, lst: recursive::RecList) -> thrift::Result<recursive::RecList> {
+ println!("{:?}", lst);
+ Ok(lst)
+ }
+
+ fn handle_echo_co_rec(&self, item: recursive::CoRec) -> thrift::Result<recursive::CoRec> {
+ println!("{:?}", item);
+ Ok(item)
+ }
+}
diff --git a/src/jaegertracing/thrift/lib/rs/test/src/lib.rs b/src/jaegertracing/thrift/lib/rs/test/src/lib.rs
new file mode 100644
index 000000000..9debdca54
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/src/lib.rs
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+extern crate thrift;
+
+pub mod base_one;
+pub mod base_two;
+pub mod midlayer;
+pub mod ultimate;
+pub mod recursive;
+
+#[cfg(test)]
+mod tests {
+
+ use std::default::Default;
+
+ use super::*;
+
+ #[test]
+ fn must_be_able_to_use_constructor() {
+ let _ = midlayer::Meal::new(Some(base_one::Noodle::default()), None);
+ }
+
+ #[test]
+ fn must_be_able_to_use_constructor_with_no_fields() {
+ let _ = midlayer::Meal::new(None, None);
+ }
+
+ #[test]
+ fn must_be_able_to_use_constructor_without_option_wrap() {
+ let _ = midlayer::Meal::new(base_one::Noodle::default(), None);
+ }
+
+ #[test]
+ fn must_be_able_to_use_defaults() {
+ let _ = midlayer::Meal {
+ noodle: Some(base_one::Noodle::default()),
+ ..Default::default()
+ };
+ }
+}
diff --git a/src/jaegertracing/thrift/lib/rs/test/thrifts/Base_One.thrift b/src/jaegertracing/thrift/lib/rs/test/thrifts/Base_One.thrift
new file mode 100644
index 000000000..c5fa6c20d
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/thrifts/Base_One.thrift
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+typedef i64 Temperature
+
+typedef i8 Size
+
+typedef string Location
+
+const i32 BoilingPoint = 100
+
+const list<Temperature> Temperatures = [10, 11, 22, 33]
+
+// IMPORTANT: temps should end with ".0" because this tests
+// that we don't have a problem with const float list generation
+const list<double> CommonTemperatures = [300.0, 450.0]
+
+const double MealsPerDay = 2.5;
+
+const string DefaultRecipeName = "Soup-rise of the Day"
+const binary DefaultRecipeBinary = "Soup-rise of the 01010101"
+
+struct Noodle {
+ 1: string flourType
+ 2: Temperature cookTemp
+}
+
+struct Spaghetti {
+ 1: optional list<Noodle> noodles
+}
+
+const Noodle SpeltNoodle = { "flourType": "spelt", "cookTemp": 110 }
+
+struct MeasuringSpoon {
+ 1: Size size
+}
+
+struct MeasuringCup {
+ 1: double millis
+}
+
+union MeasuringAids {
+ 1: MeasuringSpoon spoon
+ 2: MeasuringCup cup
+}
+
+struct CookingTemperatures {
+ 1: set<double> commonTemperatures
+ 2: list<double> usedTemperatures
+ 3: map<double, double> fahrenheitToCentigradeConversions
+}
+
+struct Recipe {
+ 1: string recipeName
+ 2: string cuisine
+ 3: i8 page
+}
+
+union CookingTools {
+ 1: set<MeasuringSpoon> measuringSpoons
+ 2: map<Size, Location> measuringCups,
+ 3: list<Recipe> recipes
+}
+
diff --git a/src/jaegertracing/thrift/lib/rs/test/thrifts/Base_Two.thrift b/src/jaegertracing/thrift/lib/rs/test/thrifts/Base_Two.thrift
new file mode 100644
index 000000000..caa6acb86
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/thrifts/Base_Two.thrift
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+const i32 WaterWeight = 200
+
+enum brothType {
+ Miso,
+ shouyu,
+}
+
+struct Ramen {
+ 1: optional string ramenType
+ 2: required i32 noodleCount
+ 3: brothType broth
+}
+
+struct Napkin {
+ // empty
+}
+
+service NapkinService {
+ Napkin napkin()
+}
+
+service RamenService extends NapkinService {
+ Ramen ramen(1: i32 requestedNoodleCount)
+}
+
+/* const struct CookedRamen = { "bar": 10 } */
+
diff --git a/src/jaegertracing/thrift/lib/rs/test/thrifts/Midlayer.thrift b/src/jaegertracing/thrift/lib/rs/test/thrifts/Midlayer.thrift
new file mode 100644
index 000000000..16ff49b0e
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/thrifts/Midlayer.thrift
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+include "Base_One.thrift"
+include "Base_Two.thrift"
+
+const i32 WaterBoilingPoint = Base_One.BoilingPoint
+
+const map<string, Base_One.Temperature> TemperatureNames = { "freezing": 0, "boiling": 100 }
+
+const map<set<i32>, map<list<string>, string>> MyConstNestedMap = {
+ [0, 1, 2, 3]: { ["foo"]: "bar" },
+ [20]: { ["nut", "ton"] : "bar" },
+ [30, 40]: { ["bouncy", "tinkly"]: "castle" }
+}
+
+const list<list<i32>> MyConstNestedList = [
+ [0, 1, 2],
+ [3, 4, 5],
+ [6, 7, 8]
+]
+
+const set<set<i32>> MyConstNestedSet = [
+ [0, 1, 2],
+ [3, 4, 5],
+ [6, 7, 8]
+]
+
+enum Pie {
+ PUMPKIN,
+ apple, // intentionally poorly cased
+ STRAWBERRY_RHUBARB,
+ Key_Lime, // intentionally poorly cased
+ coconut_Cream, // intentionally poorly cased
+ mississippi_mud, // intentionally poorly cased
+}
+
+struct Meal {
+ 1: Base_One.Noodle noodle
+ 2: Base_Two.Ramen ramen
+}
+
+union Dessert {
+ 1: string port
+ 2: string iceWine
+}
+
+service MealService extends Base_Two.RamenService {
+ Meal meal()
+}
+
diff --git a/src/jaegertracing/thrift/lib/rs/test/thrifts/Ultimate.thrift b/src/jaegertracing/thrift/lib/rs/test/thrifts/Ultimate.thrift
new file mode 100644
index 000000000..72fa100a6
--- /dev/null
+++ b/src/jaegertracing/thrift/lib/rs/test/thrifts/Ultimate.thrift
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * Contains some contributions under the Thrift Software License.
+ * Please see doc/old-thrift-license.txt in the Thrift distribution for
+ * details.
+ */
+
+include "Midlayer.thrift"
+
+enum Drink {
+ WATER,
+ WHISKEY,
+ WINE,
+ scotch, // intentionally poorly cased
+ LATE_HARVEST_WINE,
+ India_Pale_Ale, // intentionally poorly cased
+ apple_cider, // intentially poorly cased
+ belgian_Ale, // intentionally poorly cased
+ Canadian_whisky, // intentionally poorly cased
+}
+
+const map<i8, Midlayer.Pie> RankedPies = {
+ 1: Midlayer.Pie.PUMPKIN,
+ 2: Midlayer.Pie.STRAWBERRY_RHUBARB,
+ 3: Midlayer.Pie.apple,
+ 4: Midlayer.Pie.mississippi_mud,
+ 5: Midlayer.Pie.coconut_Cream,
+ 6: Midlayer.Pie.Key_Lime,
+}
+
+struct FullMeal {
+ 1: required Midlayer.Meal meal
+ 2: required Midlayer.Dessert dessert
+}
+
+struct FullMealAndDrinks {
+ 1: required FullMeal fullMeal
+ 2: optional Drink drink
+}
+
+service FullMealService extends Midlayer.MealService {
+ FullMeal fullMeal()
+}
+
+service FullMealAndDrinksService extends FullMealService {
+ FullMealAndDrinks fullMealAndDrinks()
+
+ Midlayer.Pie bestPie()
+}
+