mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
rename filter.unique to filter.change
This commit is contained in:
@@ -8,32 +8,32 @@ import (
|
|||||||
"github.com/jwetzell/showbridge-go/internal/config"
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FilterUnique struct {
|
type FilterChange struct {
|
||||||
config config.ProcessorConfig
|
config config.ProcessorConfig
|
||||||
previous any
|
previous any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fr *FilterUnique) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
func (fc *FilterChange) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||||
payload := wrappedPayload.Payload
|
payload := wrappedPayload.Payload
|
||||||
|
|
||||||
if reflect.DeepEqual(payload, fr.previous) {
|
if reflect.DeepEqual(payload, fc.previous) {
|
||||||
wrappedPayload.End = true
|
wrappedPayload.End = true
|
||||||
return wrappedPayload, nil
|
return wrappedPayload, nil
|
||||||
}
|
}
|
||||||
fr.previous = payload
|
fc.previous = payload
|
||||||
|
|
||||||
return wrappedPayload, nil
|
return wrappedPayload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fr *FilterUnique) Type() string {
|
func (fc *FilterChange) Type() string {
|
||||||
return fr.config.Type
|
return fc.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterProcessor(ProcessorRegistration{
|
RegisterProcessor(ProcessorRegistration{
|
||||||
Type: "filter.unique",
|
Type: "filter.change",
|
||||||
New: func(config config.ProcessorConfig) (Processor, error) {
|
New: func(config config.ProcessorConfig) (Processor, error) {
|
||||||
return &FilterUnique{config: config}, nil
|
return &FilterChange{config: config}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user