swoole-src icon indicating copy to clipboard operation
swoole-src copied to clipboard

Question about Swoole Events, channels and listeners?

Open vrgenl opened this issue 6 years ago • 0 comments

I'm working on a small framework for a personal project which is based on swoole + kafka for event sourcing. For sending events to Kafka I've spawned a new process which is connected to my webserver through a channel. From my controller I now can push messages to this channel which the kafka-process pops the messages and sends it to the broker.

For the consuming part of the application I looked closely to swoole-jobs and created a process which has a bunch of workers updating read models etc. Nothing fancy here.

Because I want to support a public API I need some response from a event I've just pushed within my controller. The idea is to listen for events as soon as the event is pushed.

I'm trying to find out the best approach for this controller publish / subscribe situation. Because my queue workers pop the last message from a channel I'm forced to use some other method? I think Swoole Events are the way to go so I can listen for different things as well.

Wondering what you guys think about this approach? Mainly channels for publishing and events for subscribing. I'm not even sure it's possible to create your own swoole events and listen for event from different processes.

I hope I explained it well and that somebody has the time to point me in the right direction.

vrgenl avatar Aug 30 '18 10:08 vrgenl