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

Pass nodes to Configuration instead of Manager #120

Merged
merged 4 commits into from
Feb 13, 2021

Conversation

meling
Copy link
Member

@meling meling commented Feb 12, 2021

This PR allows nodes to be passed to NewConfiguration instead of adding it to the manager first, and then adding it to the configuration. This makes it more intuitive and it also becomes easier to create new configurations from existing ones. We can now also compare two configurations via a new Equal method.

We provide tree ways to add nodes to NewConfiguration:

  • WithNodeList: provide a list of string endpoints; IDs are assigned.
  • WithNodeMap: provide a map of string endpoints to IDs; used for application defined IDs.
  • WithNodeIDs: provide a list of node IDs for the new configuration; these IDs must already have been added via one of the other options.

Also worth noting is that NewManager no longer returns an error, avoiding error handling until NewConfiguration is called.

Fixes #30.

This is a major redesign of how we pass node lists and node maps
to the system. This now happens only through the creation of a
new configuration, but still using the WithNodeList and WithNodeMap
options. These can no longer be passed to the manager. The manager
still keeps the pool of all nodes in all configurations. A benefit
from this change is that the manager can no longer fail with an error.

As this is a relatively major change, and there were fair amount
of usage examples that had to be updated, this also required a bit
of associated clean up.

When this rewrite was more or less finished I realized that we could
also provide WithNodeIDs, which could have avoided many of the
tricky rewrites. I plan to add WithNodeIDs in a follow up commit.

Fixes #30.
This adds a WithNodeIDs option for the NewConfiguration function.
This can be handy when creating a new configuration from a previous one.

The Equal method on the Configuration type is handy for comparing
two configurations, and also allows using the cmp package for
comparing stuff.
@johningve
Copy link
Member

@meling can you regenerate template_static.go to update the comment from the last commit?

@meling
Copy link
Member Author

meling commented Feb 13, 2021

@meling can you regenerate template_static.go to update the comment from the last commit?

Done. It is ready to be reviewed, I guess. The caveat with this one is that it impacts the APIs, but I think now is the time to fix this, rather than later, when we have made a proper release.

@meling meling merged commit f04667f into master Feb 13, 2021
@meling meling deleted the pass-nodes-to-config-instead-of-manager branch February 13, 2021 12:57
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.

Allow adding new nodes on the fly
2 participants