Skip to content

Instantly share code, notes, and snippets.

View kingluo's full-sized avatar

jinhua luo kingluo

View GitHub Profile
@kingluo
kingluo / go.mod
Last active March 9, 2023 18:01
go-ldap GSSAPI
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 (
@kingluo
kingluo / doc.md
Last active April 9, 2023 15:12
APISIX limit-req plugin test

rate limit policy

  • [,rate]: pass
  • (rate, burst]: sleep
  • (burst,): reject

Test

Configure a fake upstream as APISIX itself, and calculate the actual success rate via serverless plugin.

@kingluo
kingluo / grpc-status.md
Last active November 10, 2023 01:53
Everything about APISIX GRPC functionalities
@kingluo
kingluo / implement-grpc-client-in-rust-for-openresty.md
Last active November 27, 2022 06:26
Implement grpc client in rust language for openresty/nginx

gems

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.

@kingluo
kingluo / leak.go
Last active October 14, 2022 06:20
package main
import (
"fmt"
"log"
"math/rand"
"net/http"
"strings"
"time"
)
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"math/rand"
"net/http"
"strings"
@kingluo
kingluo / a.md
Last active August 18, 2023 11:32
How to trace nginx blocking issue via systemtap?

Test

# run openresty
/usr/local/openresty/nginx/sbin/nginx -p $PWD -c nginx.conf -g "daemon off;"

# run systemtap script
./samples/blocking-bt.sxx -D STP_NO_OVERLOAD --arg time=60 --skip-badvars -x 144081

# trigger the workload
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()))