rocketmq_rust/
schedule.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 */
17pub mod executor;
18pub mod scheduler;
19pub mod task;
20pub mod trigger;
21
22use std::error::Error;
23use std::fmt;
24
25pub use executor::ExecutorPool;
26pub use task::Task;
27pub use task::TaskContext;
28pub use task::TaskResult;
29pub use task::TaskStatus;
30
31/// Scheduler error type
32#[derive(Debug)]
33pub enum SchedulerError {
34    TaskNotFound(String),
35    TaskAlreadyExists(String),
36    ExecutorError(String),
37    TriggerError(String),
38    SystemError(String),
39}
40
41impl fmt::Display for SchedulerError {
42    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43        match self {
44            SchedulerError::TaskNotFound(id) => write!(f, "Task not found: {id}"),
45            SchedulerError::TaskAlreadyExists(id) => write!(f, "Task already exists: {id}"),
46            SchedulerError::ExecutorError(msg) => write!(f, "Executor error: {msg}"),
47            SchedulerError::TriggerError(msg) => write!(f, "Trigger error: {msg}"),
48            SchedulerError::SystemError(msg) => write!(f, "System error: {msg}"),
49        }
50    }
51}
52
53impl Error for SchedulerError {}
54
55pub type SchedulerResult<T> = Result<T, SchedulerError>;