@@ -17,24 +17,24 @@ const (
17
17
)
18
18
19
19
// ExporterConfig holds the configuration for an individual exporter
20
- type ExporterConfig struct {
20
+ type Config struct {
21
21
Exporter CommonExporter
22
22
FlushInterval time.Duration
23
23
MaxEventInMemory int64
24
24
}
25
25
26
26
// ExporterState maintains the state for a single exporter
27
- type ExporterState struct {
28
- config ExporterConfig
27
+ type State struct {
28
+ config Config
29
29
ticker * time.Ticker
30
30
lastIndex int // Index of the last processed event
31
31
}
32
32
33
33
// Scheduler handles data collection for one or more exporters
34
34
type Scheduler struct {
35
35
sharedCache []FeatureEvent
36
- bulkExporters map [CommonExporter ]* ExporterState // Only bulk exporters that need periodic flushing
37
- directExporters []CommonExporter // Non-bulk exporters that flush immediately
36
+ bulkExporters map [CommonExporter ]* State // Only bulk exporters that need periodic flushing
37
+ directExporters []CommonExporter // Non-bulk exporters that flush immediately
38
38
mutex sync.Mutex
39
39
daemonChan chan struct {}
40
40
logger * fflog.FFLogger
@@ -46,22 +46,22 @@ func NewScheduler(ctx context.Context, flushInterval time.Duration, maxEventInMe
46
46
exp CommonExporter , logger * fflog.FFLogger ,
47
47
) * Scheduler {
48
48
// Convert single exporter parameters to ExporterConfig
49
- config := ExporterConfig {
49
+ config := Config {
50
50
Exporter : exp ,
51
51
FlushInterval : flushInterval ,
52
52
MaxEventInMemory : maxEventInMemory ,
53
53
}
54
- return NewMultiScheduler (ctx , []ExporterConfig {config }, logger )
54
+ return NewMultiScheduler (ctx , []Config {config }, logger )
55
55
}
56
56
57
57
// NewMultiScheduler creates a scheduler that handles multiple exporters
58
- func NewMultiScheduler (ctx context.Context , exporterConfigs []ExporterConfig , logger * fflog.FFLogger ,
58
+ func NewMultiScheduler (ctx context.Context , exporterConfigs []Config , logger * fflog.FFLogger ,
59
59
) * Scheduler {
60
60
if ctx == nil {
61
61
ctx = context .Background ()
62
62
}
63
63
64
- bulkExporters := make (map [CommonExporter ]* ExporterState )
64
+ bulkExporters := make (map [CommonExporter ]* State )
65
65
directExporters := make ([]CommonExporter , 0 )
66
66
67
67
for _ , config := range exporterConfigs {
@@ -73,7 +73,7 @@ func NewMultiScheduler(ctx context.Context, exporterConfigs []ExporterConfig, lo
73
73
}
74
74
75
75
if config .Exporter .IsBulk () {
76
- state := & ExporterState {
76
+ state := & State {
77
77
config : config ,
78
78
lastIndex : - 1 ,
79
79
ticker : time .NewTicker (config .FlushInterval ),
@@ -130,15 +130,15 @@ func (s *Scheduler) AddEvent(event FeatureEvent) {
130
130
}
131
131
132
132
// getPendingEvents returns events that haven't been processed by this exporter
133
- func (s * Scheduler ) getPendingEvents (state * ExporterState ) []FeatureEvent {
133
+ func (s * Scheduler ) getPendingEvents (state * State ) []FeatureEvent {
134
134
if state .lastIndex + 1 >= len (s .sharedCache ) {
135
135
return nil
136
136
}
137
137
return s .sharedCache [state .lastIndex + 1 :]
138
138
}
139
139
140
140
// flushExporter sends pending events to the specified exporter
141
- func (s * Scheduler ) flushExporter (state * ExporterState ) {
141
+ func (s * Scheduler ) flushExporter (state * State ) {
142
142
pendingEvents := s .getPendingEvents (state )
143
143
if len (pendingEvents ) == 0 {
144
144
return
0 commit comments