Skip to content

Simplify Run syntax #39

@nleiva

Description

@nleiva

Follow up from #37 (comment)

The metadata or descriptions are not too relevant for the actual execution.

For pre-defined tasks (like SSHClose) I propose we provide a default description (the user can change it). The user can also create its own tasks:

type SSHOpen struct {
	description string
}

type SSHClose struct {
	description string
}

type MyTask struct {
	description string
}

func NewSSHOpen() SSHOpen {
	return SSHOpen{
		description: "Open SSH connection",
	}

}

func NewSSHClose() SSHClose {
	return SSHClose{
		description: "Close SSH connection",
	}

}

The goal is the user program at very high level looks something like (MyTask in the same connection package for simplicity in this example):

func main() {
	...
	sshOpen := connection.NewSSHOpen()
	sshClose := connection.NewSSHClose()
	myTask := connection.MyTask{description: "Something else"}
	
	gr.RunSync(sshOpen)
	defer gr.RunSync(sshClose)
	gr.RunSync(myTask)

	fmt.Println("Doing this:", sshOpen.description, myTask.description, sshClose.description)
	...

}

The user creates tasks that are then executed in single lines.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions