sdk-go icon indicating copy to clipboard operation
sdk-go copied to clipboard

Batch encoding support in bindings interfaces

Open slinkydeveloper opened this issue 5 years ago • 4 comments

slinkydeveloper avatar Feb 04 '20 15:02 slinkydeveloper

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?

slinkydeveloper avatar Apr 14 '20 08:04 slinkydeveloper

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.

n3wscott avatar Apr 14 '20 14:04 n3wscott

support batch event now ?

acodetailor avatar Apr 30 '21 07:04 acodetailor

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

Xopek avatar May 19 '21 09:05 Xopek