proxy

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashAny

func HashAny[T any](salt uint32, objs ...T) (uint32, error)

func HashString added in v0.8.0

func HashString[T any](salt uint32, objs ...T) (string, error)

func NewRuntimeContext

func NewRuntimeContext(
	proxyState *ProxyState,
	route *spec.DGateRoute,
	modules ...*spec.DGateModule,
) *runtimeContext

func ValidateMethods added in v0.8.0

func ValidateMethods(methods []string) error

Types

type ModuleExtractor

type ModuleExtractor interface {
	// Start starts the event loop for the module extractor; ret is true if the event loop was started, false otherwise
	Start(*RequestContext)
	// Stop stops the event loop for the module extractor
	Stop(wait bool)
	// RuntimeContext returns the runtime context for the module extractor
	RuntimeContext(*RequestContext) (modules.RuntimeContext, error)
	// ModuleContext returns the module context for the module extractor
	ModuleContext() *types.ModuleContext

	FetchUpstreamUrlFunc() (extractors.FetchUpstreamUrlFunc, bool)
	RequestModifierFunc() (extractors.RequestModifierFunc, bool)
	ResponseModifierFunc() (extractors.ResponseModifierFunc, bool)
	ErrorHandlerFunc() (extractors.ErrorHandlerFunc, bool)
	RequestHandlerFunc() (extractors.RequestHandlerFunc, bool)
}

func NewEmptyModuleExtractor

func NewEmptyModuleExtractor() ModuleExtractor

func NewModuleExtractor

func NewModuleExtractor(
	runtimeCtx *runtimeContext,
	fetchUpstreamUrl extractors.FetchUpstreamUrlFunc,
	requestModifier extractors.RequestModifierFunc,
	responseModifier extractors.ResponseModifierFunc,
	errorHandler extractors.ErrorHandlerFunc,
	requestHandler extractors.RequestHandlerFunc,
) ModuleExtractor

type ModuleExtractorFunc

type ModuleExtractorFunc func(*RequestContextProvider) (ModuleExtractor, error)

type ModulePool added in v0.8.0

type ModulePool interface {
	Borrow() ModuleExtractor
	Return(me ModuleExtractor)
	Close()
}

func NewModulePool added in v0.8.0

func NewModulePool(
	minBuffers, maxBuffers int,
	reqCtxProvider *RequestContextProvider,
	createModExts ModuleExtractorFunc,
) (ModulePool, error)

type ProxyHandlerFunc

type ProxyHandlerFunc func(ps *ProxyState, reqCtx *RequestContext)

type ProxyMetrics added in v0.8.0

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

func NewProxyMetrics added in v0.8.0

func NewProxyMetrics() *ProxyMetrics

func (*ProxyMetrics) MeasureCertResolutionDuration added in v0.8.0

func (pm *ProxyMetrics) MeasureCertResolutionDuration(
	start time.Time, host string, cache bool, err error,
)

func (*ProxyMetrics) MeasureModuleDuration added in v0.8.0

func (pm *ProxyMetrics) MeasureModuleDuration(
	reqCtx *RequestContext, moduleFunc string,
	start time.Time, err error,
)

func (*ProxyMetrics) MeasureNamespaceResolutionDuration added in v0.8.0

func (pm *ProxyMetrics) MeasureNamespaceResolutionDuration(
	start time.Time, host, namespace string, err error,
)

func (*ProxyMetrics) MeasureProxyRequest added in v0.8.0

func (pm *ProxyMetrics) MeasureProxyRequest(
	reqCtx *RequestContext, start time.Time,
)

func (*ProxyMetrics) MeasureUpstreamDuration added in v0.8.0

func (pm *ProxyMetrics) MeasureUpstreamDuration(
	reqCtx *RequestContext, start time.Time,
	upstreamHost string, err error,
)

func (*ProxyMetrics) Setup added in v0.8.0

func (pm *ProxyMetrics) Setup(config *config.DGateConfig)

type ProxyPrinter

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

func NewProxyPrinter

func NewProxyPrinter(logger *zap.Logger) *ProxyPrinter

func (*ProxyPrinter) Error

func (pp *ProxyPrinter) Error(s string)

func (*ProxyPrinter) Log

func (pp *ProxyPrinter) Log(s string)

func (*ProxyPrinter) Warn

func (pp *ProxyPrinter) Warn(s string)

type ProxyReplication

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

func NewProxyReplication

func NewProxyReplication(raft *raft.Raft, raftConfig *raft.Config) *ProxyReplication

type ProxyState

type ProxyState struct {
	ReverseProxyBuilder   reverse_proxy.Builder
	ProxyTransportBuilder proxy_transport.Builder
	ProxyHandler          ProxyHandlerFunc
	// contains filtered or unexported fields
}

func NewProxyState

func NewProxyState(logger *zap.Logger, conf *config.DGateConfig) *ProxyState

func (*ProxyState) ApplyChangeLog

func (ps *ProxyState) ApplyChangeLog(log *spec.ChangeLog) error

func (*ProxyState) ChangeHash

func (ps *ProxyState) ChangeHash() uint32

func (*ProxyState) DocumentManager

func (ps *ProxyState) DocumentManager() resources.DocumentManager

DocumentManager is an interface that defines the methods for managing documents.

func (*ProxyState) DynamicTLSConfig

func (ps *ProxyState) DynamicTLSConfig(certFile, keyFile string) *tls.Config

func (*ProxyState) FindNamespaceByRequest

func (ps *ProxyState) FindNamespaceByRequest(r *http.Request) *spec.DGateNamespace

func (*ProxyState) GetDocumentByID

func (ps *ProxyState) GetDocumentByID(docId, collection, namespace string) (*spec.Document, error)

GetDocumentByID is a function that returns a document in a collection by its ID.

func (*ProxyState) GetDocuments

func (ps *ProxyState) GetDocuments(collection, namespace string, limit, offset int) ([]*spec.Document, error)

GetDocuments is a function that returns a list of documents in a collection.

func (*ProxyState) HandleRoute

func (ps *ProxyState) HandleRoute(requestCtxProvider *RequestContextProvider, pattern string) http.HandlerFunc

func (*ProxyState) Logger

func (ps *ProxyState) Logger() *zap.Logger

func (*ProxyState) ProcessChangeLog

func (ps *ProxyState) ProcessChangeLog(log *spec.ChangeLog, reload bool) error

func (*ProxyState) Raft

func (ps *ProxyState) Raft() *raft.Raft

func (*ProxyState) Ready added in v0.8.0

func (ps *ProxyState) Ready() bool

func (*ProxyState) ReloadState

func (ps *ProxyState) ReloadState(check bool, logs ...*spec.ChangeLog) error

ReloadState - reload state checks the change logs to see if a reload is required, specifying check as false skips this step and automatically reloads

func (*ProxyState) ResourceManager

func (ps *ProxyState) ResourceManager() *resources.ResourceManager

func (*ProxyState) Scheduler

func (ps *ProxyState) Scheduler() scheduler.Scheduler

func (*ProxyState) ServeHTTP

func (ps *ProxyState) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*ProxyState) SetReady added in v0.8.0

func (ps *ProxyState) SetReady()

func (*ProxyState) SetupRaft added in v0.8.0

func (ps *ProxyState) SetupRaft(r *raft.Raft, rc *raft.Config)

func (*ProxyState) SharedCache

func (ps *ProxyState) SharedCache() cache.TCache

func (*ProxyState) Start added in v0.8.0

func (ps *ProxyState) Start() (err error)

func (*ProxyState) Stop added in v0.8.0

func (ps *ProxyState) Stop()

func (*ProxyState) Store added in v0.8.0

func (ps *ProxyState) Store() *proxystore.ProxyStore

func (*ProxyState) Version added in v0.8.0

func (ps *ProxyState) Version() string

func (*ProxyState) WaitForChanges

func (ps *ProxyState) WaitForChanges() error

type RequestContext

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

func (*RequestContext) Context added in v0.8.0

func (reqCtx *RequestContext) Context() context.Context

func (*RequestContext) Pattern added in v0.8.0

func (reqCtx *RequestContext) Pattern() string

func (*RequestContext) Request added in v0.8.0

func (reqCtx *RequestContext) Request() *http.Request

func (*RequestContext) Route added in v0.8.0

func (reqCtx *RequestContext) Route() *spec.DGateRoute

type RequestContextProvider

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

func NewRequestContextProvider

func NewRequestContextProvider(route *spec.DGateRoute, ps *ProxyState) *RequestContextProvider

func (*RequestContextProvider) CreateRequestContext

func (reqCtxProvider *RequestContextProvider) CreateRequestContext(
	ctx context.Context, rw http.ResponseWriter,
	req *http.Request, pattern string,
) *RequestContext

func (*RequestContextProvider) ModulePool added in v0.9.0

func (reqCtxProvider *RequestContextProvider) ModulePool() ModulePool

func (*RequestContextProvider) SetModulePool added in v0.8.0

func (reqCtxProvider *RequestContextProvider) SetModulePool(mb ModulePool)

type S

type S string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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