middlewares

package
v0.0.0-...-8f56db8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheMiddleware

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

CacheMiddleware for monitoror * * We need two types of Cache. * - UpstreamCache : serves as a circuit breaker to answer before executing the request. (By default, short TTL) * - DownstreamCache : serves as backup to answer the old result in case of service timeout. (By default, long TTL) * * UpstreamCache must be implemented on some routes only (and with variable expiration). * He is implemented as a decorator on the handler of each route * * DownstreamCache should be used instead of a timeout response. * So we look at the cache in the global error handler (see handlers/errors.go) * * To fill both store at the same time, I implemented a store wrapper that performs every actions on both store

func NewCacheMiddleware

func NewCacheMiddleware(store cache.Store, downstreamDefaultExpiration, upstreamDefaultExpiration time.Duration) *CacheMiddleware

NewCacheMiddleware used config to instantiate CacheMiddleware

func (*CacheMiddleware) DownstreamStoreMiddleware

func (cm *CacheMiddleware) DownstreamStoreMiddleware() echo.MiddlewareFunc

DownstreamStoreMiddleware Provide Downstream Store to all route. Used when route return timeout error

func (*CacheMiddleware) UpstreamCacheHandler

func (cm *CacheMiddleware) UpstreamCacheHandler(handle echo.HandlerFunc) echo.HandlerFunc

UpstreamCacheHandler return the cached response if he finds it in the store. (Decorator Handlers)

func (*CacheMiddleware) UpstreamCacheHandlerWithExpiration

func (cm *CacheMiddleware) UpstreamCacheHandlerWithExpiration(expire time.Duration, handle echo.HandlerFunc) echo.HandlerFunc

UpstreamCacheHandlerWithExpiration return the cached response if he finds it in the store. (Decorator Handlers)

Jump to

Keyboard shortcuts

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