Skip to content

Commit

Permalink
Support running a source function based on a class-string
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasnetau committed Oct 25, 2024
1 parent d81978e commit 28e9958
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
use function hrtime;
use function in_array;
use function is_array;
use function is_string;
use function is_subclass_of;
use function max;
use function memory_get_peak_usage;
use function number_format;
Expand Down Expand Up @@ -321,7 +323,7 @@ public function initialise_input_processes() : void {

public function initialise_input_process(int|string $id) : Process|SourceFunction {
$config = $this->input_processes_config[$id];
if ($config['cmd'] instanceof SourceFunction) {
if (is_subclass_of($config['cmd'], SourceFunction::class)) {
return $this->setup_source_function($id);
} else {
return $this->start_input_process($id);
Expand All @@ -331,7 +333,7 @@ public function initialise_input_process(int|string $id) : Process|SourceFunctio
public function setup_source_function(int|string $id): SourceFunction
{
$config = $this->input_processes_config[$id];
$cmd = clone $config['cmd'];
$cmd = is_string($config['cmd']) ? new $config['cmd']() : clone $config['cmd'];
$env = $config['env'];

$this->input_processes[$id] = $cmd;
Expand Down

0 comments on commit 28e9958

Please sign in to comment.