-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
133 changed files
with
2,715 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Cushon\HealthBundle\CushonHealthBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle; | ||
|
||
return [ | ||
FrameworkBundle::class => ['all' => true], | ||
FriendsOfBehatSymfonyExtensionBundle::class => [ | ||
'test' => true, | ||
'dev' => true, | ||
], | ||
CushonHealthBundle::class => ['all' => true], | ||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], | ||
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'dev' => true], | ||
Cushon\HealthBundle\CushonHealthBundle::class => ['all' => true], | ||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], | ||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
parameters: | ||
env(DB_READ_HOST): '127.0.0.1' | ||
env(DB_READ_NAME): 'cushon_health_test' | ||
env(DB_READ_USER): 'cushon_read' | ||
env(DB_READ_VERSION): 'mariadb-10.7.3' | ||
env(DB_READ_PORT): 33010 | ||
|
||
env(DB_WRITE_HOST): '127.0.0.1' | ||
env(DB_WRITE_NAME): 'cushon_health_test' | ||
env(DB_WRITE_USER): 'cushon_write' | ||
env(DB_WRITE_VERSION): 'mariadb-10.7.3' | ||
env(DB_WRITE_PORT): 33010 | ||
|
||
doctrine: | ||
dbal: | ||
default_connection: 'read' | ||
connections: | ||
read: | ||
# Connection used for read operations | ||
host: '%env(string:DB_READ_HOST)%' | ||
dbname: '%env(string:DB_READ_NAME)%' | ||
user: '%env(string:DB_READ_USER)%' | ||
password: '%env(string:DB_READ_PASSWORD)%' | ||
server_version: '%env(string:DB_READ_VERSION)%' | ||
port: '%env(int:DB_READ_PORT)%' | ||
driver: 'pdo_mysql' | ||
options: | ||
LoginTimeout: 2 | ||
write: | ||
# Connection used for write operations | ||
host: '%env(string:DB_WRITE_HOST)%' | ||
dbname: '%env(string:DB_WRITE_NAME)%' | ||
user: '%env(string:DB_WRITE_USER)%' | ||
password: '%env(string:DB_WRITE_PASSWORD)%' | ||
server_version: '%env(string:DB_WRITE_VERSION)%' | ||
port: '%env(int:DB_WRITE_PORT)%' | ||
driver: 'pdo_mysql' | ||
options: | ||
LoginTimeout: 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
doctrine_migrations: | ||
connection: 'write' | ||
migrations_paths: | ||
# namespace is arbitrary but should be different from App\Migrations | ||
# as migrations classes should NOT be autoloaded | ||
'App\DoctrineMigrations': '%kernel.project_dir%/migrations' | ||
enable_profiler: '%kernel.debug%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,31 @@ | ||
# see https://symfony.com/doc/current/reference/configuration/framework.html | ||
framework: | ||
secret: '%env(APP_SECRET)%' | ||
#csrf_protection: true | ||
http_method_override: false | ||
secret: '%env(APP_SECRET)%' | ||
#csrf_protection: true | ||
http_method_override: false | ||
|
||
# Enables session support. Note that the session will ONLY be started if you read or write from it. | ||
# Remove or comment this section to explicitly disable session support. | ||
session: | ||
handler_id: null | ||
cookie_secure: auto | ||
cookie_samesite: lax | ||
storage_factory_id: session.storage.factory.native | ||
# Enables session support. Note that the session will ONLY be started if you read or write from it. | ||
# Remove or comment this section to explicitly disable session support. | ||
session: | ||
handler_id: null | ||
cookie_secure: auto | ||
cookie_samesite: lax | ||
storage_factory_id: session.storage.factory.native | ||
|
||
#esi: true | ||
#fragments: true | ||
php_errors: | ||
log: true | ||
#esi: true | ||
#fragments: true | ||
php_errors: | ||
log: true | ||
when@prod: &prod | ||
framework: | ||
http_client: | ||
# https://www.random.org/integers/?num=10&min=1&max=6&col=1&base=10&format=plain&rnd=new | ||
scoped_clients: | ||
random.client: | ||
base_uri: 'https://www.random.org' | ||
|
||
when@test: | ||
framework: | ||
test: true | ||
session: | ||
storage_factory_id: session.storage.factory.mock_file | ||
framework: | ||
test: true | ||
session: | ||
storage_factory_id: session.storage.factory.mock_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
framework: | ||
default_locale: en | ||
translator: | ||
default_path: '%kernel.project_dir%/translations' | ||
fallbacks: | ||
- en | ||
# providers: | ||
# crowdin: | ||
# dsn: '%env(CROWDIN_DSN)%' | ||
# loco: | ||
# dsn: '%env(LOCO_DSN)%' | ||
# lokalise: | ||
# dsn: '%env(LOKALISE_DSN)%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- MariaDB dump 10.19 Distrib 10.7.3-MariaDB, for debian-linux-gnu (x86_64) | ||
-- | ||
-- Host: localhost Database: uuid_example | ||
-- ------------------------------------------------------ | ||
-- Server version 10.7.3-MariaDB-1:10.7.3+maria~focal | ||
|
||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | ||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | ||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | ||
/*!40101 SET NAMES utf8mb4 */; | ||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; | ||
/*!40103 SET TIME_ZONE='+00:00' */; | ||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; | ||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; | ||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; | ||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; | ||
|
||
CREATE SCHEMA IF NOT EXISTS cushon_health_test; | ||
|
||
CREATE USER 'cushon_read'@'%'; | ||
CREATE USER 'cushon_write'@'%'; | ||
|
||
GRANT ALL PRIVILEGES ON `cushon_health_test`.* TO 'cushon_write'@'%' IDENTIFIED BY 'cushon_health_writer'; | ||
GRANT SELECT ON `cushon_health_test`.* TO 'cushon_read'@'%' IDENTIFIED BY 'cushon_health_reader'; | ||
|
||
FLUSH PRIVILEGES; | ||
|
||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; | ||
|
||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; | ||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; | ||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; | ||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; | ||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; | ||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; | ||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; | ||
|
||
-- Dump completed on 2022-03-23 15:47:25 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\DBAL\Types\Types; | ||
use Doctrine\Migrations\AbstractMigration; | ||
use Ramsey\Uuid\Doctrine\UuidBinaryType; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20220530155854 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Create a simple table for health checks'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$health = $schema->createTable('health'); | ||
$health->addColumn( | ||
'last_checked', | ||
Types::DATETIME_IMMUTABLE | ||
); | ||
|
||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$schema->dropTable('health'); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
app/src/ApplicationHealth/DependencyCheck/DatabaseCheck.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ApplicationHealth\DependencyCheck; | ||
|
||
use App\ApplicationHealth\DependencyCheck\DatabaseCheck\DatabaseUserCheck; | ||
use App\ApplicationHealth\DependencyCheck\DatabaseCheck\Exception\NoDatabaseChecksProvided; | ||
use Cushon\HealthBundle\ApplicationHealth\DependencyCheck; | ||
use Ds\Set; | ||
use Generator; | ||
|
||
final class DatabaseCheck implements DependencyCheck | ||
{ | ||
/** | ||
* @var Set<DatabaseUserCheck> | ||
*/ | ||
private Set $dependencyRepositories; | ||
|
||
/** | ||
* @param iterable<DatabaseUserCheck> $dependencyRepositories | ||
*/ | ||
public function __construct(iterable $dependencyRepositories) | ||
{ | ||
$this->dependencyRepositories = new Set(); | ||
foreach ($dependencyRepositories as $dependencyRepository) { | ||
$this->addDatabaseUserCheck($dependencyRepository); | ||
} | ||
|
||
if (!$this->dependencyRepositories->count()) { | ||
throw NoDatabaseChecksProvided::create(); | ||
} | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function check(): Generator | ||
{ | ||
foreach ($this->dependencyRepositories as $dependencyRepository) { | ||
yield $dependencyRepository->checkUser(); | ||
} | ||
} | ||
|
||
/** | ||
* @param DatabaseUserCheck $databaseUserChecks | ||
* @return void | ||
*/ | ||
private function addDatabaseUserCheck(DatabaseUserCheck $databaseUserChecks): void | ||
{ | ||
$this->dependencyRepositories->add($databaseUserChecks); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/ApplicationHealth/DependencyCheck/DatabaseCheck/DatabaseUserCheck.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\ApplicationHealth\DependencyCheck\DatabaseCheck; | ||
|
||
use Cushon\HealthBundle\ApplicationHealth\HealthReport\DependencyStatus; | ||
|
||
interface DatabaseUserCheck | ||
{ | ||
/** | ||
* @return DependencyStatus | ||
*/ | ||
public function checkUser(): DependencyStatus; | ||
} |
Oops, something went wrong.