Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerProps ¶
type InterceptorCallbackMiddleware ¶
type InterceptorCallbackMiddleware interface {
Middleware
OnInterceptorRequest(ctx context.Context, method string)
}
type Middleware ¶
type Middleware interface {
GetLogger() logger.MomentoLogger
GetBaseRequestHandler(theRequest interface{}, requestName string, resourceName string) (RequestHandler, error)
GetRequestHandler(baseRequestHandler RequestHandler) (RequestHandler, error)
GetIncludeTypes() map[string]bool
}
func NewMiddleware ¶
func NewMiddleware(props Props) Middleware
NewMiddleware creates a new middleware with a logger and optional list of request types it should handle. If the IncludeTypes are omitted or empty, all request types will be processed. For example, to limit processing to only requests of type *momento.SetRequest and *momento.GetRequest, pass the following slice as the IncludeTypes:
[]interface{}{momento.SetRequest{}, momento.GetRequest{}}
Custom middleware implementations can use this constructor to create and store the base middleware:
type myMiddleware struct {
middleware.Middleware
requestCount atomic.Int64
}
type Props ¶
type Props struct {
Logger logger.MomentoLogger
IncludeTypes []interface{}
}
type RequestHandler ¶
type RequestHandler interface {
GetId() uuid.UUID
GetRequest() interface{}
GetRequestName() string
GetResourceName() string
GetLogger() logger.MomentoLogger
OnRequest(theRequest interface{}) (interface{}, error)
OnMetadata(map[string]string) map[string]string
OnResponse(theResponse interface{}) (interface{}, error)
}
RequestHandler is an interface that represents the capabilities of a middleware request handler. Custom request handlers will generally only need to implement the OnRequest and OnResponse methods.
func NewRequestHandler ¶
func NewRequestHandler(props HandlerProps) RequestHandler
type TopicEventCallbackMiddleware ¶ added in v1.35.0
type TopicEventCallbackMiddleware interface {
TopicMiddleware
OnTopicEvent(cacheName string, method string, event TopicSubscriptionEventType)
}
type TopicMiddleware ¶ added in v1.35.0
type TopicMiddleware interface {
GetLogger() logger.MomentoLogger
OnSubscribeMetadata(map[string]string) map[string]string
OnPublishMetadata(map[string]string) map[string]string
}
func NewTopicMiddleware ¶ added in v1.35.0
func NewTopicMiddleware(props Props) TopicMiddleware
type TopicMiddlewareProps ¶ added in v1.35.0
type TopicMiddlewareProps struct {
Logger logger.MomentoLogger
}
type TopicSubscriptionEventType ¶ added in v1.35.0
type TopicSubscriptionEventType string
const ( HEARTBEAT TopicSubscriptionEventType = "heartbeat" ITEM TopicSubscriptionEventType = "item" DISCONTINUITY TopicSubscriptionEventType = "discontinuity" RECONNECT TopicSubscriptionEventType = "reconnect" ERROR TopicSubscriptionEventType = "error" )