sdk-go
sdk-go copied to clipboard
Batch encoding support in bindings interfaces
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
Messageor aMultiMessage? - We want to have another function called
NewMultiMessagethat returns always aMultiMessageand, in case of single structured/binary message, returns a one elementMultiMessage?
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.
support batch event now ?
Really looking forward to be able to send multiple events at once. Can i help somehow to implement it?