twrs is a small feature flag library. No external service, no network calls on the hot path: just rules, evaluated locally.
package main
import (
"context"
"fmt"
"log"
"time"
"gitlab.com/twrshq/twrs"
)
func main() {
ctx := context.Background()
f, err := twrs.New(twrs.Options{
Path: "flags.yaml",
ReloadInterval: 10 * time.Second,
})
if err != nil {
log.Fatal(err)
}
defer f.Close()
ok, err := f.Enabled(ctx, "new-checkout", "u_1842")
if err != nil {
log.Fatal(err)
}
fmt.Println(ok)
v, err := f.Variant(ctx, "search-ranking", "u_1842")
if err != nil {
log.Fatal(err)
}
fmt.Println(v)
}
If a flag is missing or malformed, the default you passed in code wins.
Enable a flag for 5% of users and widen it as you gain confidence. Users stay in their bucket.
A single file of rules and a few hundred lines of code.
Flags are evaluated in-process in microseconds. Nothing leaves your servers.
Change the flag file and running processes pick it up within seconds.