cloud_util/network.rs
1// Copyright Rivtower Technologies LLC.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use cita_cloud_proto::client::{InterceptedSvc, NetworkClientTrait};
16use cita_cloud_proto::network::network_service_client::NetworkServiceClient;
17use cita_cloud_proto::network::RegisterInfo;
18use cita_cloud_proto::retry::RetryClient;
19use cita_cloud_proto::status_code::StatusCodeEnum;
20
21pub async fn register_network_msg_handler(
22 client: RetryClient<NetworkServiceClient<InterceptedSvc>>,
23 register_info: RegisterInfo,
24) -> StatusCodeEnum {
25 match client.register_network_msg_handler(register_info).await {
26 Ok(code) => StatusCodeEnum::from(code),
27 Err(status) => {
28 warn!("register_network_msg_handler error: {}", status.to_string());
29 StatusCodeEnum::NetworkServerNotReady
30 }
31 }
32}