nginxinc/ngx-rust

Examples on upstream/loadbalancer modules

rikatz opened this issue · 6 comments

rikatz commented

Hey folks, thanks for this crate.

I'm looking into testing ngx-rust with ingress-nginx, to replace parts of the code that deals with upstream/balancer (today it uses openresty).

First of all, bare in mind I'm almost null in Rust.

While trying to follow the examples and some module development blogs (in C), I couldn't move forward to implement a LB module for it.

I'm a bit lost on where are the limits of C/bindings and Rust code, and was wondering if it is possible to get an example on a loadbalancer module to check where am I doing the mistakes.

Thank you!

The coverage varies right now with how much of the total NGINX API this project supports. There are some known gaps and some unknown gaps. This is a good suggestion for an example though. I'll take a look.

This is an example of a community C module for LB: https://github.com/gnosek/nginx-upstream-fair, but no recent updates though.

rikatz commented

Yeap, I was also reading https://www.evanmiller.org/nginx-modules-guide.html and https://hodo.dev/posts/post-17-nginx-custom-upstream-module/ but not gonna lie I'm having some issues to port the idea to ngx-rust :)

Status: I'm significantly through an example based on this work: https://github.com/gabihodoroaga/nginx-upstream-module.

The algorithm may change some for example purposes, but the general structure will remain for cross-referencing. I'm hoping to complete and test it soon.

I opened a WIP PR early to help with your work @rikatz. Hopefully it offers some help before we finalize the structure or annotate it.

rikatz commented

Thanks @f5yacobucci it already helps a lot! I will take a look and play with it during the weekend :)