-
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.
initial commit of CakePHP 5.0 version
- Loading branch information
1 parent
f3d0ee4
commit c79a035
Showing
27 changed files
with
1,633 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.bat] | ||
end_of_line = crlf | ||
|
||
[*.yml] | ||
indent_size = 2 | ||
|
||
[*.xml] | ||
indent_size = 2 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.neon] | ||
indent_style = tab |
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,21 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- 2.next-cake5 | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
testsuite: | ||
uses: cakephp/.github/.github/workflows/[email protected] | ||
secrets: inherit | ||
|
||
cs-stan: | ||
uses: cakephp/.github/.github/workflows/[email protected] | ||
secrets: inherit |
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="phpstan" version="1.10.67" installed="1.10.67" location="./tools/phpstan" copy="false"/> | ||
<phar name="psalm" version="5.23.1" installed="5.23.1" location="./tools/psalm" copy="false"/> | ||
</phive> |
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,18 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [2.0] - 2024-04-17 | ||
|
||
### Added | ||
|
||
- First release for CakePHP 5.0 | ||
|
||
## [1.0] - 2024-04-17 | ||
|
||
### Added | ||
|
||
- First release for CakePHP 4.4 |
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,6 @@ | ||
Contributing | ||
============ | ||
|
||
This repository follows the [CakeDC Plugin Standard](https://www.cakedc.com/plugin-standard). If you'd like to | ||
contribute new features, enhancements or bug fixes to the plugin, please read our | ||
[Contribution Guidelines](https://www.cakedc.com/contribution-guidelines) for detailed instructions. |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Cake Development Corporation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,115 @@ | ||
# CakeDC Queue Monitor Plugin for CakePHP | ||
|
||
## Versions and branches | ||
| CakePHP | CakeDC Queue Monitor Plugin | Tag | Notes | | ||
|:-------:|:--------------------------------------------------------------------------:|:------------:|:-------| | ||
| ^5.0 | [2.0.0](https://github.com/CakeDC/cakephp-queue-monitor/tree/2.next-cake5) | 2.next-cake5 | stable | | ||
| ^4.4 | [1.0.0](https://github.com/CakeDC/cakephp-queue-monitor/tree/1.next-cake4) | 1.next-cake4 | stable | | ||
|
||
## Overview | ||
|
||
The CakeDC Queue Monitor Plugin adds the ability to monitor jobs in queues that are handled by the | ||
[CakePHP Queue Plugin](https://github.com/cakephp/queue). This plugin checks the duration of work of | ||
individual Jobs and sends a notification when this time is exceeded by a configurable value. | ||
|
||
## Requirements | ||
* CakePHP 5.0 | ||
* PHP 8.1+ | ||
|
||
## Installation | ||
|
||
You can install this plugin into your CakePHP application using [composer](https://getcomposer.org). | ||
|
||
The recommended way to install composer package is: | ||
``` | ||
composer require cakedc/queue-monitor | ||
``` | ||
|
||
## Configuration | ||
|
||
Add QueueMonitorPlugin to your `Application::bootstrap`: | ||
```php | ||
use Cake\Http\BaseApplication; | ||
use CakeDC\QueueMonitor\QueueMonitorPlugin; | ||
|
||
class Application extends BaseApplication | ||
{ | ||
// ... | ||
|
||
public function bootstrap(): void | ||
{ | ||
parent::bootstrap(); | ||
|
||
$this->addPlugin(QueueMonitorPlugin::class); | ||
} | ||
|
||
// ... | ||
} | ||
|
||
``` | ||
|
||
Set up the QueueMonitor configuration in your `config/app_local.php`: | ||
```php | ||
// ... | ||
'QueueMonitor' => [ | ||
// mailer config, the default is `default` mailer, you can ommit | ||
// this setting if you use default value | ||
'mailerConfig' => 'myCustomMailer', | ||
|
||
// the default is 30 minutes, you can ommit this setting if you | ||
// use the default value | ||
'longJobInMinutes' => 45, | ||
|
||
// the default is 30 days, you can ommit this setting if you | ||
// its advised to set this value correctly after queue usage analysis to avoid | ||
// high space usage in db | ||
'purgeLogsOlderThanDays' => 10, | ||
|
||
// comma separated list of recipients of notification about long running queue jobs | ||
'notificationRecipients' => '[email protected],[email protected],[email protected]', | ||
], | ||
// ... | ||
``` | ||
|
||
Run the required migrations | ||
```shell | ||
bin/cake migrations migrate -p CakeDC/QueueMonitor | ||
``` | ||
|
||
For each queue configuration add `listener` setting | ||
```php | ||
// ... | ||
'Queue' => [ | ||
'default' => [ | ||
// ... | ||
'listener' => \CakeDC\QueueMonitor\Listener\QueueMonitorListener::class, | ||
// ... | ||
] | ||
], | ||
// ... | ||
``` | ||
|
||
## Notification command | ||
|
||
To set up notifications when there are long running or possible stuck jobs please use command | ||
```shell | ||
bin/cake queue_monitor notify | ||
``` | ||
|
||
This command will send notification emails to recipients specified in `QueueMonitor.notificationRecipients`. Best is | ||
to use it as a cronjob | ||
|
||
## Purge command | ||
|
||
The logs table may grow overtime, to keep it slim you can use the purge command: | ||
```shell | ||
bin/cake queue_monitor purge | ||
``` | ||
|
||
This command will purge logs older than value specified in `QueueMonitor.purgeLogsOlderThanDays`, the value is in | ||
days, the default is 30 days. Best is to use it as a cronjob | ||
|
||
## Important | ||
|
||
Make sure your Job classes have a property value of maxAttempts because if it's missing, the log table can quickly | ||
grow to gigantic size in the event of an uncaught exception in Job, Job is re-queued indefinitely in such a case. |
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,74 @@ | ||
{ | ||
"name": "cakedc/queue-monitor", | ||
"description": "CakeDC Queue Monitor plugin for CakePHP", | ||
"type": "cakephp-plugin", | ||
"license": "MIT", | ||
"keywords": [ | ||
"cakephp", | ||
"queue", | ||
"queue monitoring", | ||
"queue monitor" | ||
], | ||
"homepage": "https://github.com/CakeDC/cakephp-queue-monitor", | ||
"authors": [ | ||
{ | ||
"name": "CakeDC", | ||
"homepage": "https://www.cakedc.com", | ||
"role": "Author" | ||
}, | ||
{ | ||
"name": "Others", | ||
"homepage": "https://github.com/CakeDC/cakephp-queue-monitor/graphs/contributors" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/CakeDC/cakephp-queue-monitor/issues", | ||
"source": "https://github.com/CakeDC/cakephp-queue-monitor" | ||
}, | ||
"require": { | ||
"php": ">=8.1", | ||
"cakephp/cakephp": "^5.0.1", | ||
"cakephp/queue": "^2.0", | ||
"ext-json": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^10.1.0", | ||
"cakephp/migrations": "^4.0.0", | ||
"cakephp/cakephp-codesniffer": "^5.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"CakeDC\\QueueMonitor\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"CakeDC\\QueueMonitor\\Test\\": "tests/", | ||
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"check": [ | ||
"@cs-check", | ||
"@test" | ||
], | ||
"cs-check": "phpcs --colors --parallel=16 -p src/ tests/", | ||
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/", | ||
"phpstan": "tools/phpstan analyse", | ||
"psalm": "tools/psalm --show-info=false", | ||
"stan": [ | ||
"@phpstan", | ||
"@psalm" | ||
], | ||
"stan-tests": "phpstan.phar analyze -c tests/phpstan.neon", | ||
"stan-baseline": "phpstan.phar --generate-baseline", | ||
"stan-setup": "phive install", | ||
"test": "phpunit", | ||
"test-coverage": "phpunit --coverage-clover=clover.xml" | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"dealerdirect/phpcodesniffer-composer-installer": true | ||
} | ||
} | ||
} |
Oops, something went wrong.