Documentation ¶
Index ¶
- func HashAny[T any](salt uint64, objs ...T) (uint64, error)
- func HashString[T any](salt uint64, objs ...T) (string, error)
- func NewRuntimeContext(proxyState *ProxyState, route *spec.DGateRoute, modules ...*spec.DGateModule) *runtimeContext
- func ValidateMethods(methods []string) error
- type ModuleExtractor
- type ModuleExtractorFunc
- type ModulePool
- type ProxyHandlerFunc
- type ProxyMetrics
- func (pm *ProxyMetrics) MeasureCertResolutionDuration(ctx context.Context, start time.Time, host string, cache bool, err error)
- func (pm *ProxyMetrics) MeasureModuleDuration(ctx context.Context, reqCtx *RequestContext, moduleFunc string, ...)
- func (pm *ProxyMetrics) MeasureNamespaceResolutionDuration(ctx context.Context, start time.Time, host, namespace string, err error)
- func (pm *ProxyMetrics) MeasureProxyRequest(ctx context.Context, reqCtx *RequestContext, start time.Time)
- func (pm *ProxyMetrics) MeasureUpstreamDuration(ctx context.Context, reqCtx *RequestContext, start time.Time, ...)
- func (pm *ProxyMetrics) Setup(config *config.DGateConfig)
- type ProxyPrinter
- type ProxyReplication
- type ProxyState
- func (ps *ProxyState) ApplyChangeLog(log *spec.ChangeLog) error
- func (ps *ProxyState) ChangeHash() uint64
- func (ps *ProxyState) ChangeLogs() []*spec.ChangeLog
- func (ps *ProxyState) DocumentManager() resources.DocumentManager
- func (ps *ProxyState) DynamicTLSConfig(certFile, keyFile string) *tls.Config
- func (ps *ProxyState) FindNamespaceByRequest(r *http.Request) *spec.DGateNamespace
- func (ps *ProxyState) GetDocumentByID(docId, collection, namespace string) (*spec.Document, error)
- func (ps *ProxyState) GetDocuments(collection, namespace string, limit, offset int) ([]*spec.Document, error)
- func (ps *ProxyState) HandleRoute(requestCtxProvider *RequestContextProvider, pattern string) http.HandlerFunc
- func (ps *ProxyState) ProcessChangeLog(log *spec.ChangeLog, reload bool) error
- func (ps *ProxyState) Raft() *raft.Raft
- func (ps *ProxyState) Ready() bool
- func (ps *ProxyState) ReloadState(check bool, logs ...*spec.ChangeLog) error
- func (ps *ProxyState) ResourceManager() *resources.ResourceManager
- func (ps *ProxyState) Scheduler() scheduler.Scheduler
- func (ps *ProxyState) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (ps *ProxyState) SetReady(ready bool)
- func (ps *ProxyState) SetupRaft(r *raft.Raft, client *raftadmin.Client)
- func (ps *ProxyState) SharedCache() cache.TCache
- func (ps *ProxyState) Start() (err error)
- func (ps *ProxyState) Stop()
- func (ps *ProxyState) Store() *proxystore.ProxyStore
- func (ps *ProxyState) WaitForChanges(log *spec.ChangeLog) error
- type RequestContext
- type RequestContextProvider
- func (reqCtxProvider *RequestContextProvider) Close()
- func (reqCtxProvider *RequestContextProvider) CreateRequestContext(ctx context.Context, rw http.ResponseWriter, req *http.Request, pattern string) *RequestContext
- func (reqCtxProvider *RequestContextProvider) ModulePool() ModulePool
- func (reqCtxProvider *RequestContextProvider) UpdateModulePool(mb ModulePool)
- type S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRuntimeContext ¶
func NewRuntimeContext( proxyState *ProxyState, route *spec.DGateRoute, modules ...*spec.DGateModule, ) *runtimeContext
func ValidateMethods ¶ added in v0.8.0
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, bufferTimeout time.Duration, 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 (*ProxyMetrics) MeasureModuleDuration ¶ added in v0.8.0
func (pm *ProxyMetrics) MeasureModuleDuration( ctx context.Context, reqCtx *RequestContext, moduleFunc string, start time.Time, err error, )
func (*ProxyMetrics) MeasureNamespaceResolutionDuration ¶ added in v0.8.0
func (*ProxyMetrics) MeasureProxyRequest ¶ added in v0.8.0
func (pm *ProxyMetrics) MeasureProxyRequest( ctx context.Context, reqCtx *RequestContext, start time.Time, )
func (*ProxyMetrics) MeasureUpstreamDuration ¶ added in v0.8.0
func (pm *ProxyMetrics) MeasureUpstreamDuration( ctx context.Context, 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, lvl zap.AtomicLevel) *ProxyPrinter
NewProxyPrinter creates a new ProxyPrinter.
func (*ProxyPrinter) Debug ¶ added in v0.11.0
func (pp *ProxyPrinter) Debug(s string)
Debug logs a message at debug level.
func (*ProxyPrinter) Error ¶
func (pp *ProxyPrinter) Error(s string)
Error logs a message at error level.
func (*ProxyPrinter) Info ¶ added in v0.11.0
func (pp *ProxyPrinter) Info(s string)
Info logs a message at info level.
func (*ProxyPrinter) Warn ¶
func (pp *ProxyPrinter) Warn(s string)
Warn logs a message at warn level.
type ProxyReplication ¶
type ProxyReplication struct {
// contains filtered or unexported fields
}
func NewProxyReplication ¶
func NewProxyReplication(raft *raft.Raft, client *raftadmin.Client) *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
ApplyChangeLog - apply change log to the proxy state
func (*ProxyState) ChangeHash ¶
func (ps *ProxyState) ChangeHash() uint64
func (*ProxyState) ChangeLogs ¶ added in v0.11.0
func (ps *ProxyState) ChangeLogs() []*spec.ChangeLog
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) 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(ready bool)
func (*ProxyState) SetupRaft ¶ added in v0.8.0
func (ps *ProxyState) SetupRaft(r *raft.Raft, client *raftadmin.Client)
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) WaitForChanges ¶
func (ps *ProxyState) WaitForChanges(log *spec.ChangeLog) 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) Close ¶ added in v0.11.1
func (reqCtxProvider *RequestContextProvider) Close()
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) UpdateModulePool ¶ added in v0.11.1
func (reqCtxProvider *RequestContextProvider) UpdateModulePool(mb ModulePool)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.