-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #83 allow a node to join an existing cluster
- Loading branch information
1 parent
012785c
commit 373e15d
Showing
25 changed files
with
380 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace ApiNodes\Models; | ||
|
||
use ApiNodes\Models\AgentStartedEventData\SwarmData; | ||
use App\Models\NodeData; | ||
use Spatie\LaravelData\Data; | ||
|
||
class AgentStartedEventData extends Data | ||
{ | ||
public function __construct( | ||
public NodeData $node, | ||
public ?SwarmData $swarm, | ||
) | ||
{ | ||
|
||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace ApiNodes\Models\AgentStartedEventData; | ||
|
||
use App\Models\SwarmData\JoinTokens; | ||
use App\Models\SwarmData\ManagerNode; | ||
use Spatie\LaravelData\Attributes\DataCollectionOf; | ||
use Spatie\LaravelData\Data; | ||
|
||
class SwarmData extends Data | ||
{ | ||
public function __construct( | ||
public JoinTokens $joinTokens, | ||
#[DataCollectionOf(ManagerNode::class)] | ||
/* @var ManagerNode[] */ | ||
public array $managerNodes, | ||
) | ||
{ | ||
|
||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\JoinSwarm; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class JoinSwarmCompleted extends BaseTaskEvent | ||
{ | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\JoinSwarm; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class JoinSwarmFailed extends BaseTaskEvent | ||
{ | ||
} |
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
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,23 @@ | ||
<?php | ||
|
||
namespace App\Http\Requests\NodeTask; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
class JoinClusterFormRequest extends FormRequest | ||
{ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return [ | ||
'node_id' => ['required', 'exists:nodes,id'], | ||
'swarm_id' => ['required', 'exists:swarms,id'], | ||
'role' => ['required', 'in:manager,worker'], | ||
'advertise_addr' => ['exclude_if:role,worker', 'required', 'ipv4'], | ||
]; | ||
} | ||
} |
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
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,9 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeData; | ||
|
||
enum NodeRole: string | ||
{ | ||
case Manager = 'manager'; | ||
case Worker = 'worker'; | ||
} |
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
Oops, something went wrong.