Skip to content

Commit 4d226ce

Browse files
committed
First commit
0 parents  commit 4d226ce

23 files changed

+1597
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
/vendor/
3+
vendor/
4+
composer.lock

.settings.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
return [
4+
'parameters' => [
5+
'value' => [
6+
],
7+
'readonly' => false,
8+
],
9+
'services' => [
10+
'value' => [
11+
'Proklung\Redis\Samples\FooRedisProcessor' =>
12+
[
13+
'className' => \Proklung\Redis\Samples\FooRedisProcessor::class,
14+
'tags' => ['name' => 'enqueue.topic_subscriber', 'client' => 'default']
15+
],
16+
],
17+
'readonly' => false,
18+
],
19+
];

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Roman Horbach
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "proklung/bitrix.redis.module",
3+
"description": "Поддержка очередей Redis (и не только) в Битриксе",
4+
"type": "bitrix-d7-module",
5+
"keywords": [
6+
"bitrix",
7+
"bitrix-module",
8+
"bitrix-cms",
9+
"bitrix-d7"
10+
],
11+
"homepage": "https://github.com/ProklUng/bitrix.redis.module",
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Gavrilov Fedy",
16+
"email": "fedor.gavrilov.75@mail.ru"
17+
}
18+
],
19+
20+
"support": {
21+
"issues": "https://github.com/ProklUng/bitrix.redis.module/issues",
22+
"source": "https://github.com/ProklUng/bitrix.redis.module"
23+
},
24+
"extra": {
25+
"installer-name": "proklung.redis"
26+
},
27+
"require": {
28+
"php": ">=7.1 || ^8.0",
29+
"symfony/dependency-injection": "^4.0 || ^5.0",
30+
"symfony/config": "^4.0 || ^5.0",
31+
"symfony/yaml": "^4.0 || ^5.0",
32+
"symfony/http-foundation": "^4.0 || ^5.0",
33+
"symfony/http-kernel": "^4.0 || ^5.0",
34+
"composer/installers": "~1",
35+
"enqueue/redis": "^0.10.9",
36+
"predis/predis": "^1.1",
37+
"enqueue/fs": "^0.10.9",
38+
"enqueue/amqp-bunny": "^0.10.9",
39+
"queue-interop/amqp-interop": "^0.8.2",
40+
"queue-interop/queue-interop": "^0.8",
41+
"enqueue/enqueue": "^0.10",
42+
"enqueue/null": "^0.10",
43+
"ext-json": "*"
44+
},
45+
"require-dev": {
46+
"icanhazstring/composer-unused": "^0.7.5"
47+
}
48+
}

configs/services.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: true
6+
7+
enqueue.locator:
8+
class: 'Symfony\Component\DependencyInjection\ServiceLocator'
9+
arguments:
10+
- []
11+
tags: ['container.service_locator']
12+
13+
enqueue.transport.consume_command:
14+
class: 'Enqueue\Symfony\Consumption\ConfigurableConsumeCommand'
15+
arguments:
16+
- '@enqueue.locator'
17+
- '%enqueue.default_transport%'
18+
- 'enqueue.transport.%s.queue_consumer'
19+
- 'enqueue.transport.%s.processor_registry'
20+
tags:
21+
- { name: 'console.command' }
22+
23+
enqueue.client.consume_command:
24+
class: 'Enqueue\Symfony\Client\ConsumeCommand'
25+
arguments:
26+
- '@enqueue.locator'
27+
- '%enqueue.default_client%'
28+
- 'enqueue.client.%s.queue_consumer'
29+
- 'enqueue.client.%s.driver'
30+
- 'enqueue.client.%s.delegate_processor'
31+
tags:
32+
- { name: 'console.command' }
33+
34+
enqueue.client.produce_command:
35+
class: 'Enqueue\Symfony\Client\ProduceCommand'
36+
arguments:
37+
- '@enqueue.locator'
38+
- '%enqueue.default_client%'
39+
- 'enqueue.client.%s.producer'
40+
tags:
41+
- { name: 'console.command' }
42+
43+
enqueue.client.setup_broker_command:
44+
class: 'Enqueue\Symfony\Client\SetupBrokerCommand'
45+
arguments:
46+
- '@enqueue.locator'
47+
- '%enqueue.default_client%'
48+
- 'enqueue.client.%s.driver'
49+
tags:
50+
- { name: 'console.command' }
51+
52+
enqueue.client.routes_command:
53+
class: 'Enqueue\Symfony\Client\RoutesCommand'
54+
arguments:
55+
- '@enqueue.locator'
56+
- '%enqueue.default_client%'
57+
- 'enqueue.client.%s.driver'
58+
tags:
59+
- { name: 'console.command' }

install/bin/enqueue

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use Bitrix\Main\DB\ConnectionException;
5+
use Bitrix\Main\Loader;
6+
use Proklung\Redis\CLI\CommandsSetup;
7+
use Proklung\Redis\CLI\ConsoleCommandConfigurator;
8+
use Proklung\Redis\DI\Services;
9+
use Symfony\Component\Console\Application;
10+
11+
@set_time_limit(0);
12+
13+
$_SERVER['DOCUMENT_ROOT'] = __DIR__. DIRECTORY_SEPARATOR . '..';
14+
$documentRoot = $GLOBALS['DOCUMENT_ROOT'] = $_SERVER['DOCUMENT_ROOT'];
15+
16+
$autoloadPath = $_SERVER['DOCUMENT_ROOT'] . '/vendor/autoload.php';
17+
18+
define('BITRIX_CLI', true);
19+
define('NO_KEEP_STATISTIC', true);
20+
define('NOT_CHECK_PERMISSIONS', true);
21+
define('LANGUAGE_ID', 'pa');
22+
define('LOG_FILENAME', 'php://stderr');
23+
define('BX_NO_ACCELERATOR_RESET', true);
24+
define('STOP_STATISTICS', true);
25+
define('NO_AGENT_STATISTIC', 'Y');
26+
define('NO_AGENT_CHECK', true);
27+
defined('PUBLIC_AJAX_MODE') || define('PUBLIC_AJAX_MODE', true);
28+
29+
/** @noinspection PhpIncludeInspection */
30+
require_once $autoloadPath;
31+
32+
try {
33+
34+
global
35+
$DB, $DBType, $DBHost, $DBLogin, $DBPassword,
36+
$DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $DBSQLServerType;
37+
38+
require_once $documentRoot . '/bitrix/modules/main/include/prolog_before.php';
39+
40+
$bitrixStatus = 0;
41+
42+
if (defined('B_PROLOG_INCLUDED') && B_PROLOG_INCLUDED === true) {
43+
$bitrixStatus = 200;
44+
}
45+
46+
// Альтернативный способ вывода ошибок типа "DB query error.":
47+
$GLOBALS['DB']->debug = true;
48+
49+
$app = \Bitrix\Main\Application::getInstance();
50+
$con = $app->getConnection();
51+
$DB->db_Conn = $con->getResource();
52+
53+
if (in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) {
54+
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '
55+
. \PHP_SAPI . ' SAPI' . \PHP_EOL;
56+
}
57+
} catch (ConnectionException $e) {
58+
$bitrixStatus = 404;
59+
}
60+
61+
if ($bitrixStatus !== 200) {
62+
exit('Bitrix not loaded.');
63+
}
64+
65+
Loader::includeModule('proklung.redis');
66+
67+
$services = new Services();
68+
$services->load();
69+
$container = $services->getContainer();
70+
71+
$commands = CommandsSetup::load($container);
72+
73+
$application = new ConsoleCommandConfigurator(
74+
new Application(),
75+
...$commands
76+
);
77+
78+
$application->init();
79+
$application->run();

install/index.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
use Bitrix\Main\Application;
4+
use Bitrix\Main\Localization\Loc;
5+
use ProklUng\Module\Boilerplate\Module;
6+
use ProklUng\Module\Boilerplate\ModuleUtilsTrait;
7+
8+
Loc::loadMessages(__FILE__);
9+
10+
class proklung_redis extends CModule
11+
{
12+
use ModuleUtilsTrait;
13+
14+
public function __construct()
15+
{
16+
$arModuleVersion = [];
17+
18+
include __DIR__.'/version.php';
19+
20+
if (is_array($arModuleVersion)
21+
&&
22+
array_key_exists('VERSION', $arModuleVersion)) {
23+
$this->MODULE_VERSION = $arModuleVersion['VERSION'];
24+
$this->MODULE_VERSION_DATE = $arModuleVersion['VERSION_DATE'];
25+
}
26+
27+
$this->MODULE_FULL_NAME = 'redis';
28+
$this->MODULE_VENDOR = 'proklung';
29+
$prefixLangCode = 'REDIS';
30+
31+
$this->MODULE_NAME = Loc::getMessage($prefixLangCode.'_MODULE_NAME');
32+
$this->MODULE_ID = $this->MODULE_VENDOR.'.'.$this->MODULE_FULL_NAME;
33+
34+
$this->MODULE_DESCRIPTION = Loc::getMessage($prefixLangCode.'_MODULE_DESCRIPTION');
35+
$this->MODULE_GROUP_RIGHTS = 'N';
36+
$this->PARTNER_NAME = Loc::getMessage($prefixLangCode.'_MODULE_PARTNER_NAME');
37+
$this->PARTNER_URI = Loc::getMessage($prefixLangCode.'MODULE_PARTNER_URI');
38+
39+
$this->INSTALL_PATHS = [
40+
'/local/modules/proklung.redis/install/admin/redis_index.php'
41+
=> '/bitrix/admin/redis_index.php',
42+
];
43+
44+
$this->moduleManager = new Module(
45+
[
46+
'MODULE_ID' => $this->MODULE_ID,
47+
'VENDOR_ID' => $this->MODULE_VENDOR,
48+
'MODULE_VERSION' => $this->MODULE_VERSION,
49+
'MODULE_VERSION_DATE' => $this->MODULE_VERSION_DATE,
50+
'ADMIN_FORM_ID' => $this->MODULE_VENDOR.'_settings_form',
51+
]
52+
);
53+
54+
$this->moduleManager->addModuleInstance($this);
55+
$this->options();
56+
}
57+
58+
/**
59+
* @inheritDoc
60+
*/
61+
public function UnInstallFiles()
62+
{
63+
parent::UnInstallFiles();
64+
65+
$rootDir = Application::getDocumentRoot().'/';
66+
$binFile = '/enqueue';
67+
68+
@unlink($rootDir . '../../bin' . $binFile);
69+
70+
return true;
71+
}
72+
73+
/**
74+
* @inheritDoc
75+
*/
76+
public function InstallFiles()
77+
{
78+
parent::InstallFiles();
79+
80+
$rootDir = Application::getDocumentRoot().'/';
81+
$binFile = '/enqueue';
82+
83+
if (is_dir($rootDir . '../../bin')) {
84+
$src = __DIR__. '/bin' . $binFile;
85+
copy($src, $rootDir . '../../bin' . $binFile);
86+
}
87+
88+
return true;
89+
}
90+
91+
92+
}

install/version.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
$arModuleVersion = [
4+
'VERSION' => '1.0.0',
5+
'VERSION_DATE' => '2021-07-13'
6+
];

lang/ru/install/index.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
$MESS['REDIS_MODULE_NAME'] = 'Очереди на Redis';
4+
$MESS['REDIS_MODULE_DESCRIPTION'] = 'Очереди на Redis';
5+
$MESS['REDIS_MODULE_PARTNER_NAME'] = 'ProklUng';
6+
$MESS['REDIS_MODULE_PARTNER_URI'] = '';

lang/ru/options.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die();
3+

0 commit comments

Comments
 (0)