@@ 65-82 (lines=18) @@ | ||
62 | * @param Projector[] $projectors |
|
63 | * @throws Exception |
|
64 | */ |
|
65 | public function play(array $projectors): void |
|
66 | { |
|
67 | foreach ($projectors as $projector) { |
|
68 | $projectorState = $this->ledger->get($projector); |
|
69 | ||
70 | // Play only when projector is not halted or being processed by other agent |
|
71 | if ($projectorState->isHalted() || $projectorState->isProjecting()) { |
|
72 | continue; |
|
73 | } |
|
74 | ||
75 | // If it's not halted, it already ran. |
|
76 | if ($projectorState->projectorRunsFrom() === Projector::RUN_ONCE) { |
|
77 | continue; |
|
78 | } |
|
79 | ||
80 | $this->project($projector, $projectorState); |
|
81 | } |
|
82 | } |
|
83 | ||
84 | /** |
|
85 | * Boots provided list of projectors |
|
@@ 90-102 (lines=13) @@ | ||
87 | * @param Projector[] $projectors |
|
88 | * @throws Exception |
|
89 | */ |
|
90 | public function boot(array $projectors): void |
|
91 | { |
|
92 | foreach ($projectors as $projector) { |
|
93 | $projectorState = $this->ledger->get($projector); |
|
94 | ||
95 | // Play only when projector is not halted or being processed by other agent |
|
96 | if (!$projectorState->isHalted() || $projectorState->isProjecting()) { |
|
97 | continue; |
|
98 | } |
|
99 | ||
100 | $this->project($projector, $projectorState); |
|
101 | } |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * Retires provided list of projectors |