gateway

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Attempts int = iota
	Retry
)
View Source
const (
	DefaultLogDir = "$HOME/.gateway"

	AppID = "hedlzgp1u48kjf50xtcvwdklminbqe9a"

	ModeValueLight = "light"
)

Variables

View Source
var (
	ShardPort = &types.ShardPort
)

Functions

func AllHandle

func AllHandle(w http.ResponseWriter, r *http.Request)

func EthPubSubHandle

func EthPubSubHandle(w http.ResponseWriter, r *http.Request)

func GetAttemptsFromContext

func GetAttemptsFromContext(r *http.Request) int

GetAttemptsFromContext returns the attempts for request

func GetRetryFromContext

func GetRetryFromContext(r *http.Request) int

GetAttemptsFromContext returns the attempts for request

func ParseURL

func ParseURL(r *http.Request) (types.Proxy, error, map[string]string)

func PubSubHandle

func PubSubHandle(w http.ResponseWriter, r *http.Request)

func Start

func Start()

Types

type BackendProto

type BackendProto func(url *url.URL, alive bool) types.Instance

type ServerPool

type ServerPool struct {
	JobQueue    chan types.Job
	WorkerQueue chan chan types.Job
	// contains filtered or unexported fields
}

func NewServerPool

func NewServerPool(backProto BackendProto, svrsource types.ServerSource, workerlen int) *ServerPool

func (*ServerPool) AddBackend

func (s *ServerPool) AddBackend(backend types.Instance)

AddBackend to the server pool

func (*ServerPool) ConfigServerPool

func (s *ServerPool) ConfigServerPool(tokens []string)

func (*ServerPool) HealthCheck

func (s *ServerPool) HealthCheck()

func (*ServerPool) MarkBackendStatus

func (s *ServerPool) MarkBackendStatus(backendUrl *url.URL, alive bool)

MarkBackendStatus changes a status of a backend

func (*ServerPool) Run

func (s *ServerPool) Run()

func (*ServerPool) SharedCheck

func (s *ServerPool) SharedCheck()

type SpecificJob

type SpecificJob struct {
	Request       *http.Request
	Proxy         types.Proxy
	BackEnds      []types.Instance
	RequestParams map[string]string

	ResponseChan *chan []byte
}

func NewSpecificJob

func NewSpecificJob(r *http.Request, backends []types.Instance) *SpecificJob

func (*SpecificJob) Do

func (sjob *SpecificJob) Do()

type Worker

type Worker struct {
	JobQueue chan types.Job
}

func NewWorker

func NewWorker() Worker

func (Worker) Run

func (w Worker) Run(wq chan chan types.Job)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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