inlet/outlet: add compile-time interface implementation check

For "plugins" only.
This commit is contained in:
Vincent Bernat
2025-09-02 22:28:28 +02:00
parent 1bdfbd9994
commit c155d34a43
7 changed files with 39 additions and 4 deletions

View File

@@ -22,12 +22,17 @@ import (
type Input struct { type Input struct {
r *reporter.Reporter r *reporter.Reporter
t tomb.Tomb t tomb.Tomb
config *Configuration config Configuration
send input.SendFunc send input.SendFunc
} }
var (
_ input.Input = &Input{}
_ input.Configuration = Configuration{}
)
// New instantiate a new UDP listener from the provided configuration. // New instantiate a new UDP listener from the provided configuration.
func (configuration *Configuration) New(r *reporter.Reporter, daemon daemon.Component, send input.SendFunc) (input.Input, error) { func (configuration Configuration) New(r *reporter.Reporter, daemon daemon.Component, send input.SendFunc) (input.Input, error) {
if len(configuration.Paths) == 0 { if len(configuration.Paths) == 0 {
return nil, errors.New("no paths provided for file input") return nil, errors.New("no paths provided for file input")
} }

View File

@@ -25,7 +25,7 @@ import (
type Input struct { type Input struct {
r *reporter.Reporter r *reporter.Reporter
t tomb.Tomb t tomb.Tomb
config *Configuration config Configuration
metrics struct { metrics struct {
bytes *reporter.CounterVec bytes *reporter.CounterVec
@@ -40,8 +40,13 @@ type Input struct {
send input.SendFunc // function to send to kafka send input.SendFunc // function to send to kafka
} }
var (
_ input.Input = &Input{}
_ input.Configuration = Configuration{}
)
// New instantiate a new UDP listener from the provided configuration. // New instantiate a new UDP listener from the provided configuration.
func (configuration *Configuration) New(r *reporter.Reporter, daemon daemon.Component, send input.SendFunc) (input.Input, error) { func (configuration Configuration) New(r *reporter.Reporter, daemon daemon.Component, send input.SendFunc) (input.Input, error) {
input := &Input{ input := &Input{
r: r, r: r,
config: configuration, config: configuration,

View File

@@ -24,6 +24,11 @@ type Provider struct {
refresh chan bool refresh chan bool
} }
var (
_ provider.Provider = &Provider{}
_ provider.Configuration = Configuration{}
)
// New creates a new gNMI provider from configuration // New creates a new gNMI provider from configuration
func (configuration Configuration) New(r *reporter.Reporter) (provider.Provider, error) { func (configuration Configuration) New(r *reporter.Reporter) (provider.Provider, error) {
p := Provider{ p := Provider{

View File

@@ -28,6 +28,11 @@ type Provider struct {
} }
} }
var (
_ provider.Provider = &Provider{}
_ provider.Configuration = Configuration{}
)
// New creates a new SNMP provider from configuration // New creates a new SNMP provider from configuration
func (configuration Configuration) New(r *reporter.Reporter) (provider.Provider, error) { func (configuration Configuration) New(r *reporter.Reporter) (provider.Provider, error) {
for exporterIP, agentIP := range configuration.Agents { for exporterIP, agentIP := range configuration.Agents {

View File

@@ -35,6 +35,11 @@ type Provider struct {
} }
} }
var (
_ provider.Provider = &Provider{}
_ provider.Configuration = Configuration{}
)
// New creates a new static provider from configuration // New creates a new static provider from configuration
func (configuration Configuration) New(r *reporter.Reporter) (provider.Provider, error) { func (configuration Configuration) New(r *reporter.Reporter) (provider.Provider, error) {
p := &Provider{ p := &Provider{

View File

@@ -63,6 +63,11 @@ type Provider struct {
// Dependencies define the dependencies of the BioRIS Provider. // Dependencies define the dependencies of the BioRIS Provider.
type Dependencies = provider.Dependencies type Dependencies = provider.Dependencies
var (
_ provider.Provider = &Provider{}
_ provider.Configuration = Configuration{}
)
// New creates a new BioRIS provider. // New creates a new BioRIS provider.
func (configuration Configuration) New(r *reporter.Reporter, dependencies Dependencies) (provider.Provider, error) { func (configuration Configuration) New(r *reporter.Reporter, dependencies Dependencies) (provider.Provider, error) {
p := Provider{ p := Provider{

View File

@@ -44,6 +44,11 @@ type Provider struct {
// Dependencies define the dependencies of the BMP component. // Dependencies define the dependencies of the BMP component.
type Dependencies = provider.Dependencies type Dependencies = provider.Dependencies
var (
_ provider.Provider = &Provider{}
_ provider.Configuration = Configuration{}
)
// New creates a new BMP component from its configuration. // New creates a new BMP component from its configuration.
func (configuration Configuration) New(r *reporter.Reporter, dependencies Dependencies) (provider.Provider, error) { func (configuration Configuration) New(r *reporter.Reporter, dependencies Dependencies) (provider.Provider, error) {
if dependencies.Clock == nil { if dependencies.Clock == nil {