rocketmq_common/common/
faq.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
18pub struct FAQUrl;
19
20impl FAQUrl {
21    pub const APPLY_TOPIC_URL: &'static str = "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
22    pub const CLIENT_PARAMETER_CHECK_URL: &'static str =
23        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
24    pub const CLIENT_SERVICE_NOT_OK: &'static str =
25        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
26    pub const GROUP_NAME_DUPLICATE_URL: &'static str =
27        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
28    pub const LOAD_JSON_EXCEPTION: &'static str =
29        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
30    const MORE_INFORMATION: &'static str = "For more information, please visit the url, ";
31    pub const MQLIST_NOT_EXIST: &'static str =
32        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
33    pub const NAME_SERVER_ADDR_NOT_EXIST_URL: &'static str =
34        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
35    // FAQ: No route info of this topic, TopicABC
36    pub const NO_TOPIC_ROUTE_INFO: &'static str =
37        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
38    pub const SAME_GROUP_DIFFERENT_TOPIC: &'static str =
39        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
40    pub const SEND_MSG_FAILED: &'static str = "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
41    pub const SUBSCRIPTION_GROUP_NOT_EXIST: &'static str =
42        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
43    const TIP_STRING_BEGIN: &'static str = "\nSee ";
44    const TIP_STRING_END: &'static str = " for further details.";
45    pub const UNEXPECTED_EXCEPTION_URL: &'static str =
46        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
47    pub const UNKNOWN_HOST_EXCEPTION: &'static str =
48        "https://rocketmq.apache.org/docs/bestPractice/06FAQ";
49
50    pub fn suggest_todo(url: &'static str) -> String {
51        format!("{}{}{}", Self::TIP_STRING_BEGIN, url, Self::TIP_STRING_END)
52    }
53
54    pub fn attach_default_url(error_message: Option<&str>) -> String {
55        if let Some(err_msg) = error_message {
56            if !err_msg.contains(Self::TIP_STRING_BEGIN) {
57                return format!(
58                    "{}\n{}{}",
59                    err_msg,
60                    Self::MORE_INFORMATION,
61                    Self::UNEXPECTED_EXCEPTION_URL
62                );
63            }
64        }
65        error_message.unwrap_or_default().to_string()
66    }
67}