MCPcopy Create free account
hub / github.com/apache/thrift / WrapProcessor

Function WrapProcessor

lib/go/thrift/middleware.go:42–52  ·  view source on GitHub ↗

WrapProcessor takes an existing TProcessor and wraps each of its inner TProcessorFunctions with the middlewares passed in and returns it. Middlewares will be called in the order that they are defined: 1. Middlewares[0] 2. Middlewares[1] ... N. Middlewares[n]

(processor TProcessor, middlewares ...ProcessorMiddleware)

Source from the content-addressed store, hash-verified

40// ...
41// N. Middlewares[n]
42func WrapProcessor(processor TProcessor, middlewares ...ProcessorMiddleware) TProcessor {
43 for name, processorFunc := range processor.ProcessorMap() {
44 wrapped := processorFunc
45 // Add middlewares in reverse so the first in the list is the outermost.
46 for i := len(middlewares) - 1; i >= 0; i-- {
47 wrapped = middlewares[i](name, wrapped)
48 }
49 processor.AddToProcessorMap(name, wrapped)
50 }
51 return processor
52}
53
54// WrappedTProcessorFunction is a convenience struct that implements the
55// TProcessorFunction interface that can be used when implementing custom

Callers 4

TestProcessorMiddlewareFunction · 0.92
TestWrapProcessorFunction · 0.85

Calls 2

ProcessorMapMethod · 0.65
AddToProcessorMapMethod · 0.65

Tested by 4

TestProcessorMiddlewareFunction · 0.74
TestWrapProcessorFunction · 0.68