forked from GoCodeAlone/modular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfield_tracker_bridge.go
More file actions
39 lines (34 loc) · 1.14 KB
/
field_tracker_bridge.go
File metadata and controls
39 lines (34 loc) · 1.14 KB
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
package modular
import (
"github.com/CrisisTextLine/modular/feeders"
)
// FieldTrackerBridge adapts between the main package's FieldTracker interface
// and the feeders package's FieldTracker interface
type FieldTrackerBridge struct {
mainTracker FieldTracker
}
// NewFieldTrackerBridge creates a new bridge adapter
func NewFieldTrackerBridge(mainTracker FieldTracker) *FieldTrackerBridge {
return &FieldTrackerBridge{
mainTracker: mainTracker,
}
}
// RecordFieldPopulation implements the feeders.FieldTracker interface
// by converting feeders.FieldPopulation to the main package's FieldPopulation
func (b *FieldTrackerBridge) RecordFieldPopulation(fp feeders.FieldPopulation) {
// Convert from feeders.FieldPopulation to main package FieldPopulation
mainFP := FieldPopulation{
FieldPath: fp.FieldPath,
FieldName: fp.FieldName,
FieldType: fp.FieldType,
FeederType: fp.FeederType,
SourceType: fp.SourceType,
SourceKey: fp.SourceKey,
Value: fp.Value,
InstanceKey: fp.InstanceKey,
SearchKeys: fp.SearchKeys,
FoundKey: fp.FoundKey,
}
// Record to the main tracker
b.mainTracker.RecordFieldPopulation(mainFP)
}