MCPcopy
hub / github.com/IBM/sarama / SetHandlerFuncByMap

Method SetHandlerFuncByMap

mockbroker.go:103–109  ·  view source on GitHub ↗

SetHandlerFuncByMap defines mapping of Request types to RequestHandlerFunc. When a request is received by the broker, it looks up the request type in the map and invoke the found RequestHandlerFunc instance to generate an appropriate reply.

(handlerMap map[string]requestHandlerFunc)

Source from the content-addressed store, hash-verified

101// request is received by the broker, it looks up the request type in the map
102// and invoke the found RequestHandlerFunc instance to generate an appropriate reply.
103func (b *MockBroker) SetHandlerFuncByMap(handlerMap map[string]requestHandlerFunc) {
104 fnMap := maps.Clone(handlerMap)
105 b.setHandler(func(req *request) (res encoderWithHeader) {
106 reqTypeName := reflect.TypeOf(req.body).Elem().Name()
107 return fnMap[reqTypeName](req)
108 })
109}
110
111// SetNotifier set a function that will get invoked whenever a request has been
112// processed successfully and will provide the number of bytes read and written

Calls 2

setHandlerMethod · 0.95
NameMethod · 0.65