-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support HTTP Request and Cron Trigger in Single Worker #127
Comments
Yeah, this should not be a cloudflare restriction. In fact, in my implementation of Queues consumer I've introduced 2 versions of the |
Yes, it is not a Cloudflare restriction. The non-blocking API proposed by @meandnano looks fine to me. |
I added multiple handlers example here: workers/_examples/multiple-handlers/main.go Lines 26 to 37 in 605532b
detail: #132 |
@ben-krieger @meandnano This feature has been released as v0.27.0, thanks! |
Currently
cron.ScheduleTask
andworkers.Serve
cannot both be used within the samefunc main
, because they both callready
, causing a race condition.Also,
cron.ScheduleTask
blocks indefinitely andworkers.Serve
blocks until the request is closed, so there needs to be a way to know the trigger type in order to decide if/when to exit main.I don't think there's a Cloudflare restriction that a Worker can only be a Cron Trigger or HTTP Request handler, but I'm new to the Workers platform, so correct me if I'm wrong.
Obviously the workaround to this issue is to create two Workers, but the problem I'm solving for is keeping "Getting Started"-type documentation concise and being able give an example with a single
main.go
andwrangler.toml
is highly beneficial.The text was updated successfully, but these errors were encountered: