Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transaction support #307

Merged
merged 1 commit into from
Dec 1, 2021
Merged

transaction support #307

merged 1 commit into from
Dec 1, 2021

Conversation

gmethvin
Copy link
Collaborator

No description provided.

@gmethvin gmethvin force-pushed the txn branch 8 times, most recently from 17b7c8f to ff71a92 Compare May 12, 2021 23:57
* headers and so on. The producer will generate an appropriate
* Pulsar [[ProducerMessage]] with this t set as the value.
*/
def sendAsync[F[_] : AsyncHandler](t: T): F[MessageId]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that Pulsar supports both send and sendAsync with transactions, while it only supports acknowledgeAsync, but it seems odd that you'd want to use an async method one place but not in another, so I think I'll omit that from the transactional API.

@gmethvin gmethvin force-pushed the txn branch 4 times, most recently from 700832d to 395aede Compare May 19, 2021 01:54
for {
msg <- consumer.receiveAsync
msgId <- txn(producer).sendAsync(msg.value + "_test")
_ <- txn(consumer).acknowledgeAsync(msg.messageId)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this syntax but this instantiates the wrapper every single call. performance-wise it's negligible, but it seems slightly weird to re-instantiate the wrapper every single time

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or maybe we're meant to do txnProducer = txn(producer) for multiple calls?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think whether you use an intermediate variable or not is down to personal preference. I was leaning toward just using the extra parameter like producer.sendAsync(value, txn), which has the advantage of being simpler to implement, but I sort of like the txn coming first to make it clear the work is done in a transaction.

@gmethvin
Copy link
Collaborator Author

@sksamuel let me know if you have any thoughts on this. I'm open to making changes in the API.

@gmethvin gmethvin force-pushed the txn branch 7 times, most recently from 4b62fa7 to c71fbf1 Compare June 13, 2021 22:59
@gmethvin gmethvin force-pushed the txn branch 2 times, most recently from 273d64c to 01ccd32 Compare June 28, 2021 22:30
@gmethvin gmethvin force-pushed the txn branch 3 times, most recently from b8010c3 to d39edcd Compare August 20, 2021 20:17
@gmethvin
Copy link
Collaborator Author

@sksamuel I rebased this on top of the current master. Do you have any thoughts on the API?

@judu
Copy link
Member

judu commented Oct 21, 2021

Hi! I just took over the maintenance of this project.

Right now, I have no strong opinion about the API. It seems quite straightforward to me. (For reasons I'm stuck on pulsar 2.7.1. So no txn for me right now… 😢 )

@gmethvin
Copy link
Collaborator Author

ok @judu , so you don't mind merging this?

@judu judu merged commit 8594966 into CleverCloud:master Dec 1, 2021
judu added a commit that referenced this pull request Dec 8, 2021
Changelog:
- [Org] Change com.sksamuel to com.clever-cloud for nexus credentials reasons
- [Org] Update all refs to github.com/CleverCloud
- [Deps] Upgrade deps:
  - scala 2.13.7, 2.12.15
  - play-json 2.8.2
  - pulsar-client 2.9.0
  - json4s 4.0.3
  - scalaz 7.2.33
  - monix 3.4.0
  - cats-effect 2.5.4
  - jackson 2.13.0
  - java8compat 1.0.1 (0.9.1 for scala 2.12)
  - akka-stream 2.6.17
  - log4j 2.14.1
- [Fix] Add fs2 to project aggregate in build.sbt #364 (thanks @valdo404)
- [Fix] Metadata is not copied to Java messages #334 (thanks @sksamuel)
- [Feature] Add transaction support #307 (thanks @gmethvin)
- [Feature] Add replicateSubscriptionState in consumerConfig #347 (thanks @deveshgithub)
- [Feature] Add enableBatchIndexAcknowledgement option #359 (thanks @gmethvin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants