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

Batch encoding support in bindings interfaces #301

Open
slinkydeveloper opened this issue Feb 4, 2020 · 4 comments
Open

Batch encoding support in bindings interfaces #301

slinkydeveloper opened this issue Feb 4, 2020 · 4 comments
Labels
component/binding enhancement New feature or request

Comments

@slinkydeveloper
Copy link
Member

No description provided.

@slinkydeveloper
Copy link
Member Author

After playing with the multipart experiment, i come out with MultiMessage.

MultiMessage is a Message iterator with a Finish(). I didn't included this interface in Message because it requires dropping the assumption everywhere in the sdk that 1 message corresponds to 1 event. MultiMessage is easily implementable, an example: https://github.com/slinkydeveloper/sdk-go/blob/multipart_experiment/v2/binding/multi_event_message.go

My proposal is that we should provide at bindings level this interface and in http protocol implement it for batch encoding. Then, we won't have any support for it at protocol level (and at client level) and we'll provide to users an example for using it (like https://github.com/slinkydeveloper/sdk-go/blob/multipart_experiment/v2/cmd/samples/http_multipart/random_multi_event_send/main.go).

My problem with this plan is http.NewMessage: What this function should do, if we open the doors to MultiMessage?

  • Should it return a void pointer that could be or a single Message or a MultiMessage?
  • We want to have another function called NewMultiMessage that returns always a MultiMessage and, in case of single structured/binary message, returns a one element MultiMessage?

@n3wscott
Copy link
Member

I think I agree with a new MultiMessage type, it can implement the message interface but to built it up is more involved, like maybe it consumes Messages? And then to use this we add a SendMulti(ctx, []events) or something.

So I can see this being implemented without an API breaking change on the surfaces we care about.

@acodetailor
Copy link

support batch event now ?

@Xopek
Copy link

Xopek commented May 19, 2021

Really looking forward to be able to send multiple events at once. Can i help somehow to implement it?

markmandel added a commit to markmandel/sdk-go that referenced this issue Dec 22, 2022
Simple implementations of NewEventsFromHTTPRequest and
NewEventsFromHTTPResponse as a step towards providing some support for
`application/cloudevents-batch+json`.

This doesn't help with batch sending of Events, but this provides some
basics of being able to process batch requests and/or responses
from standard Go HTTP handling.

This could be improved over time (See previous work on cloudevents#301) as well,
but optimised for having something that works to start, rather than
implementing big design changes.

Signed-off-by: Mark Mandel <markmandel@google.com>
markmandel added a commit to markmandel/sdk-go that referenced this issue Jan 6, 2023
Simple implementations of NewEventsFromHTTPRequest and
NewEventsFromHTTPResponse as a step towards providing some support for
`application/cloudevents-batch+json`.

This doesn't help with batch sending of Events, but this provides some
basics of being able to process batch requests and/or responses
from standard Go HTTP handling.

This could be improved over time (See previous work on cloudevents#301) as well,
but optimised for having something that works to start, rather than
implementing big design changes.

Signed-off-by: Mark Mandel <markmandel@google.com>
lionelvillard pushed a commit that referenced this issue Jan 26, 2023
* http: Batch Events from HTTP Request and Response

Simple implementations of NewEventsFromHTTPRequest and
NewEventsFromHTTPResponse as a step towards providing some support for
`application/cloudevents-batch+json`.

This doesn't help with batch sending of Events, but this provides some
basics of being able to process batch requests and/or responses
from standard Go HTTP handling.

This could be improved over time (See previous work on #301) as well,
but optimised for having something that works to start, rather than
implementing big design changes.

Signed-off-by: Mark Mandel <markmandel@google.com>

* Implement NewHTTPRequestFromEvents

Now you can send batch events with your very own http.Client.

Signed-off-by: Mark Mandel <markmandel@google.com>

* Review updates

* Expanded test for NewEventsFromHTTPRequest
* Implemented NewHTTPRequestFromEvent as well

Signed-off-by: Mark Mandel <markmandel@google.com>

* Add IsHTTPBatch

IsHTTPBatch is a convenience function such that an end user could
determine if a request or response is batch or not, and process it as
such.

Signed-off-by: Mark Mandel <markmandel@google.com>

* Review updates

* Reorder in alias.go
* More coverage of TestNewEventsFromHTTPRequest
* tests for `to_events(...)`
* Better comment documentation.

Signed-off-by: Mark Mandel <markmandel@google.com>

Signed-off-by: Mark Mandel <markmandel@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/binding enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants