basepath=$(cd `dirname $0`; pwd) cd $basepath cd .. proto-gen -s -c --generate-transport generate -d $(dirname $PWD)/base/src/grpcprotos -d $PWD/src/grpcprotos $( find src/grpcprotos/services -name "*.proto"|xargs -I {} echo " -f $PWD/{} "|xargs) -o $(dirname $PWD)/base/src/pbs/ name=$( pwd|awk -F "/" '{print $NF}'|tr '-' '_') touch ../base/src/u/${name}.rs grep "pub mod ${name};" ../base/src/u/mod.rs || echo "pub mod ${name};" >>../base/src/u/mod.rs for item in $(ls src/grpcprotos/services|sed 's/Business.proto//g'|xargs) do prefix=$name newstr=$(echo ${prefix:0:1}|tr '[a-z]' '[A-Z]')$(echo ${prefix:1}) [[ "$newstr" == "K8s" ]] && newstr="K8S" action=${item}Action business=${item}Business pname=$(echo ${item}|sed -E 's/([A-Z])/_\1/g' | sed -E 's/^_//g' | tr 'A-Z' 'a-z'| tr '-' '_') grep ${business} ../base/src/u/${name}.rs || echo "pub async fn ${pname}(addr:&'static str, message: crate::pbs::${name}::${action}) -> Result {\n usc::mylog!(\"GRPC_REQUEST_TO {:?},{:?}\", std::stringify!(addr),format!(\"{}\",addr).as_str());\n let client_result= crate::pbs::${name}::${pname}_business_service_client::${business}ServiceClient::connect(addr).await;\n let mut client=match client_result {\n Ok(a)=>a,\n Err(e)=>return Err(usc::myerror::MyError::new(e.to_string()))\n };\n let request = tonic::Request::new(message);\n let response_result = client.flow(request).await;\n let response=match response_result{\n Ok(a)=>a,\n Err(e)=>return Err(usc::myerror::MyError::new_str(e.message()))\n };\n let result=response.into_inner();\n usc::mylog!(\"GRPC_RESPONSE_FROM {:?}:{}\", std::stringify!(addr), result.result);\n Ok(result)\n}\n" >>../base/src/u/${name}.rs done cd ../base bash bgitpush.sh cd -