()
| 93 | } |
| 94 | |
| 95 | func (d *Discovery) loadServiceDiscoveryPlugin() error { |
| 96 | var sd service_discovery.ServiceDiscovery |
| 97 | |
| 98 | if val, ok := d.config.ServiceDiscovery["plugin"]; ok { |
| 99 | if sd, ok = val.(service_discovery.ServiceDiscovery); !ok { |
| 100 | return fmt.Errorf("plugin type %T is not a ServiceDiscovery interface", val) |
| 101 | } |
| 102 | } else { |
| 103 | pluginPath, ok := d.config.ServiceDiscovery["path"] |
| 104 | if !ok { |
| 105 | return fmt.Errorf("plugin path could not be found") |
| 106 | } |
| 107 | plug, err := plugin.Open(pluginPath.(string)) |
| 108 | if err != nil { |
| 109 | return fmt.Errorf("failed to open plugin: %w", err) |
| 110 | } |
| 111 | |
| 112 | symDiscovery, err := plug.Lookup("ServiceDiscovery") |
| 113 | if err != nil { |
| 114 | return fmt.Errorf("failed to lookup serviceDiscovery symbol: %w", err) |
| 115 | } |
| 116 | |
| 117 | if sd, ok = symDiscovery.(service_discovery.ServiceDiscovery); !ok { |
| 118 | return fmt.Errorf("unable to assert type to serviceDiscovery") |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | if err := sd.SetConfig(d.config.ServiceDiscovery); err != nil { |
| 123 | return err |
| 124 | } |
| 125 | sd.SetLogger(d.config.Logger) |
| 126 | if err := sd.Initialize(); err != nil { |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | d.serviceDiscovery = sd |
| 131 | return nil |
| 132 | } |
| 133 | |
| 134 | // increaseUptimeSeconds calls UptimeSeconds.Increase function every second. |
| 135 | func (d *Discovery) increaseUptimeSeconds() { |
no test coverage detected