prwnr / laravel-streamer

Events streaming package for Laravel based on Redis Streams
96 stars 12 forks source link

keep-alive and max-attempts Listen command options added #30

Closed prwnr closed 3 years ago

prwnr commented 3 years ago

due to another two reports of connection timeout caused by phpredis lib I decided to add a keep-alive command option alongside with max-attempts - both are optional.

the keep-alive option will catch any unexpected errors on main streamer->listen method call and will simply start listener again. max-attempts option is here to limit how many times this restart will occur until command will exit - should be helpful to dont get caught in a loop of listener restarts.

This wont affect the internal catch and store failure feature of handlers that are processing stream messages - this is only for exceptions that are going outside of that part.

DISCLAIMER - this is not a direct fix to reported phpredis connection error RedisException : read error on connection to localhost:6378 but more of a way to mitigate that without usage of a 3rd party app (like supervisor)

This will also restart listener on any other Throwable, so keep that in mind when using this option, cause it may cause side effects.

29 #17

prwnr commented 3 years ago

leaving PR open for a day or two to settle things out and think if I didnt miss anything that would be good to have here, after that it will go into next major release 2.5.0