Documentation ¶
Index ¶
- func HashAny[T any](salt uint32, objs ...any) (uint32, error)
- func NewRuntimeContext(proxyState *ProxyState, route *spec.DGateRoute, modules ...*spec.DGateModule) *runtimeContext
- func RouteHash(routes ...*spec.DGateRoute) (hash uint32, err error)
- func TimeoutDialer(connTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
- type LoggerOptions
- type ModuleBuffer
- type ModuleExtractor
- type ModuleExtractorFunc
- type ProxyHandlerFunc
- type ProxyPrinter
- type ProxyReplication
- type ProxySnapshot
- type ProxyState
- func (ps *ProxyState) ApplyChangeLog(log *spec.ChangeLog) error
- func (ps *ProxyState) ChangeHash() uint32
- func (ps *ProxyState) DocumentManager() resources.DocumentManager
- func (ps *ProxyState) DynamicTLSConfig(certFile, keyFile string) *tls.Config
- func (ps *ProxyState) EnableRaft(r *raft.Raft, rc *raft.Config)
- func (ps *ProxyState) FindNamespaceByRequest(r *http.Request) *spec.DGateNamespace
- func (ps *ProxyState) GetDocumentByID(namespace, collection, docId 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) Logger(opts ...LoggerOptions) *zerolog.Logger
- func (ps *ProxyState) ProcessChangeLog(log *spec.ChangeLog, register bool) error
- func (ps *ProxyState) Raft() *raft.Raft
- func (ps *ProxyState) ReloadState() error
- func (ps *ProxyState) ResourceManager() *resources.ResourceManager
- func (ps *ProxyState) RestoreState(r io.Reader) error
- func (ps *ProxyState) Scheduler() scheduler.Scheduler
- func (ps *ProxyState) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (ps *ProxyState) SharedCache() cache.TCache
- func (ps *ProxyState) Snapshot() *ProxySnapshot
- func (ps *ProxyState) Stats() *ProxyStats
- func (ps *ProxyState) WaitForChanges()
- type ProxyStats
- type ProxyStatus
- type RequestContext
- type RequestContextProvider
- type RequestStats
- 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
Types ¶
type LoggerOptions ¶
func WithComponentLogger ¶
func WithComponentLogger(component string) LoggerOptions
func WithDefaultLevel ¶
func WithDefaultLevel(level zerolog.Level) LoggerOptions
type ModuleBuffer ¶
type ModuleBuffer interface { Load(cb func()) Borrow() (ModuleExtractor, bool) Return(me ModuleExtractor) Close() }
func NewModuleBuffer ¶
func NewModuleBuffer( minBuffers, maxBuffers int, reqCtxProvider *RequestContextProvider, createModExts func(*RequestContextProvider) ModuleExtractor, ) (ModuleBuffer, error)
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() // Stop stops the event loop for the module extractor Stop(wait bool) // RuntimeContext returns the runtime context for the module extractor RuntimeContext() modules.RuntimeContext // SetModuleContext sets the module context for the module extractor SetModuleContext(*types.ModuleContext) // ModuleContext returns the module context for the module extractor ModuleContext() *types.ModuleContext // ModHash returns the hash of the module ModHash() uint32 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( runtimeContext modules.RuntimeContext, fetchUpstreamUrl extractors.FetchUpstreamUrlFunc, requestModifier extractors.RequestModifierFunc, responseModifier extractors.ResponseModifierFunc, errorHandler extractors.ErrorHandlerFunc, requestHandler extractors.RequestHandlerFunc, ) ModuleExtractor
type ModuleExtractorFunc ¶
type ModuleExtractorFunc func(*RequestContextProvider) ModuleExtractor
type ProxyHandlerFunc ¶
type ProxyHandlerFunc func(ps *ProxyState, reqCtx *RequestContext)
type ProxyPrinter ¶
type ProxyPrinter struct {
// contains filtered or unexported fields
}
func NewProxyPrinter ¶
func NewProxyPrinter(logger zerolog.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 ProxySnapshot ¶
type ProxySnapshot struct {
ResourceManager *resources.ResourceManager `json:"resource_manager"`
}
func (*ProxySnapshot) PersistState ¶
func (ps *ProxySnapshot) PersistState(w io.Writer) error
type ProxyState ¶
type ProxyState struct { ReverseProxyBuilder reverse_proxy.Builder ProxyTransportBuilder proxy_transport.Builder ProxyHandlerFunc ProxyHandlerFunc // contains filtered or unexported fields }
func NewProxyState ¶
func NewProxyState(conf *config.DGateConfig) *ProxyState
func StartProxyGateway ¶
func StartProxyGateway(conf *config.DGateConfig) (*ProxyState, error)
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) EnableRaft ¶
func (ps *ProxyState) EnableRaft(r *raft.Raft, rc *raft.Config)
func (*ProxyState) FindNamespaceByRequest ¶
func (ps *ProxyState) FindNamespaceByRequest(r *http.Request) *spec.DGateNamespace
func (*ProxyState) GetDocumentByID ¶
func (ps *ProxyState) GetDocumentByID(namespace, collection, docId 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(opts ...LoggerOptions) *zerolog.Logger
func (*ProxyState) ProcessChangeLog ¶
func (ps *ProxyState) ProcessChangeLog(log *spec.ChangeLog, register bool) error
func (*ProxyState) Raft ¶
func (ps *ProxyState) Raft() *raft.Raft
func (*ProxyState) ReloadState ¶
func (ps *ProxyState) ReloadState() error
func (*ProxyState) ResourceManager ¶
func (ps *ProxyState) ResourceManager() *resources.ResourceManager
func (*ProxyState) RestoreState ¶
func (ps *ProxyState) RestoreState(r io.Reader) error
func (*ProxyState) Scheduler ¶
func (ps *ProxyState) Scheduler() scheduler.Scheduler
func (*ProxyState) ServeHTTP ¶
func (ps *ProxyState) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ProxyState) SharedCache ¶
func (ps *ProxyState) SharedCache() cache.TCache
func (*ProxyState) Snapshot ¶
func (ps *ProxyState) Snapshot() *ProxySnapshot
func (*ProxyState) Stats ¶
func (ps *ProxyState) Stats() *ProxyStats
func (*ProxyState) WaitForChanges ¶
func (ps *ProxyState) WaitForChanges()
type ProxyStats ¶
type ProxyStats struct { RouteRequestCount map[string]int64 LastNRequestsDurs []float64 LastNModExtractDurs []float64 // contains filtered or unexported fields }
func NewProxyStats ¶
func NewProxyStats(windowSize int) *ProxyStats
func (*ProxyStats) AddRequestStats ¶
func (ps *ProxyStats) AddRequestStats(rs *RequestStats)
func (*ProxyStats) Snapshot ¶
func (ps *ProxyStats) Snapshot() map[string]any
type ProxyStatus ¶
type ProxyStatus byte
const ( ProxyStatusStarting ProxyStatus = iota ProxyStatusModifying ProxyStatusRunning ProxyStatusStopping ProxyStatusClosed )
type RequestContext ¶
type RequestContext struct {
// contains filtered or unexported fields
}
type RequestContextProvider ¶
type RequestContextProvider struct {
// contains filtered or unexported fields
}
func NewRequestContextProvider ¶
func NewRequestContextProvider(route *spec.DGateRoute) *RequestContextProvider
func (*RequestContextProvider) CreateRequestContext ¶
func (reqCtxProvider *RequestContextProvider) CreateRequestContext( ctx context.Context, rw http.ResponseWriter, req *http.Request, pattern string, ) *RequestContext
func (*RequestContextProvider) SetModuleBuffer ¶
func (reqCtxProvider *RequestContextProvider) SetModuleBuffer(mb ModuleBuffer)
type RequestStats ¶
type RequestStats struct { Service *spec.DGateService Route *spec.DGateRoute UpstreamRequestDur time.Duration MiscDurs map[string]time.Duration }
func NewRequestStats ¶
func NewRequestStats(route *spec.DGateRoute) *RequestStats
func (*RequestStats) AddMiscDuration ¶
func (rs *RequestStats) AddMiscDuration(name string, dur time.Duration)
func (*RequestStats) AddUpstreamRequestDuration ¶
func (rs *RequestStats) AddUpstreamRequestDuration(dur time.Duration)
func (*RequestStats) String ¶
func (rs *RequestStats) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.