Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat cli #26

Merged
merged 2 commits into from
Nov 25, 2023
Merged

Feat cli #26

merged 2 commits into from
Nov 25, 2023

Conversation

mic1on
Copy link
Owner

@mic1on mic1on commented Nov 25, 2023

# example.py

from onestep import step, WebHookBroker


@step(from_broker=WebHookBroker(path="/push"))
def waiting_messages(message):
    print("message:", message)

you can use onestep command to start

$ onestep example

log output:

[2023-11-25 22:08:03,719] [onestep] [INFO] OneStep 0.3.5 is start up.
[2023-11-25 22:08:03,720] [onestep.onestep] [DEBUG] start group [all]
[2023-11-25 22:08:03,720] [onestep.onestep] [DEBUG] started: consumer=<ThreadWorker waiting_messages>
[2023-11-25 22:08:03,926] [onestep.broker.webhook] [DEBUG] WebHookBroker: 0.0.0.0:8090/push

then, you can send a message to webhook:

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

and we will receive message:

message: {'body': {'a': 1}, 'extra': {'task_id': 'd7d10d60-33e9-4be7-ad41-fdee8401ce33', 'publish_time': 1700921346.82, 'failure_count': 0}}

@mic1on mic1on merged commit 5942f00 into main Nov 25, 2023
8 checks passed
@mic1on mic1on deleted the feat_cli branch November 25, 2023 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant