-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
component.go
64 lines (48 loc) · 1.96 KB
/
component.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
// Package server implements a component to run the dogstatsd capture/replay
//
//nolint:revive // TODO(AML) Fix revive linter
package replay
import (
"time"
"go.uber.org/fx"
"github.com/DataDog/datadog-agent/comp/dogstatsd/packets"
"github.com/DataDog/datadog-agent/pkg/util/fxutil"
)
// team: agent-metrics-logs
// Component is the component type.
type Component interface {
// IsOngoing returns whether a capture is ongoing for this TrafficCapture instance.
IsOngoing() bool
// StartCapture starts a TrafficCapture and returns an error in the event of an issue.
StartCapture(p string, d time.Duration, compressed bool) (string, error)
// StopCapture stops an ongoing TrafficCapture.
StopCapture()
// TODO: (components) pool manager should be injected as a component in the future.
// RegisterSharedPoolManager registers the shared pool manager with the TrafficCapture.
RegisterSharedPoolManager(p *packets.PoolManager) error
// TODO: (components) pool manager should be injected as a component in the future.
// RegisterOOBPoolManager registers the OOB shared pool manager with the TrafficCapture.f
RegisterOOBPoolManager(p *packets.PoolManager) error
// Enqueue enqueues a capture buffer so it's written to file.
Enqueue(msg *CaptureBuffer) bool
// GetStartUpError returns an error if TrafficCapture failed to start up
GetStartUpError() error
}
// Mock implements mock-specific methods.
type Mock interface {
Component
}
// Module defines the fx options for this component.
func Module() fxutil.Module {
return fxutil.Component(
fx.Provide(newTrafficCapture))
}
// MockModule defines the fx options for the mock component.
func MockModule() fxutil.Module {
return fxutil.Component(
fx.Provide(newMockTrafficCapture))
}