rocketmq_remoting/base/response_future.rs
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17use std::hash::Hash;
18use std::hash::Hasher;
19
20use crate::protocol::remoting_command::RemotingCommand;
21
22pub struct ResponseFuture {
23 pub(crate) opaque: i32,
24 pub(crate) timeout_millis: u64,
25 pub(crate) send_request_ok: bool,
26 //pub(crate) response_command: Option<RemotingCommand>,
27 pub(crate) tx: tokio::sync::oneshot::Sender<rocketmq_error::RocketMQResult<RemotingCommand>>,
28}
29
30impl PartialEq for ResponseFuture {
31 fn eq(&self, other: &Self) -> bool {
32 self.opaque == other.opaque
33 && self.timeout_millis == other.timeout_millis
34 && self.send_request_ok == other.send_request_ok
35 }
36}
37
38impl Eq for ResponseFuture {}
39
40impl Hash for ResponseFuture {
41 fn hash<H: Hasher>(&self, state: &mut H) {
42 self.opaque.hash(state);
43 self.timeout_millis.hash(state);
44 self.send_request_ok.hash(state);
45 }
46}
47
48impl ResponseFuture {
49 pub fn new(
50 opaque: i32,
51 timeout_millis: u64,
52 send_request_ok: bool,
53 //response_command: Option<RemotingCommand>,
54 tx: tokio::sync::oneshot::Sender<rocketmq_error::RocketMQResult<RemotingCommand>>,
55 ) -> Self {
56 Self {
57 opaque,
58 timeout_millis,
59 send_request_ok,
60 // response_command,
61 tx,
62 }
63 }
64}