rocketmq_client_rust/
lib.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 */
17#![allow(dead_code)]
18#![allow(unused_variables)]
19#![allow(clippy::result_large_err)]
20#![recursion_limit = "256"]
21
22extern crate core;
23
24// Define macros at crate root so they're available throughout the crate
25/// Create a client error with optional response code
26#[macro_export]
27macro_rules! mq_client_err {
28    // Handle errors with a custom ResponseCode and formatted string
29    ($response_code:expr, $fmt:expr, $($arg:expr),*) => {{
30        let formatted_msg = format!($fmt, $($arg),*);
31        let error_message = format!("CODE: {}  DESC: {}", $response_code as i32, formatted_msg);
32        let faq_msg = rocketmq_common::common::FAQUrl::attach_default_url(Some(error_message.as_str()));
33        rocketmq_error::RocketMQError::illegal_argument(faq_msg)
34    }};
35
36    ($response_code:expr, $error_message:expr) => {{
37        let error_message = format!("CODE: {}  DESC: {}", $response_code as i32, $error_message);
38        let faq_msg = rocketmq_common::common::FAQUrl::attach_default_url(Some(error_message.as_str()));
39        rocketmq_error::RocketMQError::illegal_argument(faq_msg)
40    }};
41
42    // Handle errors without a ResponseCode, using only the error message (accepts both &str and String)
43    ($error_message:expr) => {{
44        let error_msg: &str = "Body is empty";
45        let faq_msg = rocketmq_common::common::FAQUrl::attach_default_url(Some(error_msg));
46        rocketmq_error::RocketMQError::illegal_argument(faq_msg)
47    }};
48}
49
50/// Create a broker operation error
51#[macro_export]
52macro_rules! client_broker_err {
53    // Handle errors with a custom ResponseCode and formatted string
54    ($response_code:expr, $error_message:expr, $broker_addr:expr) => {{
55        rocketmq_error::RocketMQError::broker_operation_failed(
56            "BROKER_OPERATION",
57            $response_code as i32,
58            $error_message,
59        )
60        .with_broker_addr($broker_addr)
61    }};
62    // Handle errors without a ResponseCode, using only the error message
63    ($response_code:expr, $error_message:expr) => {{
64        rocketmq_error::RocketMQError::broker_operation_failed(
65            "BROKER_OPERATION",
66            $response_code as i32,
67            $error_message,
68        )
69    }};
70}
71
72// Define client_error module
73pub mod client_error;
74
75pub mod admin;
76pub mod base;
77pub mod common;
78pub mod consumer;
79pub mod factory;
80mod hook;
81pub mod implementation;
82mod latency;
83pub mod producer;
84mod trace;
85pub mod utils;
86
87pub use crate::consumer::consumer_impl::pull_request_ext::PullResultExt;