Skip to content

Instantly share code, notes, and snippets.

@gszr
gszr / schema.lua
Created November 21, 2024 13:59
Kong schema validation
setmetatable(_G, nil)
local MetaSchema = require "kong.db.schema.metaschema"
local s1 = {
name = "schema",
primary_key = {},
fields = {
{ js_enabled = { type = "boolean" }},
{ sql_enabled = { type = "boolean" }},
@gszr
gszr / gist:d4b6c63f85d8420b00701ebcec189f01
Created October 21, 2024 12:34
pluginserver restart errors
2024/10/21 09:32:27 [notice] 28823#0: *1035 [kong] process.lua:173 external pluginserver 'go-hello' terminated: signal 15, context: ngx.timer
2024/10/21 09:32:27 [notice] 28823#0: *1035 [kong] process.lua:152 [pluginserver] starting pluginserver process for go-hello, context: ngx.timer
2024/10/21 09:32:27 [notice] 28823#0: *1035 [kong] process.lua:158 [pluginserver] started, pid 28893, context: ngx.timer
2024/10/21 09:32:27 [notice] 28823#0: signal 20 (SIGCHLD) received from 28893
2024/10/21 09:32:27 [notice] 28823#0: *1035 [kong] process.lua:173 external pluginserver 'go-hello' terminated: exit 3, context: ngx.timer
@gszr
gszr / go-hello.go
Last active July 3, 2024 16:29
Go Plugin Demo
/*
A "hello world" plugin in Go,
which reads a request header and sets a response header.
*/
package main
import (
"log"
local inspect = require "inspect"
require("kong.globalpatches")({
cli = true,
})
local conf_loader = require "kong.conf_loader"
local DB = require "kong.db"
local conf = assert(conf_loader(TEST_CONF_PATH))
Decoded before:
{
data = { {
application_context = {
application_id = "app_id",
developer_id = "dev_id",
organization_id = "org_id",
portal_id = "p_id",
product_version_id = "pv_id"
@gszr
gszr / KongMemUsage.md
Last active April 8, 2024 18:33
Kong Memory Usage

Some notes on Kong memory usage

As I was tweaking the Kong config I use in my VPS, I took the opportunity to take some screenshots of the Kong container memory usage pattern. What follows is a brief summary of my findings.

The deployment is pretty small:

$ http :8001/services | jq '.data | length'
11

$ http :8001/routes | jq '.data | length'
@gszr
gszr / readme.md
Created April 5, 2024 14:33
lua-protobuf issue

Before

(kong-dev) kong $ luarocks install lua-protobuf 0.5.0 CC=/usr/bin/gcc CFLAGS="-O2 -fPIC -fstrict-aliasing -Wstrict-aliasing=2"              master
Installing https://luarocks.org/lua-protobuf-0.5.0-1.src.rock

lua-protobuf 0.5.0-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)
/usr/bin/gcc -O2 -fPIC -fstrict-aliasing -Wstrict-aliasing=2 -I/home/gs/code/work/kong/bazel-bin/build/kong-dev/openresty/luajit/include/luajit-2.1 -c pb.c -o pb.o
In file included from pb.c:11:
pb.h: In function ‘pb_nexttype’:
https://github.com/openresty/lua-nginx-module?tab=readme-ov-file#ngxrematch
```
Specify options to control how the match operation will be performed. The following option characters are supported:
a anchored mode (only match from the beginning)
d enable the DFA mode (or the longest token match semantics).
this requires PCRE 6.0+ or else a Lua exception will be thrown.
first introduced in ngx_lua v0.3.1rc30.
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.8.0 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 13.2.1 20230801"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=130201
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=24200
@gszr
gszr / gist:108abd44063086a19cb0e171d9c6a3f3
Created March 21, 2024 20:59
openrgb -vv --gui --loglevel 6
$ openrgb -vv --gui --loglevel 6
Parsing CLI option: --gui
Parsing CLI option: --loglevel
Loglevel set to 6
Attempting to connect to local OpenRGB server.
Connection attempt failed
Local OpenRGB server unavailable.
Running standalone.
[ResourceManager] Calling detection start callbacks.
[ResourceManager] Calling detection progress callbacks.