-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Rules to trigger the running of source process/function in resp…
…onse to an event (for example running a source process that loads historical data as an event for the Rule)
- Loading branch information
1 parent
d7982d5
commit 677d0f8
Showing
3 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the PHP Event Correlation package. | ||
* | ||
* (c) James Lucas <james@lucas.net.au> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace EdgeTelemetrics\EventCorrelation\Scheduler\Messages; | ||
|
||
use EdgeTelemetrics\EventCorrelation\Event; | ||
use JsonSerializable; | ||
|
||
/** | ||
* Class Action | ||
* @package EdgeTelemetrics\EventCorrelation | ||
*/ | ||
class ExecuteSource implements JsonSerializable { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $cmd; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected array $vars; | ||
|
||
/** | ||
* Action constructor. | ||
* @param string $cmd | ||
* @param array|Event $vars | ||
*/ | ||
public function __construct(string $cmd, Event|array $vars) | ||
{ | ||
$this->cmd = $cmd; | ||
if ($vars instanceof Event) { | ||
$this->vars = $vars->toArray(); | ||
} else { | ||
$this->vars = $vars; | ||
} | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function jsonSerialize() : array | ||
{ | ||
return [ | ||
'cmd' => $this->cmd, | ||
'vars' => $this->vars | ||
]; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCmd() : string | ||
{ | ||
return $this->cmd; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getVars() : array | ||
{ | ||
return $this->vars; | ||
} | ||
} |