-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add message producer #125
Add message producer #125
Conversation
e1665cb
to
ee70c46
Compare
b6a306e
to
ae2bcf1
Compare
I'll check this later, thanks! |
Just wanted to mention it: since queues require paid plan, it might be uncomfortable to test this remotely. But I now use this implementation of queues api in my worked on a paid plan it works as expected. I'll create consumer api PR once this one is merged. |
// | ||
// - https://developers.cloudflare.com/queues/configuration/javascript-apis/#producer | ||
// - https://developers.cloudflare.com/queues/configuration/javascript-apis/#queuesendoptions | ||
func (p *Producer) Send(content any, opts ...SendOption) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Go, Send
method with any
content type doesn't seem useful enough.
I think ContentType
send option should be removed and separated Send
methods should be declared.
e.g.
func (p *Producer) SendText(content string, opts ...SendOption) error {}
func (p *Producer) SendBytes(content []byte, opts ...SendOption) error {}
func (p *Producer) SendJSON(content any, opts ...SendOption) error {}
func (p *Producer) SendV8(content js.Value, opts ...SendOption) error {}
I'll separate current implementation after.
} | ||
|
||
// SendBatch sends multiple messages to a queue. This function allows setting options for each message. | ||
func (p *Producer) SendBatch(messages []*BatchMessage, opts ...BatchSendOption) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think BatchMessage
should not just be a struct with any
values, but a common type or interface constructed in the following form:
func NewTextBatchMessage(content string, opts ...SendOption) BatchMessage
func NewBytesBatchMessage(content []byte, opts ...SendOption) BatchMessage
func NewJSONBatchMessage(content any, opts ...SendOption) BatchMessage
func NewV8BatchMessage(content js.Value, opts ...SendOption) BatchMessage
I'll try to change the current implementation after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do some changes after merging this.
Thank you for great implementation!
@meandnano This feature has been released as v0.27.0, thanks! |
What
This PR implements the producer side of the Cloudflare Queues feature.
Motivation
#53