MCPcopy Create free account
hub / github.com/CPChain/chain / InstrumentingWrapperMaker

Function InstrumentingWrapperMaker

node/utils_test.go:76–87  ·  view source on GitHub ↗
(base ServiceConstructor, kind reflect.Type)

Source from the content-addressed store, hash-verified

74type InstrumentingWrapper func(base ServiceConstructor) ServiceConstructor
75
76func InstrumentingWrapperMaker(base ServiceConstructor, kind reflect.Type) ServiceConstructor {
77 return func(ctx *ServiceContext) (Service, error) {
78 obj, err := base(ctx)
79 if err != nil {
80 return nil, err
81 }
82 wrapper := reflect.New(kind)
83 wrapper.Elem().Field(0).Set(reflect.ValueOf(obj).Elem())
84
85 return wrapper.Interface().(Service), nil
86 }
87}
88
89// Set of services all wrapping the base InstrumentedService resulting in the
90// same method signatures but different outer types.

Callers 3

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected