-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
801 additions
and
4 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
/* | ||
* Copyright 1999-2020 Alibaba Group Holding Ltd. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
|
||
|
||
option java_multiple_files = true; | ||
option java_package = "com.alibaba.nacos.api.grpc.auto"; | ||
|
||
//package _; | ||
|
||
message Any { | ||
string type_url = 1; | ||
bytes value = 2; | ||
} | ||
|
||
message Metadata { | ||
string type = 3; | ||
string clientIp = 8; | ||
map<string, string> headers = 7; | ||
} | ||
|
||
|
||
message Payload { | ||
Metadata metadata = 2; | ||
Any body = 3; | ||
} | ||
|
||
service RequestStream { | ||
// build a streamRequest | ||
rpc requestStream (Payload) returns (stream Payload) { | ||
} | ||
} | ||
|
||
service Request { | ||
// Sends a commonRequest | ||
rpc request (Payload) returns (Payload) { | ||
} | ||
} | ||
|
||
service BiRequestStream { | ||
// Sends a commonRequest | ||
rpc requestBiStream (stream Payload) returns (stream Payload) { | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
pub mod nacos_proto; | ||
pub mod server; | ||
|
||
pub fn build_payload(val:&str) -> nacos_proto::Payload { | ||
let body = nacos_proto::Any { | ||
type_url:"".into(), | ||
value:val.as_bytes().to_vec(), | ||
}; | ||
nacos_proto::Payload{ | ||
body:Some(body), | ||
metadata:Default::default(), | ||
} | ||
} | ||
|
||
pub fn get_payload_string(value:&nacos_proto::Payload) -> String { | ||
let mut str = String::default(); | ||
if let Some(meta) = &value.metadata { | ||
str.push_str(&format!("type:{},\n\t",meta.r#type)); | ||
str.push_str(&format!("client_ip:{},\n\t",meta.client_ip)); | ||
str.push_str(&format!("header:{:?},\n\t",meta.headers)); | ||
} | ||
if let Some(body) = &value.body { | ||
let new_value = body.clone(); | ||
let value_str = String::from_utf8(new_value.value).unwrap(); | ||
str.push_str(&format!("body:{}",value_str)); | ||
} | ||
str | ||
} |
Oops, something went wrong.