@@ -34,18 +34,13 @@ type DataSource interface {
34
34
Start (ctx context.Context ) error
35
35
36
36
// Stop stops the collection process.
37
- Stop () error
38
-
39
- // OutputType returns the type of information collected.
40
- // TODO: this could be made private and excluded from the interface.
41
- // Use will likely be in the context of debugging/logging.
42
- OutputType () reflect.Type
37
+ Stop ()
43
38
44
39
// AddExtractor adds an extractor to the data source.
45
40
// The extractor will be called whenever the data source might
46
41
// have some new raw information regarding an endpoint.
47
- // The Extractor's expected input type is validated when it is
48
- // registered .
42
+ // The Extractor's expected input type should be validated against
43
+ // the data source output type upon registration .
49
44
AddExtractor (extractor Extractor ) error
50
45
51
46
// TODO: the following is useful for a data source that operates on
@@ -102,17 +97,17 @@ func (dsr *DataSourceRegistry) Register(src DataSource) error {
102
97
}
103
98
104
99
// GetNamedSource returns the named data source, if found.
105
- func (dsr * DataSourceRegistry ) GetNamedSource (name string ) (DataSource , error ) {
100
+ func (dsr * DataSourceRegistry ) GetNamedSource (name string ) (DataSource , bool ) {
106
101
if name == "" {
107
- return nil , errors . New ( "unable to retrieve a data source without a name" )
102
+ return nil , false
108
103
}
109
104
110
105
dsr .mu .RLock ()
111
106
defer dsr .mu .RUnlock ()
112
107
if ds , found := dsr .sources [name ]; found {
113
- return ds , nil
108
+ return ds , true
114
109
}
115
- return nil , & NotFoundError { Name : name }
110
+ return nil , false
116
111
}
117
112
118
113
// AddEndpoint adds a new endpoint to all registered sources.
@@ -166,7 +161,7 @@ func RegisterSource(src DataSource) error {
166
161
167
162
// GetNamedSource returns the named source from the default registry,
168
163
// if found.
169
- func GetNamedSource (name string ) (DataSource , error ) {
164
+ func GetNamedSource (name string ) (DataSource , bool ) {
170
165
return DefaultDataSources .GetNamedSource (name )
171
166
}
172
167
@@ -181,17 +176,6 @@ func RemoveEndpoint(ep Endpoint) error {
181
176
return DefaultDataSources .RemoveEndpoint (ep )
182
177
}
183
178
184
- // NotFoundError is an explicit error value raised when a
185
- // source is not found in the requested registry.
186
- type NotFoundError struct {
187
- Name string
188
- }
189
-
190
- // Error returns tha associated error string.
191
- func (e * NotFoundError ) Error () string {
192
- return fmt .Sprintf ("data source not found: %v" , e .Name )
193
- }
194
-
195
179
// ValidateExtractorType checks if an extractor can handle
196
180
// the collector's output.
197
181
func ValidateExtractorType (collectorOutputType , extractorInputType reflect.Type ) error {
0 commit comments