MCPcopy Index your code
hub / github.com/0verread/goralim

github.com/0verread/goralim @v0.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.0 ↗ · + Follow
8 symbols 18 edges 4 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

banner

Goralim

goralim is a Golang package that provides a rate limiter based on Token bucket algorithm. It is capabale to handle distributed workload with its redis database support. It has HTTP server middleware support (as of now).

this is a beta version now and under active development. For production use, fork it and made changes based on your need.

Install

go get "github.com/0verread/goralim"

Usage

import (
  goralim "github.com/0verread/goralim"
)

  // Redis initialization
    config := goralim.RedisConfig {
        HOST: "127.0.0.1",
        PORT: 6379,
    // password
        AUTH: "",
    }
    redisStore := goralim.NewRedisClient(config)

  // setup rate limiter for a key (key can be userId/client)
  // 10 is bucket size, 5 is bucket refill rate per second 
  tb := goralim.NewTokenBucket("key123", redisStore, 10, 5)

  // create HTTP server and setup a goralim middleware to put a rate limiter
  handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, "Hey There this is a Request")
    })

    rateLimitedHandler := goralim.RateLimiter(tb, handler)
    http.ListenAndServe(":8080", rateLimitedHandler)

License

Under MIT license

Core symbols most depended-on inside this repo

NewRedisClient
called by 1
redis.go
RateLimiter
called by 1
middleware.go
NewTokenBucket
called by 1
goralim.go
refillTokens
called by 1
goralim.go
isAllowed
called by 1
goralim.go
main
called by 0
examples/example.go

Shape

Function 4
Method 2
Struct 2

Languages

Go100%

Modules by API surface

goralim.go4 symbols
redis.go2 symbols
middleware.go1 symbols
examples/example.go1 symbols

For agents

$ claude mcp add goralim \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact