pubsub

package
v0.0.0-...-7b6cd34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

View Source
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

View Source
var BlackListChannel = make(chan Request)

BlackListChannel is the channel through which black listed requests can be send to the blacklist go routine

View Source
var Client *redis.Client

Client is the redis client for the redis

View Source
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

View Source
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

View Source
var RedisPassword = flag.String("redis-password", "", "Password to access the redis instance")

RedisPassword is the password with which the redis instance can be accessed

View Source
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

View Source
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

View Source
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

func HandleMessages(ch <-chan *redis.Message, t models.Type)

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 InitRedis

func InitRedis()

InitRedis will init the redis client

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.

func Tokens

func Tokens(ch chan Token)

Tokens go routine will cater to retieve the token information from redis cache

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

func NewToken

func NewToken(keyHash string) Token

NewToken will generate a new token request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL