v1

package
v0.0.0-...-21f8c35 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package v1 contains interface definitions for v1API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RepoInterface

type RepoInterface interface {
	RegisterClient(models.Client) (models.Client, error)
	GetClient(name string) (models.Client, error)
	UpdateClient(models.Client) error
	DeleteClient(name string) error
}

RepoInterface defines an interface for repository of v1API

type Request

type Request struct {
	Key      string
	Limit    uint64
	Duration time.Duration
}

Request struct defines a rate limit check request

type Result

type Result struct {
	State         State
	TotalRequests uint64
	ExpiresAt     time.Time
}

Result struct defines a rate limit check result

type State

type State int64

State defines the rate limiter state

const (
	Deny  State = 0
	Allow       = 1
)

Define constants for rate limit state

type Strategy

type Strategy interface {
	Run(r *Request) (*Result, error)
}

Strategy is an interface for rate limiting algorithms. Any rate limiting algorithm that implements this interface can be used with fluxy

type UseCaseInterface

type UseCaseInterface interface {
	RegisterClient(models.Client) (models.Client, error)
	GetClient(name string) (models.Client, error)
	UpdateClient(models.Client) error
	DeleteClient(name string) error
	VerifyLimit(name string) (*Result, error)
}

UseCaseInterface defines the logic interface of v1API

Directories

Path Synopsis
Package algorithm contains all rate limiting algorithms that define the Strategy interface
Package algorithm contains all rate limiting algorithms that define the Strategy interface
handlers
grpc
Package grpc defines the GRPC handler for fluxy
Package grpc defines the GRPC handler for fluxy
Package repository contains the implementation of data access methods
Package repository contains the implementation of data access methods
Package usecase acts as a bridge between the repository and the business logic
Package usecase acts as a bridge between the repository and the business logic

Jump to

Keyboard shortcuts

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