|
| 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 | + */ |
| 17 | +use rocketmq_common::common::message::{ |
| 18 | + message_batch::MessageExtBatch, message_single::MessageExtBrokerInner, |
| 19 | +}; |
| 20 | + |
| 21 | +use crate::base::{message_result::AppendMessageResult, put_message_context::PutMessageContext}; |
| 22 | + |
| 23 | +/// Write messages callback interface |
| 24 | +pub trait AppendMessageCallback { |
| 25 | + /// After message serialization, write MappedByteBuffer |
| 26 | + /// |
| 27 | + /// # Arguments |
| 28 | + /// |
| 29 | + /// * `file_from_offset` - The offset of the file |
| 30 | + /// * `byte_buffer` - The buffer to write |
| 31 | + /// * `max_blank` - The maximum blank space |
| 32 | + /// * `msg` - The message to write |
| 33 | + /// * `put_message_context` - The context of putting message |
| 34 | + /// |
| 35 | + /// # Returns |
| 36 | + /// |
| 37 | + /// The number of bytes written |
| 38 | + fn do_append( |
| 39 | + &self, |
| 40 | + file_from_offset: i64, |
| 41 | + byte_buffer: &mut [u8], |
| 42 | + max_blank: i32, |
| 43 | + msg: &MessageExtBrokerInner, |
| 44 | + put_message_context: &PutMessageContext, |
| 45 | + ) -> AppendMessageResult; |
| 46 | + |
| 47 | + /// After batched message serialization, write MappedByteBuffer |
| 48 | + /// |
| 49 | + /// # Arguments |
| 50 | + /// |
| 51 | + /// * `file_from_offset` - The offset of the file |
| 52 | + /// * `byte_buffer` - The buffer to write |
| 53 | + /// * `max_blank` - The maximum blank space |
| 54 | + /// * `message_ext_batch` - The batched message to write |
| 55 | + /// * `put_message_context` - The context of putting message |
| 56 | + /// |
| 57 | + /// # Returns |
| 58 | + /// |
| 59 | + /// The number of bytes written |
| 60 | + fn do_append_batch( |
| 61 | + &self, |
| 62 | + file_from_offset: i64, |
| 63 | + byte_buffer: &mut [u8], |
| 64 | + max_blank: i32, |
| 65 | + message_ext_batch: &MessageExtBatch, |
| 66 | + put_message_context: &PutMessageContext, |
| 67 | + ) -> AppendMessageResult; |
| 68 | +} |
0 commit comments