Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Run syntax #39

Open
nleiva opened this issue Jul 5, 2019 · 1 comment
Open

Simplify Run syntax #39

nleiva opened this issue Jul 5, 2019 · 1 comment

Comments

@nleiva
Copy link
Collaborator

nleiva commented Jul 5, 2019

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.

@dbarrosop
Copy link
Contributor

Not sure if this is the right way but I wanted to get rid of the JobParameters object and as a side effect I had to reconsider the "title". For now, I have moved it to the RenderResult as it's where it's being consumed but we may still want to be able to attach some metadata to the jobs:

b22aa1c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants