Refactored \Tamer to \TamerLib
This commit is contained in:
parent
1b8d2fb40a
commit
7eea383ce9
25 changed files with 81 additions and 81 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Abstracts\ExitCodes;
|
namespace TamerLib\Abstracts\ExitCodes;
|
||||||
|
|
||||||
class WorkerExitCodes
|
class WorkerExitCodes
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Abstracts;
|
namespace TamerLib\Abstracts;
|
||||||
|
|
||||||
abstract class JobStatus
|
abstract class JobStatus
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Abstracts;
|
namespace TamerLib\Abstracts;
|
||||||
|
|
||||||
abstract class Mode
|
abstract class Mode
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Abstracts;
|
namespace TamerLib\Abstracts;
|
||||||
|
|
||||||
abstract class ProtocolType
|
abstract class ProtocolType
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Abstracts;
|
namespace TamerLib\Abstracts;
|
||||||
|
|
||||||
abstract class TaskPriority
|
abstract class TaskPriority
|
||||||
{
|
{
|
|
@ -1,14 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Classes;
|
namespace TamerLib\Classes;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use OptsLib\Parse;
|
use OptsLib\Parse;
|
||||||
use Symfony\Component\Process\PhpExecutableFinder;
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
use Tamer\Abstracts\ProtocolType;
|
use TamerLib\Abstracts\ProtocolType;
|
||||||
use Tamer\Interfaces\ClientProtocolInterface;
|
use TamerLib\Interfaces\ClientProtocolInterface;
|
||||||
use Tamer\Interfaces\WorkerProtocolInterface;
|
use TamerLib\Interfaces\WorkerProtocolInterface;
|
||||||
|
|
||||||
class Functions
|
class Functions
|
||||||
{
|
{
|
||||||
|
@ -60,8 +60,8 @@
|
||||||
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
||||||
return match (strtolower($protocol))
|
return match (strtolower($protocol))
|
||||||
{
|
{
|
||||||
ProtocolType::Gearman => new \Tamer\Protocols\Gearman\Client($username, $password),
|
ProtocolType::Gearman => new \TamerLib\Protocols\Gearman\Client($username, $password),
|
||||||
ProtocolType::RabbitMQ => new \Tamer\Protocols\RabbitMq\Client($username, $password),
|
ProtocolType::RabbitMQ => new \TamerLib\Protocols\RabbitMq\Client($username, $password),
|
||||||
default => throw new InvalidArgumentException('Invalid protocol type'),
|
default => throw new InvalidArgumentException('Invalid protocol type'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -77,8 +77,8 @@
|
||||||
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
||||||
return match (strtolower($protocol))
|
return match (strtolower($protocol))
|
||||||
{
|
{
|
||||||
ProtocolType::Gearman => new \Tamer\Protocols\Gearman\Worker($username, $password),
|
ProtocolType::Gearman => new \TamerLib\Protocols\Gearman\Worker($username, $password),
|
||||||
ProtocolType::RabbitMQ => new \Tamer\Protocols\RabbitMq\Worker($username, $password),
|
ProtocolType::RabbitMQ => new \TamerLib\Protocols\RabbitMq\Worker($username, $password),
|
||||||
default => throw new InvalidArgumentException('Invalid protocol type'),
|
default => throw new InvalidArgumentException('Invalid protocol type'),
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Classes;
|
namespace TamerLib\Classes;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use LogLib\Log;
|
use LogLib\Log;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Tamer\Objects\WorkerInstance;
|
use TamerLib\Objects\WorkerInstance;
|
||||||
|
|
||||||
class Supervisor
|
class Supervisor
|
||||||
{
|
{
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Classes;
|
namespace TamerLib\Classes;
|
||||||
|
|
||||||
use Tamer\Abstracts\Mode;
|
use TamerLib\Abstracts\Mode;
|
||||||
use Tamer\Abstracts\ProtocolType;
|
use TamerLib\Abstracts\ProtocolType;
|
||||||
use Tamer\Abstracts\TaskPriority;
|
use TamerLib\Abstracts\TaskPriority;
|
||||||
|
|
||||||
class Validate
|
class Validate
|
||||||
{
|
{
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Exceptions;
|
namespace TamerLib\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Throwable;
|
use Throwable;
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Exceptions;
|
namespace TamerLib\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Throwable;
|
use Throwable;
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Interfaces;
|
namespace TamerLib\Interfaces;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Tamer\Exceptions\ConnectionException;
|
use TamerLib\Exceptions\ConnectionException;
|
||||||
use Tamer\Objects\Task;
|
use TamerLib\Objects\Task;
|
||||||
|
|
||||||
interface ClientProtocolInterface
|
interface ClientProtocolInterface
|
||||||
{
|
{
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Tamer\Interfaces;
|
namespace TamerLib\Interfaces;
|
||||||
|
|
||||||
use Tamer\Exceptions\ConnectionException;
|
use TamerLib\Exceptions\ConnectionException;
|
||||||
|
|
||||||
interface WorkerProtocolInterface
|
interface WorkerProtocolInterface
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Objects;
|
namespace TamerLib\Objects;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Opis\Closure\SerializableClosure;
|
use Opis\Closure\SerializableClosure;
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Objects;
|
namespace TamerLib\Objects;
|
||||||
|
|
||||||
use Tamer\Abstracts\JobStatus;
|
use TamerLib\Abstracts\JobStatus;
|
||||||
|
|
||||||
class JobResults
|
class JobResults
|
||||||
{
|
{
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Objects;
|
namespace TamerLib\Objects;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Tamer\Abstracts\TaskPriority;
|
use TamerLib\Abstracts\TaskPriority;
|
||||||
use Tamer\Classes\Validate;
|
use TamerLib\Classes\Validate;
|
||||||
|
|
||||||
class Task
|
class Task
|
||||||
{
|
{
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Objects;
|
namespace TamerLib\Objects;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use LogLib\Log;
|
use LogLib\Log;
|
||||||
use Symfony\Component\Process\Process;
|
use Symfony\Component\Process\Process;
|
||||||
use Tamer\Classes\Functions;
|
use TamerLib\Classes\Functions;
|
||||||
|
|
||||||
class WorkerInstance
|
class WorkerInstance
|
||||||
{
|
{
|
|
@ -3,11 +3,11 @@
|
||||||
require 'ncc';
|
require 'ncc';
|
||||||
import('net.nosial.tamerlib', 'latest');
|
import('net.nosial.tamerlib', 'latest');
|
||||||
|
|
||||||
\Tamer\Tamer::initWorker();
|
\TamerLib\Tamer::initWorker();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
\Tamer\Tamer::work();
|
\TamerLib\Tamer::work();
|
||||||
}
|
}
|
||||||
catch(\Exception $e)
|
catch(\Exception $e)
|
||||||
{
|
{
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Protocols\Gearman;
|
namespace TamerLib\Protocols\Gearman;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GearmanClient;
|
use GearmanClient;
|
||||||
use GearmanTask;
|
use GearmanTask;
|
||||||
use LogLib\Log;
|
use LogLib\Log;
|
||||||
use Tamer\Abstracts\TaskPriority;
|
use TamerLib\Abstracts\TaskPriority;
|
||||||
use Tamer\Exceptions\ConnectionException;
|
use TamerLib\Exceptions\ConnectionException;
|
||||||
use Tamer\Interfaces\ClientProtocolInterface;
|
use TamerLib\Interfaces\ClientProtocolInterface;
|
||||||
use Tamer\Objects\Job;
|
use TamerLib\Objects\Job;
|
||||||
use Tamer\Objects\JobResults;
|
use TamerLib\Objects\JobResults;
|
||||||
use Tamer\Objects\Task;
|
use TamerLib\Objects\Task;
|
||||||
|
|
||||||
class Client implements ClientProtocolInterface
|
class Client implements ClientProtocolInterface
|
||||||
{
|
{
|
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Protocols\Gearman;
|
namespace TamerLib\Protocols\Gearman;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use GearmanJob;
|
use GearmanJob;
|
||||||
use GearmanWorker;
|
use GearmanWorker;
|
||||||
use LogLib\Log;
|
use LogLib\Log;
|
||||||
use Opis\Closure\SerializableClosure;
|
use Opis\Closure\SerializableClosure;
|
||||||
use Tamer\Abstracts\JobStatus;
|
use TamerLib\Abstracts\JobStatus;
|
||||||
use Tamer\Exceptions\ConnectionException;
|
use TamerLib\Exceptions\ConnectionException;
|
||||||
use Tamer\Interfaces\WorkerProtocolInterface;
|
use TamerLib\Interfaces\WorkerProtocolInterface;
|
||||||
use Tamer\Objects\Job;
|
use TamerLib\Objects\Job;
|
||||||
use Tamer\Objects\JobResults;
|
use TamerLib\Objects\JobResults;
|
||||||
|
|
||||||
class Worker implements WorkerProtocolInterface
|
class Worker implements WorkerProtocolInterface
|
||||||
{
|
{
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Protocols\RabbitMq;
|
namespace TamerLib\Protocols\RabbitMq;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use PhpAmqpLib\Channel\AMQPChannel;
|
use PhpAmqpLib\Channel\AMQPChannel;
|
||||||
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
||||||
use PhpAmqpLib\Message\AMQPMessage;
|
use PhpAmqpLib\Message\AMQPMessage;
|
||||||
use Tamer\Abstracts\TaskPriority;
|
use TamerLib\Abstracts\TaskPriority;
|
||||||
use Tamer\Exceptions\ServerException;
|
use TamerLib\Exceptions\ServerException;
|
||||||
use Tamer\Interfaces\ClientProtocolInterface;
|
use TamerLib\Interfaces\ClientProtocolInterface;
|
||||||
use Tamer\Objects\Job;
|
use TamerLib\Objects\Job;
|
||||||
use Tamer\Objects\JobResults;
|
use TamerLib\Objects\JobResults;
|
||||||
use Tamer\Objects\Task;
|
use TamerLib\Objects\Task;
|
||||||
|
|
||||||
class Client implements ClientProtocolInterface
|
class Client implements ClientProtocolInterface
|
||||||
{
|
{
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer\Protocols\RabbitMq;
|
namespace TamerLib\Protocols\RabbitMq;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use PhpAmqpLib\Channel\AMQPChannel;
|
use PhpAmqpLib\Channel\AMQPChannel;
|
||||||
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
use PhpAmqpLib\Connection\AMQPStreamConnection;
|
||||||
use PhpAmqpLib\Message\AMQPMessage;
|
use PhpAmqpLib\Message\AMQPMessage;
|
||||||
use Tamer\Abstracts\JobStatus;
|
use TamerLib\Abstracts\JobStatus;
|
||||||
use Tamer\Interfaces\WorkerProtocolInterface;
|
use TamerLib\Interfaces\WorkerProtocolInterface;
|
||||||
use Tamer\Objects\Job;
|
use TamerLib\Objects\Job;
|
||||||
use Tamer\Objects\JobResults;
|
use TamerLib\Objects\JobResults;
|
||||||
|
|
||||||
class Worker implements WorkerProtocolInterface
|
class Worker implements WorkerProtocolInterface
|
||||||
{
|
{
|
|
@ -2,20 +2,20 @@
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
/** @noinspection PhpMissingFieldTypeInspection */
|
||||||
|
|
||||||
namespace Tamer;
|
namespace TamerLib;
|
||||||
|
|
||||||
use Closure;
|
use Closure;
|
||||||
use Exception;
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Tamer\Abstracts\Mode;
|
use TamerLib\Abstracts\Mode;
|
||||||
use Tamer\Classes\Functions;
|
use TamerLib\Classes\Functions;
|
||||||
use Tamer\Classes\Supervisor;
|
use TamerLib\Classes\Supervisor;
|
||||||
use Tamer\Classes\Validate;
|
use TamerLib\Classes\Validate;
|
||||||
use Tamer\Exceptions\ConnectionException;
|
use TamerLib\Exceptions\ConnectionException;
|
||||||
use Tamer\Exceptions\UnsupervisedWorkerException;
|
use TamerLib\Exceptions\UnsupervisedWorkerException;
|
||||||
use Tamer\Interfaces\ClientProtocolInterface;
|
use TamerLib\Interfaces\ClientProtocolInterface;
|
||||||
use Tamer\Interfaces\WorkerProtocolInterface;
|
use TamerLib\Interfaces\WorkerProtocolInterface;
|
||||||
use Tamer\Objects\Task;
|
use TamerLib\Objects\Task;
|
||||||
|
|
||||||
class Tamer
|
class Tamer
|
||||||
{
|
{
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use Tamer\Abstracts\ProtocolType;
|
use TamerLib\Abstracts\ProtocolType;
|
||||||
use Tamer\Tamer;
|
use TamerLib\Tamer;
|
||||||
|
|
||||||
require 'ncc';
|
require 'ncc';
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Tamer\Abstracts\ProtocolType;
|
use TamerLib\Abstracts\ProtocolType;
|
||||||
use Tamer\Objects\JobResults;
|
use TamerLib\Objects\JobResults;
|
||||||
use Tamer\Objects\Task;
|
use TamerLib\Objects\Task;
|
||||||
use Tamer\Tamer;
|
use TamerLib\Tamer;
|
||||||
|
|
||||||
require 'ncc';
|
require 'ncc';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Tamer\Abstracts\Mode;
|
use TamerLib\Abstracts\Mode;
|
||||||
use Tamer\Abstracts\ProtocolType;
|
use TamerLib\Abstracts\ProtocolType;
|
||||||
use Tamer\Tamer;
|
use TamerLib\Tamer;
|
||||||
|
|
||||||
require 'ncc';
|
require 'ncc';
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
Tamer::initWorker();
|
Tamer::initWorker();
|
||||||
|
|
||||||
Tamer::addFunction('sleep', function(\Tamer\Objects\Job $job) {
|
Tamer::addFunction('sleep', function(\TamerLib\Objects\Job $job) {
|
||||||
sleep($job->getData());
|
sleep($job->getData());
|
||||||
return $job->getData();
|
return $job->getData();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue