File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ const (
9191 connWriterReconnectOnMsgAttr = "reconnectonmsg"
9292)
9393
94+ // CustomReceiverProducer is the signature of the function CfgParseParams needs to create
95+ // custom receivers.
96+ type CustomReceiverProducer func (CustomReceiverInitArgs ) (CustomReceiver , error )
97+
9498// CfgParseParams represent specific parse options or flags used by parser. It is used if seelog parser needs
9599// some special directives or additional info to correctly parse a config.
96100type CfgParseParams struct {
@@ -114,7 +118,7 @@ type CfgParseParams struct {
114118 // You may use this param to set custom producers in case you need to pass some context when instantiating
115119 // a custom receiver or if you frequently change custom receivers with different parameters or in any other
116120 // situation where package-level registering (RegisterReceiver) is not an option for you.
117- CustomReceiverProducers map [string ]func ( initArgs CustomReceiverInitArgs ) ( CustomReceiver , error )
121+ CustomReceiverProducers map [string ]CustomReceiverProducer
118122}
119123
120124func (cfg * CfgParseParams ) String () string {
Original file line number Diff line number Diff line change @@ -398,11 +398,12 @@ func getParserTests() []parserTest {
398398 testHeadSplitter , _ = newSplitDispatcher (defaultformatter , []interface {}{testCustomReceiver2 })
399399 testExpected .LogType = syncloggerTypeFromString
400400 testExpected .RootDispatcher = testHeadSplitter
401+ fnc := func (initArgs CustomReceiverInitArgs ) (CustomReceiver , error ) {
402+ return & customTestReceiver {}, nil
403+ }
401404 cfg := CfgParseParams {
402- CustomReceiverProducers : map [string ]func (initArgs CustomReceiverInitArgs ) (CustomReceiver , error ){
403- "custom-name-2" : func (initArgs CustomReceiverInitArgs ) (CustomReceiver , error ) {
404- return & customTestReceiver {}, nil
405- },
405+ CustomReceiverProducers : map [string ]CustomReceiverProducer {
406+ "custom-name-2" : CustomReceiverProducer (fnc ),
406407 },
407408 }
408409 testExpected .Params = & cfg
You can’t perform that action at this time.
0 commit comments