-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from OS2web/feature/audit-logging-performance
Added queue logic to enhance performance
- Loading branch information
Showing
8 changed files
with
170 additions
and
30 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
10 changes: 10 additions & 0 deletions
10
config/install/advancedqueue.advancedqueue_queue.os2web_audit.yml
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,10 @@ | ||
status: true | ||
dependencies: { } | ||
id: os2web_audit | ||
label: os2web_audit | ||
backend: database | ||
backend_configuration: | ||
lease_time: 300 | ||
processor: daemon | ||
processing_time: 90 | ||
locked: false |
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,69 @@ | ||
<?php | ||
|
||
namespace Drupal\os2web_audit\Plugin\AdvancedQueue\JobType; | ||
|
||
use Drupal\Component\Plugin\Exception\PluginException; | ||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
use Drupal\advancedqueue\Job; | ||
use Drupal\advancedqueue\JobResult; | ||
use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase; | ||
use Drupal\os2web_audit\Exception\AuditException; | ||
use Drupal\os2web_audit\Exception\ConnectionException; | ||
use Drupal\os2web_audit\Service\Logger; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
/** | ||
* Log messages job. | ||
* | ||
* @AdvancedQueueJobType( | ||
* id = "Drupal\os2web_audit\Plugin\AdvancedQueue\JobType\LogMessages", | ||
* label = @Translation("Audit Log messages"), | ||
* ) | ||
*/ | ||
class LogMessages extends JobTypeBase implements ContainerFactoryPluginInterface { | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @phpstan-param array<string, mixed> $configuration | ||
*/ | ||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | ||
return new static( | ||
$configuration, | ||
$plugin_id, | ||
$plugin_definition, | ||
$container->get('os2web_audit.logger'), | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @phpstan-param array<string, mixed> $configuration | ||
*/ | ||
public function __construct( | ||
array $configuration, | ||
$plugin_id, | ||
$plugin_definition, | ||
private readonly Logger $logger, | ||
) { | ||
parent::__construct($configuration, $plugin_id, $plugin_definition); | ||
} | ||
|
||
/** | ||
* Processes the LogMessages job. | ||
*/ | ||
public function process(Job $job): JobResult { | ||
$payload = $job->getPayload(); | ||
|
||
try { | ||
$this->logger->log($payload['type'], $payload['timestamp'], $payload['line'], $payload['plugin_id'], $payload['metadata']); | ||
|
||
return JobResult::success(); | ||
} | ||
catch (PluginException | ConnectionException | AuditException $e) { | ||
return JobResult::failure($e->getMessage()); | ||
} | ||
} | ||
|
||
} |
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