\Drupal\strata\Journal JournalFactory

Chooses the journal backend, and falls back rather than failing.

A journal that cannot be constructed would take capture down with it, and capture is the one thing that must not stop: an operation not captured is a gap in the history that nothing can fill later. So a configured backend that cannot be reached logs why and hands back the database journal, which needs nothing beyond what Drupal already has.

The Redis connection is read from Drupal's own redis.connection settings, which is where drupal/redis puts it, so a site already running Redis configures nothing extra.

Summary

Methods
Properties
Constants
__construct
create
active
No public properties found
DATABASE
REDIS
DEFAULT_HOST
DEFAULT_PORT
TIMEOUT
No protected methods found
No protected properties found
No protected constants found
connect
configFactory
database
logger
client
No private constants found

Constant

DATABASE

DATABASE = 'database'

The always-available backend.

REDIS

REDIS = 'redis'

The Redis stream backend.

DEFAULT_HOST

DEFAULT_HOST = '127.0.0.1'

Default Redis host, matching what `drupal/redis` assumes.

DEFAULT_PORT

DEFAULT_PORT = 6379

Default Redis port.

TIMEOUT

TIMEOUT = 1.0

Seconds to wait for a Redis connection.

Short, because this runs while a request is being served and a journal that hangs is worse than one that falls back.

Properties

$configFactory

$configFactory : \Drupal\Core\Config\ConfigFactoryInterface

Type

ConfigFactoryInterface

$database

$database : \Drupal\Core\Database\Connection

Type

Connection

$logger

$logger : \Psr\Log\LoggerInterface

Type

LoggerInterface

$client

$client : ?object

Type

object|null

Methods

__construct()

__construct(\Drupal\Core\Config\ConfigFactoryInterface  $configFactory, \Drupal\Core\Database\Connection  $database, \Psr\Log\LoggerInterface  $logger, object|null  $client = null) : mixed

Constructs a factory.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $configFactory

Where the configured backend is read from.

\Drupal\Core\Database\Connection $database

Backs the database journal.

\Psr\Log\LoggerInterface $logger

Records a backend that could not be used.

object|null $client

A ready Redis client, which a test supplies. NULL to connect from settings.

Returns

mixed —

create()

create() : \Drupal\strata\Journal\JournalInterface

The journal this site should use.

Returns

\Drupal\strata\Journal\JournalInterface —

The journal.

active()

active() : string

Which backend is actually in use.

Shown on the status page, because "configured for Redis" and "using Redis" are different statements and an operator needs the second one.

Returns

string —

A backend id.

connect()

connect() : object|null

A Redis client from Drupal's own connection settings.

Returns

object|null —

The client, or NULL when the extension is absent or the connection failed.