@@ -20,11 +20,13 @@ erases stored session information as well.
20
20
21
21
This package wraps the configuration of Laravel's broadcasting, cache, session,
22
22
and queue APIs for Sentinel with the ability to set options for our Redis
23
- services independently. We configure the package separately from Laravel's
24
- standard Redis configuration so we can choose to use the Sentinel connections
25
- as needed by the environment. A developer may use a standalone Redis server in
26
- their local environment, while production environments operate a Redis Sentinel
27
- set of servers.
23
+ services independently. It adds Sentinel support for [ Laravel Horizon] [ s-horizon ]
24
+ and fixes other compatibility issues.
25
+
26
+ We configure the package separately from Laravel's standard Redis configuration
27
+ so we can choose to use the Sentinel connections as needed by the environment.
28
+ A developer may use a standalone Redis server in their local environment, while
29
+ production environments operate a Redis Sentinel set of servers.
28
30
29
31
30
32
Contents
@@ -42,6 +44,7 @@ Contents
42
44
- [ Executing Redis Commands (RedisSentinel Facade)] [ s-facade ]
43
45
- [ Dependency Injection] [ s-dependency-injection ]
44
46
- [ Other Sentinel Considerations] [ s-considerations ]
47
+ - [ Laravel Horizon] [ s-horizon ]
45
48
- [ Testing] ( #testing )
46
49
- [ License] ( #license )
47
50
- [ Appendix: Environment Variables] [ s-appx-env-vars ]
@@ -598,6 +601,9 @@ service (`app('redis')`, etc) will operate using the Sentinel connections.
598
601
This makes it easier for developers to use a standalone Redis server in their
599
602
local environments and switch to a full Sentinel set of servers in production.
600
603
604
+ ** Note:** When using the package with [ Laravel Horizon] [ s-horizon ] , this change
605
+ will cause Horizon to run over a Sentinel connection as well.
606
+
601
607
602
608
Executing Redis Commands (RedisSentinel Facade)
603
609
-------------------------------------------------
@@ -726,6 +732,67 @@ connection failure handling. For high-availability, use the Laravel API by
726
732
passing a closure to ` subscribe() ` or ` psubscribe() ` .
727
733
728
734
735
+ Laravel Horizon
736
+ ---------------
737
+
738
+ Versions 2.4.0 and greater of this package provide for the use of Sentinel
739
+ connections with the [ Laravel Horizon] [ laravel-horizon ] queue management tool
740
+ in compatible applications (Laravel 5.5+).
741
+
742
+ After [ installing Horizon] [ laravel-horizon-install-docs ] , we need to update
743
+ some configuration settings in * config/horizon.php* :
744
+
745
+ If needed, change ` 'use' => 'default' ` to the name of the Sentinel connection
746
+ to use for the Horizon backend as configured in * config/database.php* .
747
+
748
+ ** Important:** The standard ` 'redis' ` connections array in * config/database.php*
749
+ must contain an element with the same key as the Sentinel connection specified
750
+ for the ` 'use' ` directive or Horizon throws an exception. Currently, Horizon
751
+ does not provide a way for this package to handle this behavior, but an
752
+ (in-progress) pull request may eliminate this requirement in the future. This
753
+ element can contain any value (but a matching Redis connection config seems
754
+ most appropriate).
755
+
756
+ Change the backend driver for Horizon's internal metadata to ` 'redis-sentinel' `
757
+ by adding the following element to the top-level array:
758
+
759
+ ``` php
760
+ 'driver' => env('HORIZON_DRIVER', 'redis');
761
+ ```
762
+
763
+ ...and assign the value of ` redis-sentinel ` to ` HORIZON_DRIVER ` in * .env* .
764
+
765
+
766
+ Then, add an entry to the ` 'waits' ` array for any Sentinel queues:
767
+
768
+ ``` php
769
+ 'waits' => [
770
+ ...
771
+ 'redis-sentinel:default' => 60,
772
+ ],
773
+ ```
774
+
775
+ Next, change the connection driver to ` redis-sentinel ` for each of the queue
776
+ workers that should use Sentinel connections in the ` 'environments' ` block:
777
+
778
+ ``` php
779
+ ...
780
+ 'supervisor-1' => [
781
+ 'connection' => 'redis-sentinel',
782
+ ...
783
+ ],
784
+ ...
785
+ ```
786
+
787
+ Horizon will now use the application's Redis Sentinel connections to monitor
788
+ and process our queues.
789
+
790
+ ** Note:** If we already configured the package to [ override Laravel's standard
791
+ Redis API] [ s-override-redis-api ] (by setting ` REDIS_DRIVER ` to ` redis-sentinel ` ,
792
+ for example), we don't need to change ` HORIZON_DRIVER ` to ` 'redis-sentinel' ` .
793
+ The package already routes all Redis operations through Sentinel connections.
794
+
795
+
729
796
Testing
730
797
-------
731
798
@@ -1117,6 +1184,7 @@ Sentinel Documentation][sentinel].
1117
1184
[ s-env-config ] : #environment-based-configuration
1118
1185
[ s-env-config-examples ] : #environment-based-configuration-examples
1119
1186
[ s-facade ] : #executing-redis-commands-redissentinel-facade
1187
+ [ s-horizon ] : #laravel-horizon
1120
1188
[ s-hybrid-config ] : #hybrid-configuration
1121
1189
[ s-integration-tests ] : #integration-tests
1122
1190
[ s-multi-sentinel-example ] : #multi-sentinel-connection-configuration
@@ -1129,6 +1197,9 @@ Sentinel Documentation][sentinel].
1129
1197
[ s-standard-config-examples ] : #configuration-file-examples
1130
1198
1131
1199
[ laravel-env-docs ] : https://laravel.com/docs/configuration#environment-configuration
1200
+ [ laravel-horizon ] : https://horizon.laravel.com
1201
+ [ laravel-horizon-docs ] : https://laravel.com/docs/horizon
1202
+ [ laravel-horizon-install-docs ] : https://laravel.com/docs/horizon#installation
1132
1203
[ laravel-package-discovery-docs ] : https://laravel.com/docs/packages#package-discovery
1133
1204
[ laravel-redis-api-docs ] : https://laravel.com/docs/redis#interacting-with-redis
1134
1205
[ laravel-redis-docs ] : https://laravel.com/docs/redis
0 commit comments