[,rate]
: pass(rate, burst]
: sleep(burst,)
: reject
Configure a fake upstream as APISIX itself, and calculate the actual success rate via serverless plugin.
module github.com/kingluo/foobar | |
go 1.19 | |
require ( | |
github.com/go-ldap/ldap/v3 v3.4.5-0.20230226130424-b64a808c288f | |
gopkg.in/jcmturner/gokrb5.v7 v7.5.0 | |
) | |
require ( |
Back in 2019, when I work as individual postgresql/nginx consultant. Many clients ask me if they could do hybrid programming in nginx.
They said, nginx/openresty is powerful and high performance, but the most significant drawback is it lacks of ecosystem of mainstream programming languages, especially when they have to interact with popular frameworks, e.g. kafka, consul, k8s, etc. The C/Lua ecosystem is slim, even if they bite the bullet and write down C/Lua modules, they face the awkward fact that most frameworks do not provide C/Lua API.
package main | |
import ( | |
"fmt" | |
"log" | |
"math/rand" | |
"net/http" | |
"strings" | |
"time" | |
) |
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"math/rand" | |
"net/http" | |
"strings" |
ipset_name="myset" | |
hosts=("httpbin.org") | |
interval=3 #secs | |
while true; do | |
new_iplist=() | |
for host in ${hosts[@]}; do | |
for ip in $(dig +noall +answer +multiline $host | awk '{print $NF}' | sort); do | |
new_iplist+=($ip) | |
done |
use hyper::service::{make_service_fn, service_fn}; | |
use hyper::{Body, Request, Response, Server}; | |
use std::convert::Infallible; | |
use std::net::SocketAddr; | |
async fn hello_world(_req: Request<Body>) -> Result<Response<Body>, Infallible> { | |
//let path = _req.uri().path(); | |
//let v: Vec<&str> = path.split('/').collect(); | |
//let str = format!("hello {}", v[2]); | |
//Ok(Response::new(str.into())) |