-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
make rama-cli squid-config compatible #128
Comments
Moving this to v0.3, because as fun as it is, it does seem like a distraction from what we really need for now. Once v0.2 is out, it's definitely something we can tackle for v0.3. |
Those that want to pick up this issue, be warned that it will require a decent time investment. There is a lot to be learned from this issue and pleasure taken from it, but it will require also plenty of work. The code for the config will live in a new module This story is about getting this API started. In reality this interface is a never ending story, just like the Rust API is a never ending one, but we have to start somewhere and for the config API that start is this story. The steps that have to be completed for this story to be considered "resolved" (done):
These steps are to be done one by one, in order, one branch/PR per step. They do not have to be done by the same person, but only one person/team should be active on this at the same time. And the one already working on one step gets preference on completing also the step after that, if that is what they want. At all steps feel free to involve me and report regular. This way you are not alone in this and can we ensure that not too much work is done that shouldn't be done. Important at all times that we stay aligned. I am also here for guidance, mentoring and assistance. Can be via here (GitHub) or on Discord, or both. |
What attracted me to the squid config format initially was how it allows you to also declare variables (acl's) and some similar features which makes for a pretty powerful config format. A more traditional approach would be like [[services]]
internal_port = 8080
protocol = "tcp"
[services.concurrency]
hard_limit = 25
soft_limit = 20
[[services.ports]]
handlers = ["http"]
port = "80"
[[services.ports]]
handlers = ["tls", "http"]
port = "443" Where you would allow middleware to be configured still in flexible ways, and can map handlers to specific services (e.g. tls could mean the default tls, while we could also allows rustls specifically etc. Http would be the default http proxy etc... Obviously this is a cloud web deployment config example so not 1-to-1 example applicable to proxies but it does show. This is in a way a lot simpler, as we can just parse toml with serde, and allow within the defined format also dynamic fields that stuff can register into. E.g. one could register a transport middleware (concurrency) to hook into the let mut cfg = rama::config::default();
cfg.register_middleware::<MyConcurrencyConfig>("concurrency", |cfg: MyConcurrencyConfig| {
ConcurrencyLayer::new(/* ... */)
});
let proxy_services: Vec<_> = cfg.parse().await?.collect();
for proxy_service in proxy_services {
/* spawn it */
} There are of course still plenty of questions to answer even for such much simpler approach:
And of course, to bring us back to the original topic of squid-inspired config. What does that format give us that would not be possible with a toml-based format. Or put in other words, what are the pros and cons of each approach? |
For some use cases or users a config is good enough. Especially if we allow the custom logic to also be controlled by the same config file this can be a very powerful concept.
For the v0.2 case might already be cool if the following config file could work:
This would also make the
glendc/rama:latest
docker image to be useful out of the box for plenty of use cases.The reference can be found here: https://www.squid-cache.org/Doc/config/
For the one picking this up, it's a nice opportunity to get your hands dirty with something like https://docs.rs/winnow/latest/winnow/ if you haven't used it already.
The text was updated successfully, but these errors were encountered: