PHP code example of grupo-cometa / client-orchestrator
1. Go to this page and download the library: Download grupo-cometa/client-orchestrator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grupo-cometa / client-orchestrator example snippets
use GrupoCometa\ClientOrchestrator\Commands\Register;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__ . '/../routes/web.php',
commands: __DIR__ . '/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})
->withCommands([
...Register::commands() // registra os commandos.
])
->create();
~~~
## Criando um config.
Na raiz de seu projeto laravel em config, adicionar o arquivo **orchestrator.php**
~~~php
return [
'orchestratorUrl'=> env('ORCHESTRATOR_URL'),
'ssoUsername' => env('SSO_USERNAME'),
'ssoPassword' => env('SSO_PASSWORD'),
'ssoClientId' => env('SSO_CLIENT_ID'),
'ssoUrl' => env('SSO_URL'),
'wsUrl' => env('WEBSOCKET_URL'),
'rabbitmqHost' => env('AMQP_HOST'),
'rabbitmqPort' => env('AMQP_PORT'),
'rabbitmqUser' => env('AMQP_USERNAME'),
'rabbitmqPassword' => env('AMQP_PASSWORD'),
];
~~~
Em projetos Lumen é necessário realizar o registro do seu config em **app/bootstrap/app.php** como na linha abaixo
~~~php
$app->configure('orchestrator');
~~~
## Criando um Automation
Para implementar uma automação que possa ser monitoradora pelo orquestrador basta criar um class em app\Orchestrator (diretório padrao, pode ser alterado add uma key 'namespace' => 'App\MyBaseNamespace' no config conforme passo a cima) que extenda a abstract class **GrupoCometa\ClientOrchestrator\AbstractAutomation**
Exemplo criado no diretorio padrão: app\Orchestrator\AutomationTeste.php
~~~php
namespace App\Orchestrator;
use GrupoCometa\ClientOrchestrator\AbstractAutomation;
class AutomationTeste extends AbstractAutomation
{
public function publicId(): string
{
return "ca432bbc-0b72-4b07-8848-f0f2761c15e5";
}
public function start()
{
$this->log->success('Automation teste start sucess', date('Y-m-d H:i:s'));
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.