rocketmq_remoting/protocol/
topic.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 rocketmq_common::common::message::message_queue::MessageQueue;
18use serde::Deserialize;
19use serde::Serialize;
20
21#[derive(Serialize, Deserialize, Debug)]
22pub struct OffsetMovedEvent {
23    pub consumer_group: String,
24    pub message_queue: MessageQueue,
25    pub offset_request: i64,
26    pub offset_new: i64,
27}
28
29impl OffsetMovedEvent {
30    pub fn get_consumer_group(&self) -> &str {
31        &self.consumer_group
32    }
33
34    pub fn set_consumer_group(&mut self, consumer_group: String) {
35        self.consumer_group = consumer_group;
36    }
37
38    pub fn get_message_queue(&self) -> &MessageQueue {
39        &self.message_queue
40    }
41
42    pub fn set_message_queue(&mut self, message_queue: MessageQueue) {
43        self.message_queue = message_queue;
44    }
45
46    pub fn get_offset_request(&self) -> i64 {
47        self.offset_request
48    }
49
50    pub fn set_offset_request(&mut self, offset_request: i64) {
51        self.offset_request = offset_request;
52    }
53
54    pub fn get_offset_new(&self) -> i64 {
55        self.offset_new
56    }
57
58    pub fn set_offset_new(&mut self, offset_new: i64) {
59        self.offset_new = offset_new;
60    }
61}
62
63impl std::fmt::Display for OffsetMovedEvent {
64    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
65        write!(
66            f,
67            "OffsetMovedEvent [consumer_group={}, message_queue={:?}, offset_request={}, \
68             offset_new={}]",
69            self.consumer_group, self.message_queue, self.offset_request, self.offset_new
70        )
71    }
72}