Actyx / Actyx

Local-First Cooperation based on Event Sourcing

Home Page:https://developer.actyx.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`ActyxClient::publish` is too verbose

jmg-duarte opened this issue · comments

client
    .publish(PublishRequest {
        data: vec![PublishEvent {
            tags: tags!("message"),
            payload: Payload::compact(&event).expect("failed to serialize event"),
        }],
    })
    .await
    .expect("failed to publish event");

This function suffers from the same issue as #553.

  • We can provide a function for a single event, or multiple events.
  • Publishing several events with the same tags is also not ergonomic — the user is required to write down the tags multiple times.

Some like the following would be more ergonomic:

client.publish_events(&tags, vec![event1, event2])

For example:

client
    .publish_event(tags!("hello", "there"), &event)

And we could still keep publish as a more low-level abstraction (still keeping the Payload::compact away from the user):

client.publish(vec![PublishEvent::new(tags!("hey", "there"), &event)])

How about publish_single and publish? And we can remove the PublishEvent type from this API and just use (Tags, T).