gatewayflowcontroller

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 12 Imported by: 0

README

RSS3 Gateway Flow Controller

About

This is a Traefik plugin, which controls the inbound traffic, useful for billing related requirements.

We use this with the Payment Processor.

Or you can also develop your own processors.

Questions

Why vendor dependencies

According to traefik plugin demo's readme,

Plugin dependencies must be vendored for each plugin. Vendored packages should be included in the plugin's GitHub repository. (Go modules are not supported.)

So we have to push the vendor directory.

What is the connector

Traefik doesn't like package unsafe (which has been widely used in many dependencies), so we have to split a dedicated connector to call them, contact with our plugin through rpc .

Why this repo name

Lint doesn't like GatewayFlowController_test because of mixed camelCase and snake_case.

Traefik doesn't like plugin because of unmatched package name.

So in order to satisfy both of them, we have to use this long piece of word.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIP

func GetIP(req *http.Request) string

func New

func New(_ context.Context, next http.Handler, config *Config, name string) (http.Handler, error)

New created a new plugin.

Types

type Config

type Config struct {
	// Request related
	KeyHeader string `json:"key_header,omitempty"`

	// Connector
	ConnectorRPC string `json:"connector_rpc,omitempty"`

	// Rate Limit
	MaxSources int   `json:"max_sources,omitempty"`
	Average    int64 `json:"average,omitempty"`
	Period     int64 `json:"period,omitempty"`
	Burst      int64 `json:"burst,omitempty"`
}

Config the plugin configuration.

func CreateConfig

func CreateConfig() *Config

CreateConfig creates the default plugin configuration.

type Core

type Core struct {
	// contains filtered or unexported fields
}

func (*Core) ServeHTTP

func (fc *Core) ServeHTTP(rw http.ResponseWriter, req *http.Request)

The Core processor

type FlowController

type FlowController struct {
	Core
	// contains filtered or unexported fields
}

FlowController : a FlowController plugin.

func (*FlowController) ServeHTTP

func (fc *FlowController) ServeHTTP(rw http.ResponseWriter, req *http.Request)

The Full processor

func (*FlowController) Stop

func (fc *FlowController) Stop()

Stop will not be called, it's just a resource release reminder

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter(maxSources int, average int64, period int64, burst int64) (*RateLimiter, error)

func (*RateLimiter) RateLimit

func (rl *RateLimiter) RateLimit(rw http.ResponseWriter, req *http.Request, account *string) bool

type ResponseWriterProxy

type ResponseWriterProxy struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewResponseWriterProxy

func NewResponseWriterProxy(rw http.ResponseWriter) *ResponseWriterProxy

func (*ResponseWriterProxy) StatusCode

func (rwp *ResponseWriterProxy) StatusCode() int

func (*ResponseWriterProxy) WriteHeader

func (rwp *ResponseWriterProxy) WriteHeader(statusCode int)

Directories

Path Synopsis
holster
clock
Package clock provides the same functions as the system package time.
Package clock provides the same functions as the system package time.

Jump to

Keyboard shortcuts

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