8000 [sketch] Prevent typos in option tables by wingo · Pull Request #797 · snabbco/snabb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[sketch] Prevent typos in option tables #797

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

Merged
merged 3 commits into from
Oct 7, 2016

Conversation

wingo
Copy link
Contributor
@wingo wingo commented Mar 2, 2016

Oftentimes we pass around tables of options. Some of those options are required, some are optional. Thing is, it becomes hard to add required options over time, as old code might not detect that it needs to change; it's also hard to let old code know when options go away; and most importantly it's easy to make typos. It's also a bit of irritating effort to provide for optional values which default to false; the idiom conf.foo = conf.foo or bar is just too easy to type.

In the lwaftr and in pflua we use helpers to parse options that solve all these problems. Maybe they're good for snabb itself? Feedback welcome @lukego @eugeneia :)

I note that @kbara once thought this sort of thing was too much machinery, then it caught a nice bug and she became a believer :)

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @lukego, @altexy and @javierguerragiraldez to be potential reviewers

@kbara
Copy link
Contributor
kbara commented Mar 2, 2016

It is too much machinery, it's just the least bad option in these contexts. ;-)

@wingo
Copy link
Contributor Author
wingo commented Mar 2, 2016

Hehe :) I admit, I really like common lisp's keyword arguments :)

@eugeneia eugeneia self-assigned this Mar 3, 2016
@eugeneia
Copy link
Member
eugeneia commented Mar 3, 2016

I would prefer this to be in core.lib (and built into core.config.parse_app_args). Anything that speaks against that?

Cc @lukego

@lukego
Copy link
Member
lukego commented Mar 9, 2016

Great! I would really love to have this. I definitely have that uneasy feeling when using table parameters that are not validated for typos etc. Commonly do make mistakes on parameters to engine.run() for example.

@eugeneia Good question. To me core.lib is a bit of a disorganized mess and I shudder a bit when I read the documentation and see how much stuff we have just thrown in there and thus made part of our API. So I agree that putting this into core.lib would be consistent with normal practice but I am not sure how much I want to promote that. Up to you guys.

@eugeneia
Copy link
Member
eugeneia commented Mar 9, 2016

@lukego Completely agree that core.lib needs a cleanup. As parsing table configurations is a core competency of Snabb (every serious app needs to do it), I would persist on having this in core.lib and it being built into config.parse_app_arg. The current pattern to parse app configurations is absolutely horrible and this is a chance to end this swiftly. Cleaning up core.lib is a separate task.

@eugeneia
Copy link
Member

I would like to have this, but this PR seems forgotten. I would offer to take over integrating this, given there is demand.

@kbara
Copy link
Contributor
kbara commented Aug 1, 2016

I agree; pinging @wingo .

eugeneia added a commit to eugeneia/snabb that referenced this pull request Sep 7, 2016
…config

# Conflicts:
#	src/apps/rate_limiter/rate_limiter.lua
@eugeneia eugeneia merged commit 6d9c784 into snabbco:master Oct 7, 2016
lukego pushed a commit to lukego/snabb that referenced this pull request May 22, 2017
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.

5 participants
0