github.com/netdata/go.d.plugin@v0.58.1/modules/systemdunits/client.go (about) 1 // SPDX-License-Identifier: GPL-3.0-or-later 2 3 //go:build linux 4 // +build linux 5 6 package systemdunits 7 8 import ( 9 "context" 10 11 "github.com/coreos/go-systemd/v22/dbus" 12 ) 13 14 type systemdClient interface { 15 connect() (systemdConnection, error) 16 } 17 type systemdConnection interface { 18 Close() 19 GetManagerProperty(string) (string, error) 20 ListUnitsContext(ctx context.Context) ([]dbus.UnitStatus, error) 21 ListUnitsByPatternsContext(ctx context.Context, states []string, patterns []string) ([]dbus.UnitStatus, error) 22 } 23 24 type systemdDBusClient struct{} 25 26 func (systemdDBusClient) connect() (systemdConnection, error) { 27 return dbus.NewWithContext(context.Background()) 28 } 29 30 func newSystemdDBusClient() *systemdDBusClient { 31 return &systemdDBusClient{} 32 }