Replies: 4 comments 2 replies
-
NOTE: @caspervonb and @Jarema agreed that exposing everything through JetStreamContext as factories and operations will be the best approach. |
Beta Was this translation helpful? Give feedback.
-
Yeah I'm thinking more along the lines of: let jetstream = client.jetstream(nats::jetstream::JetStreamOptions::new());
jetstream.publish_with_options("foo", nats::jetstream::PublishOptions::new()
.expect_stream("EVENTS")
.expect_sequence(1)
); |
Beta Was this translation helpful? Give feedback.
-
For consumers we can go this way:
Each consumer exposes subscription functions available for given type of consumer. |
Beta Was this translation helpful? Give feedback.
-
Refactor has been implemented and merged. |
Beta Was this translation helpful? Give feedback.
-
Problem diagnosis
In current version of client (0.16.0) JetStream is exposed in given state:
no JetStream publish method
That means that the only way to publish to JetStream is by standard NATS publish method.
That, however, does not allow to:
Nats-Msg-Id
headerPubAck
)Consumer:: methods have both JetStream and Consumer config opts
Because of that:
Such implementation made Rust Client to drift quite far from reference Go implementation increasing cost of implementing new features available in Go client.
Solution
Follow Go Client approach and have a JetStream Context.
Go JetStreamContext is an interface aggregating all JetStream interactions and enables them to reuse the same base setup.
That means, that both
JetStream
publish
and allConsumers
can reuse the same context, which is especially useful when user want to switch a domain.*Example usage (early DRAFT):
But how to pass options?
Below snippet shows possible solution for passing options wihtout using struct instances with
..Default::default()
It rises some questions though:
NOTE: Work in progress.
Beta Was this translation helpful? Give feedback.
All reactions