-
Notifications
You must be signed in to change notification settings - Fork 7
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
chore: simple in memory provisioning scheduler #2815
Conversation
} | ||
|
||
// next running or pending task. Nil if all tasks are done. | ||
func (d *Deployment) next() *Task { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use optional.Option
instead of nil to indicate existence.
Desired []*provisioner.Resource | ||
Existing []*provisioner.Resource | ||
// populated only when the task is done | ||
Output []*provisioner.Resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner if this wasn't public, and was instead returned by Progress()
once the task is complete?
) | ||
|
||
// Task is a unit of work for a deployment | ||
type Task struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should all these be public? Generally I think unless a type is purely data it's preferable to have private fields and a constructor, to make it very clear what is and isn't required at construction time.
} | ||
|
||
// ExtractResources from a module schema | ||
func ExtractResources(sch *schema.Module) ([]*provisioner.Resource, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
var result []*provisioner.Resource | ||
for _, decl := range sch.Decls { | ||
if db, ok := decl.(*schema.Database); ok { | ||
if db.Type == "postgres" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch?
if existing == nil { | ||
continue | ||
} | ||
if mysqlTo, ok := r.Resource.(*provisioner.Resource_Mysql); ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better pattern we can use here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very least this should be a type switch rather than a set of if/else
Rough domain model for provisioning deployments.
Task
is a single executable task to bring the infra from one state to anotherDeployment
is a list of sequentially executable tasksProvisioner
is an interface for calling provisioners, wrapping calls to provisioner pluginsThis is a WIP, and there are a lot of
TODO
s around, but I wanted to get this out to keep PRs small.