Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: assert getters #17052

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions provider/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,34 @@ var registry = reg.New[Provider]("plugin")

// provider types
type (
Provider interface{}
IntProvider interface {
IntGetter() (func() (int64, error), error)
Provider interface{}
Getters interface {
StringProvider
FloatProvider
IntProvider
BoolProvider
}
StringProvider interface {
StringGetter() (func() (string, error), error)
}
FloatProvider interface {
FloatGetter() (func() (float64, error), error)
}
IntProvider interface {
IntGetter() (func() (int64, error), error)
}
BoolProvider interface {
BoolGetter() (func() (bool, error), error)
}
SetIntProvider interface {
IntSetter(param string) (func(int64) error, error)
}
SetStringProvider interface {
StringSetter(param string) (func(string) error, error)
}
SetFloatProvider interface {
FloatSetter(param string) (func(float64) error, error)
}
SetIntProvider interface {
IntSetter(param string) (func(int64) error, error)
}
SetBoolProvider interface {
BoolSetter(param string) (func(bool) error, error)
}
Expand Down
2 changes: 1 addition & 1 deletion provider/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (p *HTTP) request(url string, body string) ([]byte, error) {
return p.val, p.err
}

var _ StringProvider = (*HTTP)(nil)
var _ Getters = (*HTTP)(nil)

// StringGetter sends string request
func (p *HTTP) StringGetter() (func() (string, error), error) {
Expand Down
2 changes: 1 addition & 1 deletion provider/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (m *Mqtt) newReceiver() (*msgHandler, error) {
return h, err
}

var _ StringProvider = (*Mqtt)(nil)
var _ Getters = (*Mqtt)(nil)

// StringGetter creates handler for string from MQTT topic that returns cached value
func (m *Mqtt) StringGetter() (func() (string, error), error) {
Expand Down
2 changes: 1 addition & 1 deletion provider/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (p *Script) exec(script string) (string, error) {
return s, nil
}

var _ StringProvider = (*Script)(nil)
var _ Getters = (*Script)(nil)

// StringGetter returns string from exec result. Only STDOUT is considered.
func (p *Script) StringGetter() (func() (string, error), error) {
Expand Down
2 changes: 1 addition & 1 deletion provider/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (p *Socket) run(errC chan error) {
}
}

var _ StringProvider = (*Socket)(nil)
var _ Getters = (*Socket)(nil)

// StringGetter sends string request
func (p *Socket) StringGetter() (func() (string, error), error) {
Expand Down