我想在我的 rails 应用程序中创建一个 cron 作业。
例如:
def job(message)
send_message_to_someother_service(message)
end
该作业将采用输入参数并针对 cron 表达式运行。现在我将向我的 Rails 应用程序发送请求以添加更多 cron 表达式、输入参数对。(假设这些将存储在数据库中)
例如:
[
{cron: (0 0/1 * 1/1 * ? *), parameters: {message: "test1"}},
{cron: (0 0/5 * 1/1 * ? *), parameters: {message: "test2"}
]
我的工作应该为所有具有相应输入参数的 cron 表达式运行。
预期行为:其他服务只打印它收到的带有时间戳的消息
[12:00:00]: test1
[12:00:00]: test2
[12:01:00]: test1
[12:02:00]: test1
[12:03:00]: test1
[12:04:00]: test1
[12:05:00]: test1
[12:05:00]: test2
谁能帮我实现这个?