NEW: Queue managing with DB2 ODBC connections
This commit is contained in:
parent
5c6bef7fa0
commit
8ee8a02237
@ -16,20 +16,20 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2.5",
|
"php": "^7.2",
|
||||||
"illuminate/database": "^7.0"
|
"illuminate/database": "^6.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Cooperl\\Database\\DB2\\": "src/"
|
"Cooperl\\DB2\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
"providers": [
|
"providers": [
|
||||||
"Cooperl\\Database\\DB2\\DB2ServiceProvider"
|
"Cooperl\\DB2\\DB2ServiceProvider"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2;
|
namespace Cooperl\DB2;
|
||||||
|
|
||||||
use Illuminate\Foundation\Application as LaravelApplication;
|
use Illuminate\Foundation\Application as LaravelApplication;
|
||||||
use Laravel\Lumen\Application as LumenApplication;
|
use Laravel\Lumen\Application as LumenApplication;
|
||||||
use Cooperl\Database\DB2\Connectors\ODBCConnector;
|
use Cooperl\DB2\Database\DB2Connection;
|
||||||
use Cooperl\Database\DB2\Connectors\IBMConnector;
|
use Cooperl\DB2\Database\Connectors\ODBCConnector;
|
||||||
use Cooperl\Database\DB2\Connectors\ODBCZOSConnector;
|
use Cooperl\DB2\Database\Connectors\IBMConnector;
|
||||||
|
use Cooperl\DB2\Database\Connectors\ODBCZOSConnector;
|
||||||
|
use Cooperl\DB2\Queue\DB2Connector;
|
||||||
|
use Illuminate\Queue\QueueManager;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DB2ServiceProvider
|
* Class DB2ServiceProvider
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2
|
* @package Cooperl\DB2\Database
|
||||||
*/
|
*/
|
||||||
class DB2ServiceProvider extends ServiceProvider
|
class DB2ServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@ -84,6 +87,17 @@ class DB2ServiceProvider extends ServiceProvider
|
|||||||
return new DB2Connection($db2Connection, $config["database"], $config["prefix"], $config);
|
return new DB2Connection($db2Connection, $config["database"], $config["prefix"], $config);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->app->extend(
|
||||||
|
'queue',
|
||||||
|
function (QueueManager $queueManager) {
|
||||||
|
$queueManager->addConnector('db2_odbc', function () {
|
||||||
|
return new DB2Connector($this->app['db']);
|
||||||
|
});
|
||||||
|
|
||||||
|
return $queueManager;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Connectors;
|
namespace Cooperl\DB2\Database\Connectors;
|
||||||
|
|
||||||
use Illuminate\Database\Connectors\Connector;
|
use Illuminate\Database\Connectors\Connector;
|
||||||
use Illuminate\Database\Connectors\ConnectorInterface;
|
use Illuminate\Database\Connectors\ConnectorInterface;
|
||||||
@ -8,7 +8,7 @@ use Illuminate\Database\Connectors\ConnectorInterface;
|
|||||||
/**
|
/**
|
||||||
* Class IBMConnector
|
* Class IBMConnector
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Connectors
|
* @package Cooperl\DB2\Database\Connectors
|
||||||
*/
|
*/
|
||||||
class DB2Connector extends Connector implements ConnectorInterface
|
class DB2Connector extends Connector implements ConnectorInterface
|
||||||
{
|
{
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Connectors;
|
namespace Cooperl\DB2\Database\Connectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IBMConnector
|
* Class IBMConnector
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Connectors
|
* @package Cooperl\DB2\Database\Connectors
|
||||||
*/
|
*/
|
||||||
class IBMConnector extends DB2Connector
|
class IBMConnector extends DB2Connector
|
||||||
{
|
{
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Connectors;
|
namespace Cooperl\DB2\Database\Connectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ODBCConnector
|
* Class ODBCConnector
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Connectors
|
* @package Cooperl\DB2\Database\Connectors
|
||||||
*/
|
*/
|
||||||
class ODBCConnector extends DB2Connector
|
class ODBCConnector extends DB2Connector
|
||||||
{
|
{
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Connectors;
|
namespace Cooperl\DB2\Database\Connectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ODBCZOSConnector
|
* Class ODBCZOSConnector
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Connectors
|
* @package Cooperl\DB2\Database\Connectors
|
||||||
*/
|
*/
|
||||||
class ODBCZOSConnector extends ODBCConnector
|
class ODBCZOSConnector extends ODBCConnector
|
||||||
{
|
{
|
@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2;
|
namespace Cooperl\DB2\Database;
|
||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
|
|
||||||
use Illuminate\Database\Connection;
|
use Illuminate\Database\Connection;
|
||||||
|
|
||||||
use Cooperl\Database\DB2\Schema\Builder;
|
use Cooperl\DB2\Database\Schema\Builder;
|
||||||
use Cooperl\Database\DB2\Query\Processors\DB2Processor;
|
use Cooperl\DB2\Database\Query\Processors\DB2Processor;
|
||||||
use Cooperl\Database\DB2\Query\Processors\DB2ZOSProcessor;
|
use Cooperl\DB2\Database\Query\Processors\DB2ZOSProcessor;
|
||||||
use Cooperl\Database\DB2\Query\Grammars\DB2Grammar as QueryGrammar;
|
use Cooperl\DB2\Database\Query\Grammars\DB2Grammar as QueryGrammar;
|
||||||
use Cooperl\Database\DB2\Schema\Grammars\DB2Grammar as SchemaGrammar;
|
use Cooperl\DB2\Database\Schema\Grammars\DB2Grammar as SchemaGrammar;
|
||||||
use Cooperl\Database\DB2\Schema\Grammars\DB2ExpressCGrammar;
|
use Cooperl\DB2\Database\Schema\Grammars\DB2ExpressCGrammar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DB2Connection
|
* Class DB2Connection
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2
|
* @package Cooperl\DB2\Database
|
||||||
*/
|
*/
|
||||||
class DB2Connection extends Connection
|
class DB2Connection extends Connection
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ class DB2Connection extends Connection
|
|||||||
/**
|
/**
|
||||||
* Get a schema builder instance for the connection.
|
* Get a schema builder instance for the connection.
|
||||||
*
|
*
|
||||||
* @return \Cooperl\Database\DB2\Schema\Builder
|
* @return \Cooperl\DB2\Database\Schema\Builder
|
||||||
*/
|
*/
|
||||||
public function getSchemaBuilder()
|
public function getSchemaBuilder()
|
||||||
{
|
{
|
||||||
@ -133,7 +133,7 @@ class DB2Connection extends Connection
|
|||||||
/**
|
/**
|
||||||
* Get the default post processor instance.
|
* Get the default post processor instance.
|
||||||
*
|
*
|
||||||
* @return \Cooperl\Database\DB2\Query\Processors\DB2Processor|\Cooperl\Database\DB2\Query\Processors\DB2ZOSProcessor
|
* @return \Cooperl\DB2\Database\Query\Processors\DB2Processor|\Cooperl\DB2\Database\Query\Processors\DB2ZOSProcessor
|
||||||
*/
|
*/
|
||||||
protected function getDefaultPostProcessor()
|
protected function getDefaultPostProcessor()
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Query\Grammars;
|
namespace Cooperl\DB2\Database\Query\Grammars;
|
||||||
|
|
||||||
use Illuminate\Database\Query\Grammars\Grammar;
|
use Illuminate\Database\Query\Grammars\Grammar;
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
@ -8,7 +8,7 @@ use Illuminate\Database\Query\Builder;
|
|||||||
/**
|
/**
|
||||||
* Class DB2Grammar
|
* Class DB2Grammar
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Query\Grammars
|
* @package Cooperl\DB2\Database\Query\Grammars
|
||||||
*/
|
*/
|
||||||
class DB2Grammar extends Grammar
|
class DB2Grammar extends Grammar
|
||||||
{
|
{
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Query\Processors;
|
namespace Cooperl\DB2\Database\Query\Processors;
|
||||||
|
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
use Illuminate\Database\Query\Processors\Processor;
|
use Illuminate\Database\Query\Processors\Processor;
|
||||||
use Cooperl\Database\DB2\Query\Grammars\DB2Grammar;
|
use Cooperl\DB2\Database\Query\Grammars\DB2Grammar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DB2Processor
|
* Class DB2Processor
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Query\Processors
|
* @package Cooperl\DB2\Database\Query\Processors
|
||||||
*/
|
*/
|
||||||
class DB2Processor extends Processor
|
class DB2Processor extends Processor
|
||||||
{
|
{
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Query\Processors;
|
namespace Cooperl\DB2\Database\Query\Processors;
|
||||||
|
|
||||||
use Illuminate\Database\Query\Builder;
|
use Illuminate\Database\Query\Builder;
|
||||||
use Illuminate\Database\Query\Processors\Processor;
|
use Illuminate\Database\Query\Processors\Processor;
|
||||||
use Cooperl\Database\DB2\Query\Grammars\DB2Grammar;
|
use Cooperl\DB2\Database\Query\Grammars\DB2Grammar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class DB2ZOSProcessor
|
* Class DB2ZOSProcessor
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Query\Processors
|
* @package Cooperl\DB2\Database\Query\Processors
|
||||||
*/
|
*/
|
||||||
class DB2ZOSProcessor extends Processor
|
class DB2ZOSProcessor extends Processor
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Schema;
|
namespace Cooperl\DB2\Database\Schema;
|
||||||
|
|
||||||
use Illuminate\Database\Connection;
|
use Illuminate\Database\Connection;
|
||||||
use Illuminate\Database\Schema\Grammars\Grammar;
|
use Illuminate\Database\Schema\Grammars\Grammar;
|
||||||
@ -8,7 +8,7 @@ use Illuminate\Database\Schema\Grammars\Grammar;
|
|||||||
/**
|
/**
|
||||||
* Class Blueprint
|
* Class Blueprint
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Schema
|
* @package Cooperl\DB2\Database\Schema
|
||||||
*/
|
*/
|
||||||
class Blueprint extends \Illuminate\Database\Schema\Blueprint
|
class Blueprint extends \Illuminate\Database\Schema\Blueprint
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Schema;
|
namespace Cooperl\DB2\Database\Schema;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
@ -8,7 +8,7 @@ use Illuminate\Database\Schema\Blueprint;
|
|||||||
/**
|
/**
|
||||||
* Class Builder
|
* Class Builder
|
||||||
*
|
*
|
||||||
* @package Cooperl\Database\DB2\Schema
|
* @package Cooperl\DB2\Database\Schema
|
||||||
*/
|
*/
|
||||||
class Builder extends \Illuminate\Database\Schema\Builder
|
class Builder extends \Illuminate\Database\Schema\Builder
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ class Builder extends \Illuminate\Database\Schema\Builder
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @param \Closure $callback
|
* @param \Closure $callback
|
||||||
*
|
*
|
||||||
* @return \Cooperl\Database\DB2\Schema\Blueprint
|
* @return \Cooperl\DB2\Database\Schema\Blueprint
|
||||||
*/
|
*/
|
||||||
protected function createBlueprint($table, Closure $callback = null)
|
protected function createBlueprint($table, Closure $callback = null)
|
||||||
{
|
{
|
||||||
@ -84,6 +84,6 @@ class Builder extends \Illuminate\Database\Schema\Builder
|
|||||||
return call_user_func($this->resolver, $table, $callback);
|
return call_user_func($this->resolver, $table, $callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new \Cooperl\Database\DB2\Schema\Blueprint($table, $callback);
|
return new \Cooperl\DB2\Database\Schema\Blueprint($table, $callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Schema\Grammars;
|
namespace Cooperl\DB2\Database\Schema\Grammars;
|
||||||
|
|
||||||
use Illuminate\Database\Query\Expression;
|
|
||||||
use Illuminate\Support\Fluent;
|
|
||||||
use Illuminate\Database\Connection;
|
|
||||||
use Illuminate\Database\Schema\Grammars\Grammar;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
|
|
||||||
class DB2ExpressCGrammar extends DB2Grammar
|
class DB2ExpressCGrammar extends DB2Grammar
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Cooperl\Database\DB2\Schema\Grammars;
|
namespace Cooperl\DB2\Database\Schema\Grammars;
|
||||||
|
|
||||||
use Illuminate\Database\Query\Expression;
|
use Illuminate\Database\Query\Expression;
|
||||||
use Illuminate\Support\Fluent;
|
use Illuminate\Support\Fluent;
|
24
src/Queue/DB2Connector.php
Normal file
24
src/Queue/DB2Connector.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Cooperl\DB2\Queue;
|
||||||
|
|
||||||
|
use Illuminate\Queue\Connectors\DatabaseConnector;
|
||||||
|
|
||||||
|
class DB2Connector extends DatabaseConnector
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Establish a queue connection.
|
||||||
|
*
|
||||||
|
* @param array $config
|
||||||
|
* @return \Illuminate\Contracts\Queue\Queue
|
||||||
|
*/
|
||||||
|
public function connect(array $config)
|
||||||
|
{
|
||||||
|
return new DB2Queue(
|
||||||
|
$this->connections->connection($config['connection'] ?? null),
|
||||||
|
$config['table'],
|
||||||
|
$config['queue'],
|
||||||
|
$config['retry_after'] ?? 60
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
18
src/Queue/DB2Queue.php
Normal file
18
src/Queue/DB2Queue.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Cooperl\DB2\Queue;
|
||||||
|
|
||||||
|
use Illuminate\Queue\DatabaseQueue;
|
||||||
|
|
||||||
|
class DB2Queue extends DatabaseQueue
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getLockForPopping()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user