-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
ingress.go
48 lines (38 loc) · 1.42 KB
/
ingress.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package telemetry
import (
"context"
ocrtypes "github.com/smartcontractkit/libocr/commontypes"
"github.com/smartcontractkit/chainlink/v2/core/services/synchronization"
)
var _ MonitoringEndpointGenerator = &IngressAgentWrapper{}
type IngressAgentWrapper struct {
telemetryIngressClient synchronization.TelemetryIngressClient
}
func NewIngressAgentWrapper(telemetryIngressClient synchronization.TelemetryIngressClient) *IngressAgentWrapper {
return &IngressAgentWrapper{telemetryIngressClient}
}
func (t *IngressAgentWrapper) GenMonitoringEndpoint(contractID string, telemType synchronization.TelemetryType) ocrtypes.MonitoringEndpoint {
return NewIngressAgent(t.telemetryIngressClient, contractID, telemType)
}
type IngressAgent struct {
telemetryIngressClient synchronization.TelemetryIngressClient
contractID string
telemType synchronization.TelemetryType
}
func NewIngressAgent(telemetryIngressClient synchronization.TelemetryIngressClient, contractID string, telemType synchronization.TelemetryType) *IngressAgent {
return &IngressAgent{
telemetryIngressClient,
contractID,
telemType,
}
}
// SendLog sends a telemetry log to the ingress server
func (t *IngressAgent) SendLog(telemetry []byte) {
payload := synchronization.TelemPayload{
Ctx: context.Background(),
Telemetry: telemetry,
ContractID: t.contractID,
TelemType: t.telemType,
}
t.telemetryIngressClient.Send(payload)
}