Upgrading vendor folder dependencies.

This commit is contained in:
Renan DelValle 2018-12-27 09:58:53 -08:00
parent 4a0cbcd770
commit acbe9ad9e5
No known key found for this signature in database
GPG key ID: C240AD6D6F443EC9
229 changed files with 10735 additions and 4528 deletions

View file

@ -28,10 +28,13 @@ 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::transport::{ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel,
TTcpChannel, WriteHalf};
use thrift::protocol::{TBinaryInputProtocol, TBinaryOutputProtocol, TCompactInputProtocol,
TCompactOutputProtocol, TInputProtocol, TOutputProtocol};
use thrift::protocol::{
TBinaryInputProtocol, TBinaryOutputProtocol, TCompactInputProtocol, TCompactOutputProtocol,
TInputProtocol, TOutputProtocol,
};
use thrift::transport::{
ReadHalf, TFramedReadTransport, TFramedWriteTransport, TIoChannel, TTcpChannel, WriteHalf,
};
fn main() {
match run() {
@ -61,17 +64,20 @@ fn run() -> thrift::Result<()> {
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_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)))
}
"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()),
};
@ -87,7 +93,10 @@ fn run_client(
"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)),),
_ => Err(thrift::Error::from(format!(
"unknown service type {}",
service
))),
}
}
@ -110,12 +119,9 @@ fn exec_meal_client(
// 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(|_| ())?;
execute_call("part", "ramen", || client.ramen(50)).map(|_| ())?;
execute_call("part", "meal", || client.meal()).map(|_| ())?;
execute_call("part", "napkin", || client.napkin()).map(|_| ())?;
Ok(())
}
@ -126,14 +132,10 @@ fn exec_full_meal_client(
) -> 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(|_| ())?;
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(())
}
@ -145,114 +147,75 @@ fn exec_recursive_client(
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),
},
),
],
),
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),
},
),
],
),
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(),
);
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),
},
),
),
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(),);
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 })) }),
},
),
),
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()),
)?;
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(),);
return Err(format!("mismatched co_rec {:?} {:?}", co_rec, returned_co_rec).into());
}
Ok(())
@ -266,14 +229,10 @@ where
match res {
Ok(_) => println!("{}: completed {} call", service_type, call_name),
Err(ref e) => {
println!(
"{}: failed {} call with error {:?}",
service_type,
call_name,
e
)
}
Err(ref e) => println!(
"{}: failed {} call with error {:?}",
service_type, call_name, e
),
}
res

View file

@ -17,23 +17,32 @@
#[macro_use]
extern crate clap;
extern crate kitchen_sink;
extern crate thrift;
use kitchen_sink::base_one::Noodle;
use kitchen_sink::base_two::{Napkin, NapkinServiceSyncHandler, Ramen, RamenServiceSyncHandler};
use kitchen_sink::midlayer::{Dessert, Meal, MealServiceSyncHandler, MealServiceSyncProcessor};
use kitchen_sink::recursive;
use kitchen_sink::ultimate::{Drink, FullMeal, FullMealAndDrinks,
FullMealAndDrinksServiceSyncProcessor, FullMealServiceSyncHandler};
use kitchen_sink::ultimate::FullMealAndDrinksServiceSyncHandler;
use thrift::protocol::{TBinaryInputProtocolFactory, TBinaryOutputProtocolFactory,
TCompactInputProtocolFactory, TCompactOutputProtocolFactory,
TInputProtocolFactory, TOutputProtocolFactory};
use thrift::transport::{TFramedReadTransportFactory, TFramedWriteTransportFactory,
TReadTransportFactory, TWriteTransportFactory};
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() {
@ -46,7 +55,6 @@ fn main() {
}
fn run() -> thrift::Result<()> {
let matches = clap_app!(rust_kitchen_sink_server =>
(version: "0.1.0")
(author: "Apache Thrift Developers <dev@thrift.apache.org>")
@ -67,21 +75,22 @@ fn run() -> thrift::Result<()> {
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());
}
};
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?
//
@ -94,33 +103,27 @@ fn run() -> thrift::Result<()> {
//
// 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,
)
}
"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()),
}
}
@ -207,7 +210,13 @@ struct FullHandler;
impl FullMealAndDrinksServiceSyncHandler for FullHandler {
fn handle_full_meal_and_drinks(&self) -> thrift::Result<FullMealAndDrinks> {
Ok(FullMealAndDrinks::new(full_meal(), Drink::WHISKEY))
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
}
}
@ -252,7 +261,7 @@ fn noodle() -> Noodle {
}
fn ramen() -> Ramen {
Ramen::new("Mr Ramen".to_owned(), 72)
Ramen::new("Mr Ramen".to_owned(), 72, BrothType::Miso)
}
fn napkin() -> Napkin {

View file

@ -37,6 +37,9 @@ 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

View file

@ -23,9 +23,15 @@
const i32 WaterWeight = 200
enum brothType {
Miso,
shouyu,
}
struct Ramen {
1: optional string ramenType
2: required i32 noodleCount
3: brothType broth
}
struct Napkin {

View file

@ -46,6 +46,15 @@ const set<set<i32>> MyConstNestedSet = [
[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

View file

@ -27,6 +27,21 @@ 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 {
@ -45,5 +60,7 @@ service FullMealService extends Midlayer.MealService {
service FullMealAndDrinksService extends FullMealService {
FullMealAndDrinks fullMealAndDrinks()
Midlayer.Pie bestPie()
}