Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var APITokenHeader = flag.String("api-token-header", "token", "Header key with which the token is stored in the request")
APITokenHeader is the header key with which the token is stored in the request
var APIUrl = flag.String("api-url", "http://127.0.0.1:8085", "URL of the api to be access. Eg. http://127.0.0.1:8085")
APIUrl is url of the api to be accessed
var BlackListChannel = make(chan Request)
BlackListChannel is the channel through which black listed requests can be send to the blacklist go routine
var Client *redis.Client
Client is the redis client for the redis
var RedisAPIUsageChannelName = flag.String("redis-api-usage-channel", "API_USAGE", "Name of the Redis pubsub channel through which API usage info has to be passed")
RedisAPIUsageChannelName is the name of the redis pubsub channel through which
var RedisBlockChannelName = flag.String("redis-block-channel", "BLOCK", "Name of the Redis pubsub channel through which the message for blocking requests come")
RedisBlockChannelName is the name of the redis pubsub channel through which the messages to block the requests come
var RedisPassword = flag.String("redis-password", "", "Password to access the redis instance")
RedisPassword is the password with which the redis instance can be accessed
var RedisResetChannelName = flag.String("redis-reset-channel", "RESET", "Name of the Redis pubsub channel through which the message for reseting the api usage message come")
RedisResetChannelName is the name of the Redis pubsub channel through which the message for reseting the api usage message come
var RedisURL = flag.String("redis-url", "redis:6379", "URL with which redis can be accessed. Eg. redis:6379")
RedisURL is the url of the redis instance
var TokenChan = make(chan Token)
TokenChan is the channel for getting the token information
Functions ¶
func BlackList ¶
func BlackList(ch chan Request)
BlackList is the go routine which maintains the blacklisted tokens and updates it
func HandleMessages ¶
HandleMessages go routine will handle the pubsub messages from redis t is the type of requests that needed to be catered
func InitPubSub ¶
func InitPubSub()
InitPubSub inits the pubsub to communicate with the rate limiter through redis
func SendToChannel ¶
func SendToChannel(ch chan models.RateRequest, req models.RateRequest)
SendToChannel will send arequest to a channel. This function comes handy in situations where requests has to be send async.
Types ¶
type Request ¶
type Request struct { models.RateRequest //RateRequest Out chan models.RateRequest //Out is the channel through requests can be responded }
Request is wrapper around rate request with aditional Out channel to respond back
func NewRequest ¶
func NewRequest(r models.RateRequest) Request
NewRequest creates a new request for a given rate request
type Token ¶
type Token struct { models.RateRequest //RateRequest Out chan models.RateRequest //Out is the channel through requests can be responded }
Token is wrapper around rate request with aditional Out channel to respond back