Brought everything back into working condition.

Also updated all copyright notices.
This commit is contained in:
Abel Hoogeveen 2020-01-28 11:46:14 +01:00
parent 4d61e84ad6
commit bcbb7535b1
No known key found for this signature in database
GPG Key ID: 96C2234920BF4292
20 changed files with 232 additions and 176 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
composer.phar
composer.lock
.idea/
log/
vendor/

25
composer.json Normal file
View File

@ -0,0 +1,25 @@
{
"name": "fuzeworks/async",
"description": "FuzeWorks Async task execution library",
"license": ["MIT"],
"authors": [
{
"name": "TechFuze",
"homepage": "https://techfuze.net"
},
{
"name": "FuzeWorks Community",
"homepage": "https://techfuze.net/fuzeworks/contributors"
}
],
"require": {
"php": ">=7.2.0",
"fuzeworks/core": "~1.2.0",
"ext-json": "*"
},
"autoload": {
"psr-4": {
"FuzeWorks\\Async\\": "src/FuzeWorks/Async"
}
}
}

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,13 +25,13 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
return array(
'SuperVisor' => [
@ -48,6 +48,6 @@ return array(
'type' => 'ShellExecutor',
// For ShellExecutor, first parameter is the file location of the worker script
'parameters' => [dirname(dirname(__DIR__)) . DS . 'worker.php']
'parameters' => [dirname(__FILE__) . DS . 'worker.php']
]
);

63
createTask.php Normal file
View File

@ -0,0 +1,63 @@
<?php
/**
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2020 TechFuze
*
* 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.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.0.0
*
* @version Version 1.0.0
*/
use FuzeWorks\Async\Tasks;
use FuzeWorks\Logger;
require_once('vendor/autoload.php');
// Open configurator
$configurator = new FuzeWorks\Configurator();
// Set up basic settings
$configurator->setTimeZone('Europe/Amsterdam');
$configurator->setTempDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'temp');
$configurator->setLogDirectory(dirname(__FILE__). DIRECTORY_SEPARATOR . 'log');
// Add Async library
$configurator->deferComponentClassMethod('libraries', 'addLibraryClass', null, 'async', '\FuzeWorks\Async\Tasks');
// Debug
$configurator->enableDebugMode()->setDebugAddress('ALL');
// Create container
$container = $configurator->createContainer();
// Add lib
Logger::enableScreenLog();
// RUN THE APP
/** @var Tasks $lib */
$lib = $container->libraries->get('async');

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,17 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
interface Constraint
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,17 +25,17 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks\Events;
use Application\Library\Tasks\Task;
namespace FuzeWorks\Async\Events;
use FuzeWorks\Async\Task;
use FuzeWorks\Event;
class TaskHandleEvent extends Event

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,17 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
interface Executor
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,19 +25,19 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks\Executors;
use Application\Library\Tasks\Executor;
use Application\Library\Tasks\Task;
use Application\Library\Tasks\TasksException;
namespace FuzeWorks\Async\Executors;
use FuzeWorks\Async\Executor;
use FuzeWorks\Async\Task;
use FuzeWorks\Async\TasksException;
class ShellExecutor implements Executor
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,16 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
interface Handler
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,16 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
interface SuperVisor

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,21 +25,21 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks\Supervisors;
use Application\Library\Tasks\Executor;
use Application\Library\Tasks\SuperVisor;
use Application\Library\Tasks\Task;
use Application\Library\Tasks\TasksException;
use Application\Library\Tasks\TaskStorage;
namespace FuzeWorks\Async\Supervisors;
use FuzeWorks\Async\Executor;
use FuzeWorks\Async\SuperVisor;
use FuzeWorks\Async\Task;
use FuzeWorks\Async\TasksException;
use FuzeWorks\Async\TaskStorage;
class ParallelSuperVisor implements SuperVisor
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,16 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
class Task
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,16 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
class TaskFailException extends TasksException
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,16 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
interface TaskStorage
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,19 +25,19 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks\TaskStorage;
use Application\Library\Tasks\Task;
use Application\Library\Tasks\TasksException;
use Application\Library\Tasks\TaskStorage;
namespace FuzeWorks\Async\TaskStorage;
use FuzeWorks\Async\Task;
use FuzeWorks\Async\TasksException;
use FuzeWorks\Async\TaskStorage;
class ArrayTaskStorage implements TaskStorage
{

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,25 +25,18 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library;
use Application\Library\Tasks\Executor;
use Application\Library\Tasks\SuperVisor;
use Application\Library\Tasks\Task;
use Application\Library\Tasks\TasksException;
use Application\Library\Tasks\TaskStorage;
use Application\Library\Tasks\Worker;
namespace FuzeWorks\Async;
use FuzeWorks\Config;
use FuzeWorks\ConfigORM\ConfigORM;
use FuzeWorks\Events;
use FuzeWorks\Exception\Exception;
use FuzeWorks\Factory;
use FuzeWorks\iLibrary;
@ -66,7 +59,7 @@ class Tasks implements iLibrary
{
/** @var Config $config */
$config = Factory::getInstance('config');
$config->addComponentPath(dirname(__FILE__), Priority::LOW);
$config->addComponentPath(dirname(__FILE__, 4), Priority::LOW);
$this->cfg = $config->getConfig('tasks');
}
@ -87,7 +80,7 @@ class Tasks implements iLibrary
public function getSuperVisor(): SuperVisor
{
$cfg = $this->cfg->get('SuperVisor');
$class = 'Application\Library\Tasks\Supervisors\\' . $cfg['type'];
$class = 'FuzeWorks\Async\Supervisors\\' . $cfg['type'];
$parameters = isset($cfg['parameters']) && is_array($cfg['parameters']) ? $cfg['parameters'] : [];
array_unshift($parameters, $this->getTaskStorage(), $this->getExecutor());
if (!class_exists($class, true))
@ -118,7 +111,7 @@ class Tasks implements iLibrary
public function getTaskStorage(): TaskStorage
{
$cfg = $this->cfg->get('TaskStorage');
$class = 'Application\Library\Tasks\TaskStorage\\' . $cfg['type'];
$class = 'FuzeWorks\Async\TaskStorage\\' . $cfg['type'];
$parameters = isset($cfg['parameters']) && is_array($cfg['parameters']) ? $cfg['parameters'] : [];
if (!class_exists($class, true))
throw new TasksException("Could not get TaskStorage. Type of '$class' not found.");
@ -139,7 +132,7 @@ class Tasks implements iLibrary
protected function getExecutor(): Executor
{
$cfg = $this->cfg->get('Executor');
$class = 'Application\Library\Tasks\Executors\\' . $cfg['type'];
$class = 'FuzeWorks\Async\Executors\\' . $cfg['type'];
$parameters = isset($cfg['parameters']) && is_array($cfg['parameters']) ? $cfg['parameters'] : [];
if (!class_exists($class, true))
throw new TasksException("Could not get Executor. Type of '$class' not found.");
@ -156,7 +149,7 @@ class Tasks implements iLibrary
*/
public function getClassesPrefix(): ?string
{
return '\Application\Library\Tasks';
return null;
}
/**
@ -164,6 +157,6 @@ class Tasks implements iLibrary
*/
public function getSourceDirectory(): ?string
{
return 'src';
return null;
}
}

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,16 +25,16 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
namespace FuzeWorks\Async;
use FuzeWorks\Exception\LibraryException;
class TasksException extends LibraryException

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks CLIComponent.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,17 +25,17 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 1.2.0
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
namespace Application\Library\Tasks;
use Application\Library\Tasks\Events\TaskHandleEvent;
namespace FuzeWorks\Async;
use FuzeWorks\Async\Events\TaskHandleEvent;
use FuzeWorks\Event\HaltExecutionEvent;
use FuzeWorks\Events;
use FuzeWorks\Exception\EventException;

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks Application Skeleton.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,58 +25,44 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 0.0.1
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
use Application\Library\Tasks;
use Application\Library\Tasks\Executors\ShellExecutor;
use Application\Library\Tasks\SuperVisor;
use Application\Library\Tasks\Supervisors\ParallelSuperVisor;
use Application\Library\Tasks\TaskStorage\ArrayTaskStorage;
use FuzeWorks\Async\SuperVisor;
use FuzeWorks\Async\Tasks;
use FuzeWorks\Logger;
use FuzeWorks\Priority;
use FuzeWorks\WebAppComponent;
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php');
require_once('vendor/autoload.php');
// Open configurator
$configurator = new FuzeWorks\Configurator();
// Set up basic settings
$configurator->setTimeZone('Europe/Amsterdam');
$configurator->setTempDirectory(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'temp');
$configurator->setLogDirectory(dirname(__DIR__). DIRECTORY_SEPARATOR . 'log');
$configurator->setTempDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'temp');
$configurator->setLogDirectory(dirname(__FILE__). DIRECTORY_SEPARATOR . 'log');
// Enable components
// WebComponent
$webAppComponent = new WebAppComponent();
$configurator->addComponent($webAppComponent);
// Add directories
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config', 'config', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Helper', 'helpers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Library', 'libraries', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Plugin', 'plugins', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Controller', 'controllers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View', 'views', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Model', 'models', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Layout', 'layouts', Priority::NORMAL);
// Add Async library
$configurator->deferComponentClassMethod('libraries', 'addLibraryClass', null, 'async', '\FuzeWorks\Async\Tasks');
// Debug
$configurator->enableDebugMode()->setDebugAddress('ALL');
// Create container
$container = $configurator->createContainer();
// Add lib
Logger::enableScreenLog();
// RUN THE APP
/** @var Tasks $lib */
$lib = $container->libraries->get('tasks');
$lib = $container->libraries->get('async');
$supervisor = $lib->getSuperVisor();
while ($supervisor->cycle() === SuperVisor::RUNNING) {

View File

@ -1,10 +1,10 @@
<?php
/**
* FuzeWorks Application Skeleton.
* FuzeWorks Async Library
*
* The FuzeWorks PHP FrameWork
*
* Copyright (C) 2013-2019 TechFuze
* Copyright (C) 2013-2020 TechFuze
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,48 +25,34 @@
* SOFTWARE.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2019, TechFuze. (http://techfuze.net)
* @copyright Copyright (c) 2013 - 2020, TechFuze. (http://techfuze.net)
* @license https://opensource.org/licenses/MIT MIT License
*
* @link http://techfuze.net/fuzeworks
* @since Version 0.0.1
* @since Version 1.0.0
*
* @version Version 1.2.0
* @version Version 1.0.0
*/
use FuzeWorks\Async\Tasks;
use Application\Library\Tasks;
use FuzeWorks\Priority;
use FuzeWorks\WebAppComponent;
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor/autoload.php');
require_once('vendor/autoload.php');
// Open configurator
$configurator = new FuzeWorks\Configurator();
// Set up basic settings
$configurator->setTimeZone('Europe/Amsterdam');
$configurator->setTempDirectory(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'temp');
$configurator->setLogDirectory(dirname(__DIR__). DIRECTORY_SEPARATOR . 'log');
$configurator->setTempDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'temp');
$configurator->setLogDirectory(dirname(__FILE__). DIRECTORY_SEPARATOR . 'log');
// Enable components
// WebComponent
$webAppComponent = new WebAppComponent();
$configurator->addComponent($webAppComponent);
// Add directories
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Config', 'config', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Helper', 'helpers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Library', 'libraries', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Plugin', 'plugins', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Controller', 'controllers', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'View', 'views', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Model', 'models', Priority::HIGH);
$configurator->addDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Layout', 'layouts', Priority::NORMAL);
// Add Async library
$configurator->deferComponentClassMethod('libraries', 'addLibraryClass', null, 'async', '\FuzeWorks\Async\Tasks');
// Debug
$configurator->enableDebugMode()->setDebugAddress('ALL');
// Create container
$container = $configurator->createContainer();
//\FuzeWorks\Logger::enableScreenLog();
// Prepare arguments
$script = array_shift($argv);
@ -77,6 +63,6 @@ $post = ($mode === 'post' ? true : false);
// RUN THE APP
/** @var Tasks $lib */
$lib = $container->libraries->get('tasks');
$lib = $container->libraries->get('async');
$worker = $lib->getWorker();
$worker->run($taskID, $post);