-
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
Implement Queues Consumer handler #53
Comments
Please 🙏 |
I'll try to implement this in next few weeks. |
Thanks in advance. By the way, would you mind sharing the concrete steps that will be involved in doing the implementation? I'm curious to know how things work under the hood, who knows, I might even be able to contribute? |
It will be like the following steps.
PRs are welcome! |
I've started working on this (#125) since the I need the Queues support in my worker. Though there's a problem that I'd like to discuss as my experience with workers and js in general is not that great. In general, producer's side of API is clear and mostly works as expected. One important feature of producer's api is an option to specify the content type of each message produced. This is handled in my PR. The questions I have are concerning the consumer's API. Any advices on how to achieve this? |
Thank you @meandnano!
I think we should provide a way to access to the raw value of the message. Almost all the API can be the same as the Queue Consumer API (MessageBatch type, Message type ... etc). I think we need to introduce a type for
Then, import jsencoding "github.com/syumai/go-jsutil/encoding"
type QueueMsg struct {
Type string
Value int
}
func Consume(batch queues.MessageBatch) {
for _, msg := range batch.Messages {
var queueMsg QueueMsg
err := jsencoding.UnmarshalJSONValue(msg.Raw(), &queueMsg)
if err != nil { /* handling error */ }
// Now, queueMsg is available
}
}
I don't think functions like I hope this answer helps you with your implementation. |
Thanks for the input @syumai. My current implementation of consumer API does exactly that - exposes the raw type ConsumerMessage struct {
// instance - The underlying instance of the JS message object passed by the cloudflare
instance js.Value
Id string
Timestamp time.Time
Body js.Value
Attempts int
} IMO we don't need Essentially, I have it all working locally and now am only focused on the tests. Will push updates soon enough |
The text was updated successfully, but these errors were encountered: