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

Introduce Kafka::asyncPublish() that will not flush on each send/batchSend but only once when the application is terminating #310

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

sash
Copy link
Contributor

@sash sash commented Aug 8, 2024

See discussion #309

src/Factory.php Show resolved Hide resolved
Copy link
Owner

@mateusjunges mateusjunges left a comment

Choose a reason for hiding this comment

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

Thanks @sash! I left some small tweaks. I'm still testing this before I make any decisions, but it makes me want to remove support for batch publishing messages.

src/Producers/Builder.php Show resolved Hide resolved
src/Producers/Builder.php Show resolved Hide resolved
src/Producers/Builder.php Show resolved Hide resolved
src/Producers/Producer.php Show resolved Hide resolved
src/Factory.php Show resolved Hide resolved
src/Facades/Kafka.php Show resolved Hide resolved
@mateusjunges mateusjunges changed the base branch from master to async August 9, 2024 22:23
@mateusjunges mateusjunges merged commit 3031da7 into mateusjunges:async Aug 9, 2024
6 checks passed
@mateusjunges
Copy link
Owner

Merging into the async branch, I'll take it from here. Thank you @sash!

@sash
Copy link
Contributor Author

sash commented Aug 12, 2024

I thought of something I didn't do - I need to have a singleton in order to keep a singular instance of the builder, so that even if you call Kafka::asyncPublish multiple times, you will still get the same instance that will have the same publisher. The current implementation creates multiple publishers and has each of them being flushed when the app terminates, and its up to the user to reuse the builder in his/hers code.

Perhaps we should have an argument $async = false for the Factory->produce method (instead of a standalone asyncPublish that feals clunky to me). And we should also have a Factory->defaultProducer that will use the container to return a singleton instance of an async producer builder?

mateusjunges added a commit that referenced this pull request Aug 18, 2024
* Introduce Kafka::asyncPublish() that will not flush on each send/batchSend but only once when the application is terminating (#310)

* upd: async production (that has only one flush at the end of the application) [see discussion #309]

* fix: added broker parameter to the facade helper [see discussion #309]

* ref: simplify Builder construct extension [see discussion #309]

---------

Co-authored-by: Alexander (SASh) Alexiev <[email protected]>

* wip

* Deprecate batch messages

* Docs

* wip

* wip

* wip

* wip

* Update docs for v2

* Remove cache folder

* Update gitignore

* Store the builder in memory

* Add tests

* Update tests

---------

Co-authored-by: SASh <[email protected]>
Co-authored-by: Alexander (SASh) Alexiev <[email protected]>
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.

2 participants