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

Need a way to access flux options from builtins #3173

Closed
rockstar opened this issue Sep 2, 2020 · 1 comment · Fixed by #3180
Closed

Need a way to access flux options from builtins #3173

rockstar opened this issue Sep 2, 2020 · 1 comment · Fixed by #3180
Assignees

Comments

@rockstar
Copy link
Contributor

rockstar commented Sep 2, 2020

While trying to implement influxdata/influxdb/tasks/lastSuccess, I discovered that there's not a way to get an option defined in flux from inside a builtin. @wolffcm and I talked about it, and decided that it might be best to be able to get to the flux options from the context.Context from a function.

@rockstar rockstar added this to the Sprint 20-Q3-6 milestone Sep 2, 2020
@jsternberg
Copy link
Contributor

jsternberg commented Sep 3, 2020

I'd need to know the specifics, but the best way to use an option inside of a builtin is likely to use some indirection. A few things to consider when using another value inside of a builtin. A builtin doesn't really understand the concept of closures which means that it doesn't really understand the concept of scope. But it does understand the concept of passing values. I've used this technique before:

option opt = 0
builtin _func
func = (v) => _func(v: v, opt: opt)

The builtin includes a parameter for the option and the user facing function will include it automatically. This causes the interpreter to take care of everything.

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 a pull request may close this issue.

2 participants