add main comments

This commit is contained in:
rmanach 2025-04-04 12:40:18 +02:00
parent bcb8c9c313
commit d609d4ea5b

13
main.go
View File

@ -55,6 +55,7 @@ func initLogger() {
log.Logger = log.With().Caller().Logger().Output(zerolog.ConsoleWriter{Out: os.Stderr})
}
// loadHMMap loads your instance configuration map from `$HOME/.homeserver` dir.
func loadHMMap() (models.HMMap, error) {
var hmmap models.HMMap
@ -80,6 +81,10 @@ func loadHMMap() (models.HMMap, error) {
return hmmap, nil
}
// initDeployers instanciates from `Project` and `HMMap` needed deployers and returns them.
//
// You can provide as an optional arg:
// - WithGlobalCancellation(fnCancel context.CancelFunc): close the global context, notifying all deployers to stop
func initDeployers(
ctx context.Context,
hmmap *models.HMMap,
@ -129,6 +134,9 @@ func initDeployers(
return []deployers.IDeployer{&sd, &nd}, nil
}
// generateTasksTree returns a list of linked `Task` to submit.
//
// It's here that all tasks are linked each other to provide the deployment ordering.
func generateTasksTree(deployers []deployers.IDeployer) ([]*scheduler.Task, error) {
if len(deployers) != MaxDeployers {
return nil, fmt.Errorf("%w, deployers len should be equals to 2", ErrGenerateTasksTree)
@ -149,9 +157,14 @@ func generateTasksTree(deployers []deployers.IDeployer) ([]*scheduler.Task, erro
swarmTask = scheduler.NewTask("swarm-build", sd.Build, swarmTask)
tasks = append(tasks, swarmTask, scheduler.NewTask("nginx-build", nd.Build))
return tasks, nil
}
// waitForCompletion waits for all deployers to complete.
//
// After the completion, deployers `Clear` methods are executed to clean all ressources.
// Then the scheduler is stopped to terminate the engine.
func waitForCompletion(deployers []deployers.IDeployer, s *scheduler.Scheduler) error {
var wg sync.WaitGroup