forked from TrueCloudLab/frostfs-node
29 lines
660 B
Go
29 lines
660 B
Go
package net
|
|
|
|
import (
|
|
"net"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/metrics"
|
|
"git.frostfs.info/TrueCloudLab/multinet"
|
|
)
|
|
|
|
var _ multinet.EventHandler = (*metricsEventHandler)(nil)
|
|
|
|
type metricsEventHandler struct {
|
|
m metrics.MultinetMetrics
|
|
}
|
|
|
|
func (m *metricsEventHandler) DialPerformed(sourceIP net.Addr, _ string, _ string, err error) {
|
|
sourceIPString := "undefined"
|
|
if sourceIP != nil {
|
|
sourceIPString = sourceIP.Network() + "://" + sourceIP.String()
|
|
}
|
|
m.m.Dial(sourceIPString, err == nil)
|
|
}
|
|
|
|
func newEventHandler(m metrics.MultinetMetrics) multinet.EventHandler {
|
|
if m == nil {
|
|
return nil
|
|
}
|
|
return &metricsEventHandler{m: m}
|
|
}
|