cloudevents / sdk-go

Go SDK for CloudEvents
https://cloudevents.github.io/sdk-go/
Apache License 2.0
836 stars 221 forks source link

Add v3 version of NATS JetStream protocol #1095

Closed stephen-totty-hpe closed 1 month ago

stephen-totty-hpe commented 2 months ago

As been discussed previously, there has been a desire to implement the CloudEventSDK nats jetstream protocol using the newer jetstream package. The newer jetstream package exposes more jetstream specific functionality that should make it more flexible to use.

Much of this code is stolen from the v2 implementation and changed where necessary. It builds upon comments made in: https://github.com/cloudevents/sdk-go/pull/1083

Under the covers, this uses a jetstream.Consumer, which can be "normal" or "ordered". This is done using consumer options WithConsumerConfig and WithOrderedConsumerConfig.

Also, the need to know the stream names upfront is not needed. Many of the internal options are available if needed, although the only required option is the ConsumerOption with the correct config.

yanmxa commented 1 month ago

@stephen-totty-hpe Thanks! It looks good to me. Leave it to @embano1 ~