Laravel DB Failover + Telegram Notification + Circuit Breaker + Dynamic DB Switching
dedenfarhanhub/db-failover is a Laravel package for laravel db failover + telegram notification + circuit breaker + dynamic db switching.
It currently has 0 GitHub stars and 0 downloads on Packagist.
Install it with composer require dedenfarhanhub/db-failover.
Discover more Laravel packages by dedenfarhanhub
or browse all Laravel packages to compare alternatives.
Last updated
SultanDB is a Laravel package that automatically performs failover to a backup database connection when the primary connection is down. This package supports:
composer require dedenfarhanhub/db-failover
php artisan vendor:publish --tag=db-failover-config
Add the following lines to your .env file:
DB_FAILOVER_TELEGRAM=true
TELEGRAM_BOT_TOKEN=xxxxxx
TELEGRAM_CHAT_ID=xxxxx
Add middleware to app/Http/Kernel.php:
protected $middleware = [
\SultanDB\Middleware\DBMonitor::class,
];
use SultanDB\Helpers\Telegram;
Telegram::sendMessage("Database is down!");
Automatically switches from the primary connection to the secondary connection if the primary connection fails.
Counts the number of failures within a certain period before automatically breaking the connection.
Sends notifications to Telegram if there is any database connection issue.
Automatically falls back to Redis Cache if all database connections fail.
config/db-failover.php
return [
'telegram' => [
'enabled' => env('DB_FAILOVER_TELEGRAM', true),
'token' => env('TELEGRAM_BOT_TOKEN'),
'chat_id' => env('TELEGRAM_CHAT_ID'),
],
'circuit_breaker' => [
'attempt_limit' => 3,
'timeout' => 300,
],
'db_switch' => [
'redis_timeout' => 300,
],
];
php artisan test
Pull requests are highly welcome 🔥. Please include tests and documentation where possible.