MCPcopy
hub / github.com/safing/portmaster / GetWorkerInfo

Method GetWorkerInfo

service/debug.go:17–50  ·  view source on GitHub ↗

GetWorkerInfo returns the worker info of all running workers.

()

Source from the content-addressed store, hash-verified

15
16// GetWorkerInfo returns the worker info of all running workers.
17func (i *Instance) GetWorkerInfo() (*mgr.WorkerInfo, error) {
18 snapshot, _, err := stack.ScanSnapshot(bytes.NewReader(fullStack()), io.Discard, stack.DefaultOpts())
19 if err != nil && !errors.Is(err, io.EOF) {
20 return nil, fmt.Errorf("get stack: %w", err)
21 }
22
23 infos := make([]*mgr.WorkerInfo, 0, 32)
24 for _, m := range i.serviceGroup.Modules() {
25 wi, _ := m.Manager().WorkerInfo(snapshot) // Does not fail when we provide a snapshot.
26 infos = append(infos, wi)
27
28 // Check if module is a nested modules group
29 if gm, ok := m.(*mgr.GroupModule); ok {
30 for _, sm := range gm.Modules() {
31 wi, _ := sm.Manager().WorkerInfo(snapshot) // Does not fail when we provide a snapshot.
32 infos = append(infos, wi)
33 }
34 }
35 }
36 for _, m := range i.SpnGroup.Modules() {
37 wi, _ := m.Manager().WorkerInfo(snapshot) // Does not fail when we provide a snapshot.
38 infos = append(infos, wi)
39
40 // Check if module is a nested modules group
41 if gm, ok := m.(*mgr.GroupModule); ok {
42 for _, sm := range gm.Modules() {
43 wi, _ := sm.Manager().WorkerInfo(snapshot) // Does not fail when we provide a snapshot.
44 infos = append(infos, wi)
45 }
46 }
47 }
48
49 return mgr.MergeWorkerInfo(infos...), nil
50}
51
52// AddWorkerInfoToDebugInfo adds the worker info of all running workers to the debug info.
53func (i *Instance) AddWorkerInfoToDebugInfo(di *debug.Info) {

Callers 2

TestDebugFunction · 0.95

Calls 7

MergeWorkerInfoFunction · 0.92
ErrorfMethod · 0.80
fullStackFunction · 0.70
WorkerInfoMethod · 0.65
ManagerMethod · 0.65
IsMethod · 0.45
ModulesMethod · 0.45

Tested by 1

TestDebugFunction · 0.76