This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"database/sql" | |
"encoding/json" | |
"fmt" | |
"net/http" | |
"os" | |
"path/filepath" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"strings" | |
"testing" | |
"text/template" | |
) | |
type Data struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Input parameters | |
local tokens_key = KEYS[1]..":tokens" -- Key for the bucket's token counter | |
local last_access_key = KEYS[1]..":last_access" -- Key for the bucket's last access time | |
local capacity = tonumber(ARGV[1]) -- Maximum number of tokens in the bucket | |
local rate = tonumber(ARGV[2]) -- Rate of token generation (tokens/second) | |
local now = tonumber(ARGV[3]) -- Current timestamp in microseconds | |
local requested = tonumber(ARGV[4]) -- Number of tokens requested for the operation | |
-- Fetch the current token count |