align method receiver variable names

This commit is contained in:
Joel Wetzell
2026-05-20 21:25:30 -05:00
parent 4cedd58a76
commit cf41bcae85
5 changed files with 27 additions and 27 deletions
+4 -4
View File
@@ -18,7 +18,7 @@ type IntScale struct {
config config.ProcessorConfig
}
func (ir *IntScale) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
func (is *IntScale) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
payload := wrappedPayload.Payload
payloadInt, ok := common.GetAnyAs[int](payload)
if !ok {
@@ -26,13 +26,13 @@ func (ir *IntScale) Process(ctx context.Context, wrappedPayload common.WrappedPa
return wrappedPayload, errors.New("int.scale can only process an int")
}
payloadInt = (payloadInt-ir.InMin)*(ir.OutMax-ir.OutMin)/(ir.InMax-ir.InMin) + ir.OutMin
payloadInt = (payloadInt-is.InMin)*(is.OutMax-is.OutMin)/(is.InMax-is.InMin) + is.OutMin
wrappedPayload.Payload = payloadInt
return wrappedPayload, nil
}
func (ir *IntScale) Type() string {
return ir.config.Type
func (is *IntScale) Type() string {
return is.config.Type
}
func init() {
+9 -9
View File
@@ -18,29 +18,29 @@ type ModuleOutput struct {
module common.OutputModule
}
func (ro *ModuleOutput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
func (mo *ModuleOutput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
if ro.module == nil {
if mo.module == nil {
if wrappedPayload.Modules == nil {
wrappedPayload.End = true
return wrappedPayload, errors.New("module.output wrapped payload has no modules")
}
module, ok := wrappedPayload.Modules[ro.ModuleId]
module, ok := wrappedPayload.Modules[mo.ModuleId]
if !ok {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("module.output unable to find module with id: %s", ro.ModuleId)
return wrappedPayload, fmt.Errorf("module.output unable to find module with id: %s", mo.ModuleId)
}
outputModule, ok := module.(common.OutputModule)
if !ok {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("module.output module with id %s is not an OutputModule", ro.ModuleId)
return wrappedPayload, fmt.Errorf("module.output module with id %s is not an OutputModule", mo.ModuleId)
}
ro.module = outputModule
mo.module = outputModule
}
err := ro.module.Output(ctx, wrappedPayload.Payload)
err := mo.module.Output(ctx, wrappedPayload.Payload)
if err != nil {
wrappedPayload.End = true
@@ -50,8 +50,8 @@ func (ro *ModuleOutput) Process(ctx context.Context, wrappedPayload common.Wrapp
return wrappedPayload, nil
}
func (ro *ModuleOutput) Type() string {
return ro.config.Type
func (mo *ModuleOutput) Type() string {
return mo.config.Type
}
func init() {
+4 -4
View File
@@ -17,7 +17,7 @@ type RouterInput struct {
logger *slog.Logger
}
func (ro *RouterInput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
func (ri *RouterInput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
payload := wrappedPayload.Payload
if wrappedPayload.InputHandler == nil {
@@ -25,7 +25,7 @@ func (ro *RouterInput) Process(ctx context.Context, wrappedPayload common.Wrappe
return wrappedPayload, errors.New("router.input no input handler found")
}
_, err := wrappedPayload.InputHandler(ctx, ro.SourceId, payload)
_, err := wrappedPayload.InputHandler(ctx, ri.SourceId, payload)
if err != nil {
wrappedPayload.End = true
@@ -37,8 +37,8 @@ func (ro *RouterInput) Process(ctx context.Context, wrappedPayload common.Wrappe
return wrappedPayload, nil
}
func (ro *RouterInput) Type() string {
return ro.config.Type
func (ri *RouterInput) Type() string {
return ri.config.Type
}
func init() {
+5 -5
View File
@@ -16,7 +16,7 @@ type StructFieldGet struct {
Name string
}
func (sf *StructFieldGet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
func (sfg *StructFieldGet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
payload := wrappedPayload.Payload
s := reflect.ValueOf(payload)
@@ -29,18 +29,18 @@ func (sf *StructFieldGet) Process(ctx context.Context, wrappedPayload common.Wra
}
}
field := s.FieldByName(sf.Name)
field := s.FieldByName(sfg.Name)
if !field.IsValid() {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("struct.field.get field '%s' does not exist", sf.Name)
return wrappedPayload, fmt.Errorf("struct.field.get field '%s' does not exist", sfg.Name)
}
wrappedPayload.Payload = field.Interface()
return wrappedPayload, nil
}
func (sf *StructFieldGet) Type() string {
return sf.config.Type
func (sfg *StructFieldGet) Type() string {
return sfg.config.Type
}
func init() {
+5 -5
View File
@@ -16,7 +16,7 @@ type StructMethodGet struct {
Name string
}
func (sm *StructMethodGet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
func (smg *StructMethodGet) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
payload := wrappedPayload.Payload
s := reflect.ValueOf(payload)
@@ -29,10 +29,10 @@ func (sm *StructMethodGet) Process(ctx context.Context, wrappedPayload common.Wr
}
}
method := s.MethodByName(sm.Name)
method := s.MethodByName(smg.Name)
if !method.IsValid() {
wrappedPayload.End = true
return wrappedPayload, fmt.Errorf("struct.method.get method '%s' does not exist", sm.Name)
return wrappedPayload, fmt.Errorf("struct.method.get method '%s' does not exist", smg.Name)
}
value := method.Call(nil)
@@ -58,8 +58,8 @@ func (sm *StructMethodGet) Process(ctx context.Context, wrappedPayload common.Wr
return wrappedPayload, nil
}
func (sm *StructMethodGet) Type() string {
return sm.config.Type
func (smg *StructMethodGet) Type() string {
return smg.config.Type
}
func init() {