rocketmq_remoting/rpc/rpc_request_header.rs
1// Copyright 2023 The RocketMQ Rust Authors
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 cheetah_string::CheetahString;
16use rocketmq_macros::RequestHeaderCodecV2;
17use serde::Deserialize;
18use serde::Serialize;
19
20#[derive(Clone, Debug, Serialize, Deserialize, Default, RequestHeaderCodecV2)]
21pub struct RpcRequestHeader {
22 // the namespace name
23 #[serde(rename = "namespace")]
24 pub namespace: Option<CheetahString>,
25 // if the data has been namespaced
26 #[serde(rename = "namespaced")]
27 pub namespaced: Option<bool>,
28 // the abstract remote addr name, usually the physical broker name
29 #[serde(rename = "brokerName")]
30 pub broker_name: Option<CheetahString>,
31 // oneway
32 #[serde(rename = "oneway")]
33 pub oneway: Option<bool>,
34}
35
36impl RpcRequestHeader {
37 pub fn new(
38 namespace: Option<CheetahString>,
39 namespaced: Option<bool>,
40 broker_name: Option<CheetahString>,
41 oneway: Option<bool>,
42 ) -> Self {
43 Self {
44 namespace,
45 namespaced,
46 broker_name,
47 oneway,
48 }
49 }
50}