MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / defineSkip

Function defineSkip

pkg/events/definitions.go:105–128  ·  view source on GitHub ↗

defineSkip registers an event and returns its definition. The argument skip is the number of stack frames to ascend, with 0 identifying the caller of defineSkip.

(name, description string, skip uint, opts ...Option)

Source from the content-addressed store, hash-verified

103// defineSkip registers an event and returns its definition.
104// The argument skip is the number of stack frames to ascend, with 0 identifying the caller of defineSkip.
105func defineSkip(name, description string, skip uint, opts ...Option) Builder {
106 if definitions[name] != nil {
107 panic(fmt.Errorf("Event %q already defined", name))
108 }
109 def := &definition{
110 name: name,
111 description: description,
112 }
113 for _, opt := range opts {
114 if defOpt, ok := opt.(DefinitionOption); ok {
115 defOpt.applyToDefinition(def)
116 }
117 }
118 definitions[name] = def
119
120 i18n.Define(fmt.Sprintf("%s:%s", i18nPrefix, name), description).SetSource(1 + skip)
121 initMetrics(name)
122
123 var b Builder = def
124 if len(opts) > 0 {
125 b = b.With(opts...)
126 }
127 return b
128}
129
130// Define a registered event.
131func Define(name, description string, opts ...Option) Builder {

Callers 2

DefineFunction · 0.85
DefineFuncFunction · 0.85

Calls 6

WithMethod · 0.95
DefineFunction · 0.92
initMetricsFunction · 0.85
SetSourceMethod · 0.80
ErrorfMethod · 0.65
applyToDefinitionMethod · 0.65

Tested by

no test coverage detected