dragonite

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Rate Limit Request

Installation

Install

go get github.com/gananggww/pikago-rate-limit

Usage

how to inject or call

val := dragonite.NewValidate(rds) //you can inject dep this in main.go in ucase or handler or direct call to func
err = o.val.RateLimit(ctx, dragonite.RateLimitConfig{ 
    SubAs:      "pikachu", // sub type for identifier as who
    In:         10000, // limit request in ms
    As:         "pokemon", // main type for identifier as who  
    Limit:      10, // how many limit request 
}).Error

if err != nil {
    return
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimitConfig

type RateLimitConfig struct {
	Limit int64
	In    time.Duration
	SubAs string
	As    string
}

type Validate

type Validate struct {
	Error error
	// contains filtered or unexported fields
}

func NewValidate

func NewValidate(rds *redis.Client) *Validate

func (*Validate) RateLimit

func (o *Validate) RateLimit(ctx context.Context, config RateLimitConfig) *Validate

Jump to

Keyboard shortcuts

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