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

Introduce the ExecutorBuilder. #273

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

mlhamel
Copy link
Collaborator

@mlhamel mlhamel commented Jan 14, 2019

Why

It would be handy to generate executor from the task context: in the future by example we would be able to keep trace of every requested commands.

How

This PR is introducing a set of interfaces for the ExecutorBuilder but also the Executor itself.

Following PR will add the builder into the TaskContext

@mlhamel mlhamel requested a review from pior as a code owner January 14, 2019 02:40

// ExecutorBuilder build executor with specific program and args
type ExecutorBuilder interface {
NewExecutor(program string, args ...string) Executor
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or Simply New?

// ExecutorBuilder build executor with specific program and args
type ExecutorBuilder interface {
NewExecutor(program string, args ...string) Executor
NewShell(cmdline string) Executor
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or NewExecutorShell ?

package executor

type executorBuilderImpl struct {
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of keeping the struct private ?

executor.SetOutputPrefix("---")
result := executor.Run()
impl := executor.(*executorImpl)
impl.outputWriter = buf
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was searching for a better way but i cannot think of something

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for now. We could improve this by introducing a executor.SetOutputWriter(writer) at some point.

@pior
Copy link
Member

pior commented Jan 15, 2019

The Executor interface is great. Maybe we should try to ship this first?

I don't see the big picture about the builder interface... maybe this should be another PR, also including how we use this builder.

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

Successfully merging this pull request may close these issues.

2 participants