MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / NewApp

Function NewApp

internal/bootstrap/bootstrap.go:108–168  ·  view source on GitHub ↗

NewApp constructs a new bootstrap application with the specified configuration and a list of options. The configuration is passed from individual command work functions.

(cfg *config.Config, options ...Option)

Source from the content-addressed store, hash-verified

106// and a list of options. The configuration is passed from individual command work
107// functions.
108func NewApp(cfg *config.Config, options ...Option) (*App, error) {
109 if err := InitConfigAndLogger(cfg); err != nil {
110 return nil, err
111 }
112 var opts opts
113 var sigs chan struct{}
114 for _, opt := range options {
115 opt(&opts)
116 }
117 if cfg.DebugPrivilege && opts.setDebugPrivilege {
118 sys.SetDebugPrivilege()
119 }
120 if opts.installSignals {
121 sigs = signals.Install()
122 }
123 if opts.isCaptureReplay {
124 reader, err := cap.NewReader(cfg.CapFile, cfg)
125 if err != nil {
126 return nil, err
127 }
128 app := &App{
129 config: cfg,
130 reader: reader,
131 signals: sigs,
132 }
133 return app, nil
134 }
135
136 hsnap := handle.NewSnapshotter(cfg, opts.handleSnapshotFn)
137 psnap := ps.NewSnapshotter(hsnap, cfg)
138
139 var engine *rules.Engine
140 var rs *config.RulesCompileResult
141
142 if cfg.Filters.Rules.Enabled && !cfg.ForwardMode && !cfg.IsCaptureSet() && !cfg.IsFilamentSet() {
143 engine = rules.NewEngine(psnap, cfg)
144 var err error
145 rs, err = engine.Compile()
146 if err != nil {
147 return nil, err
148 }
149 if rs != nil {
150 log.Infof("rules compile summary: %s", rs)
151 }
152 } else {
153 log.Info("rule engine is disabled")
154 }
155
156 evs := NewEventSourceControl(psnap, hsnap, cfg, rs)
157
158 app := &App{
159 config: cfg,
160 evs: evs,
161 engine: engine,
162 hsnap: hsnap,
163 psnap: psnap,
164 signals: sigs,
165 }

Callers 4

runFunction · 0.92
runMethod · 0.92
captureFunction · 0.92
replayFunction · 0.92

Calls 12

CompileMethod · 0.95
SetDebugPrivilegeFunction · 0.92
InstallFunction · 0.92
NewReaderFunction · 0.92
NewSnapshotterFunction · 0.92
NewSnapshotterFunction · 0.92
NewEngineFunction · 0.92
InitConfigAndLoggerFunction · 0.85
NewEventSourceControlFunction · 0.85
IsCaptureSetMethod · 0.80
IsFilamentSetMethod · 0.80
InfoMethod · 0.80

Tested by

no test coverage detected