models

package
v0.0.0-...-c0e7709 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlockChannel string

BlockChannel is the name of the channel that should be used for blocking the api subscription key

DB is the db client for the redis persistent storage

View Source
var RateChannel = make(chan RateRequest)

RateChannel receives the rate updation requests

View Source
var ResetChannel <-chan *redis.Message

ResetChannel receives the redis api usage reset channel

View Source
var ResetChannelName string

ResetChannelName is the name of the reset channel

View Source
var UsageChannel <-chan *redis.Message

UsageChannel receives the redis api usage channel

Functions

This section is empty.

Types

type APIUsage

type APIUsage struct {
	Key          string `json:"key"`     //Key is the key associated with the api usage
	MaxUsage     int    `json:"usage"`   //MaxUsage is the maximum allowed usage
	CurrentUsage int    `json:"current"` //CurrentUsage is the current usage
	Email        string `json:"email"`   //Email is the email associated with the key
}

APIUsage represents the api usage of the key

type RateRequest

type RateRequest struct {
	KeyHash string //KeyHash is used to store the rate info in redis cache
	Type    Type   //Type of the rate update request
}

RateRequest is the request to update the rate

type Type

type Type uint

Type is the type of the request for rate limitng go routine

const (
	//ADD will add the current usage of an api with 1
	ADD Type = iota
	//RESET will reset the the current api usage to 0
	RESET
	//BLOCK request is to block the api token
	BLOCK
	//STATUS request is to know the status of a token
	STATUS
	//OK request indicates that the status of the token is ok and not blacklisted
	OK
)

Jump to

Keyboard shortcuts

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