Skip to content
/ onestep Public

Easily implement distributed asynchronous tasks in one step.仅需一步,轻松实现分布式异步任务。

Notifications You must be signed in to change notification settings

mic1on/onestep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


仅需一步,轻松实现分布式异步任务。

Brokers

  • MemoryBroker
  • CronBroker
  • WebHookBroker
  • RabbitMQBroker
  • RedisBroker
    • RedisStreamBroker
    • RedisPubSubBroker
  • KafkaBroker

😋example

# example.py

from onestep import step, WebHookBroker


# 对外提供一个webhook接口,接收外部的消息
@step(from_broker=WebHookBroker(path="/push"))
def waiting_messages(message):
    print("收到消息:", message)


if __name__ == '__main__':
    step.start(block=True)

also, you can use onestep command to start, like this:

$ onestep example

then, you can send a message to webhook:

$ curl -X POST -H "Content-Type: application/json" -d '{"a": 1}' http://localhost:8090/push

🤩 other brokers

from onestep import step, CronBroker


# 每3秒触发一次任务
@step(from_broker=CronBroker("* * * * * */3", body={"a": 1}))
def cron_task(message):
    assert message.body == {"a": 1}
    return message


if __name__ == '__main__':
    step.start(block=True)

🤔more examples: examples

About

Easily implement distributed asynchronous tasks in one step.仅需一步,轻松实现分布式异步任务。

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •