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

node/basic: add a basic NodePrototypeChooser #185

Closed
mvdan opened this issue Jun 4, 2021 · 0 comments
Closed

node/basic: add a basic NodePrototypeChooser #185

mvdan opened this issue Jun 4, 2021 · 0 comments

Comments

@mvdan
Copy link
Contributor

mvdan commented Jun 4, 2021

I keep seeing code like:

nodePrototypeChooser := dagpb.AddSupportToChooser(
	func(ipld.Link, ipld.LinkContext) (ipld.NodePrototype, error) {
		return basicnode.Prototype.Any, nil
	},
)

It's pretty common to stack chooser funcs on top of a fallback that just tries to use basicnode.Prototype.Any. If we defined a nice API for this, then the user could do:

nodePrototypeChooser := dagpb.AddSupportToChooser(basicnode.Chooser)

We could bikeshed on the name: Chooser, DefaultChooser, FallbackChooser. I think just "Chooser" is nice because it does just that - people could use it in a number of ways, it doesn't need to be a fallback or everyone's default.

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

No branches or pull requests

1 participant