mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-05-13 13:04:13 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea977f4634 | |||
| 9d22f9fc47 | |||
| 7367f55fa9 | |||
| 1ac93ebe21 | |||
| 833bd529d6 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
ARG GO_VERSION=1.26.2
|
||||
ARG GO_VERSION=1.26.3
|
||||
FROM golang:${GO_VERSION}-alpine AS build
|
||||
RUN apk --no-cache add ca-certificates tzdata git
|
||||
WORKDIR /build
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/jwetzell/showbridge-go
|
||||
|
||||
go 1.26.2
|
||||
go 1.26.3
|
||||
|
||||
require (
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1
|
||||
@@ -15,9 +15,9 @@ require (
|
||||
github.com/jwetzell/osc-go v0.3.0
|
||||
github.com/jwetzell/psn-go v0.3.0
|
||||
github.com/nats-io/nats-server/v2 v2.14.0
|
||||
github.com/nats-io/nats.go v1.51.0
|
||||
github.com/nats-io/nats.go v1.52.0
|
||||
github.com/redis/go-redis/v9 v9.19.0
|
||||
github.com/urfave/cli/v3 v3.8.0
|
||||
github.com/urfave/cli/v3 v3.9.0
|
||||
gitlab.com/gomidi/midi/v2 v2.3.23
|
||||
go.bug.st/serial v1.6.4
|
||||
go.opentelemetry.io/otel v1.43.0
|
||||
@@ -30,12 +30,12 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op // indirect
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0 // indirect
|
||||
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/creack/goselect v0.1.2 // indirect
|
||||
github.com/creack/goselect v0.1.3 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a // indirect
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240828172851-9145d8ad07e1 // indirect
|
||||
github.com/emiago/dtls/v3 v3.0.0-20260122183559-8b8d23e359c0 // indirect
|
||||
github.com/go-audio/riff v1.0.0 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
@@ -47,10 +47,10 @@ require (
|
||||
github.com/google/go-tpm v0.9.8 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca // indirect
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20260505044615-1ff4bf46051f // indirect
|
||||
github.com/icholy/digest v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.18.5 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/klauspost/compress v1.18.6 // indirect
|
||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
||||
github.com/minio/highwayhash v1.0.4 // indirect
|
||||
github.com/nats-io/jwt/v2 v2.8.1 // indirect
|
||||
github.com/nats-io/nkeys v0.4.15 // indirect
|
||||
@@ -59,13 +59,12 @@ require (
|
||||
github.com/pion/logging v0.2.4 // indirect
|
||||
github.com/pion/randutil v0.1.0 // indirect
|
||||
github.com/pion/rtcp v1.2.16 // indirect
|
||||
github.com/pion/rtp v1.8.26 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.9 // indirect
|
||||
github.com/pion/transport/v3 v3.1.1 // indirect
|
||||
github.com/pion/rtp v1.10.2 // indirect
|
||||
github.com/pion/srtp/v3 v3.0.10 // indirect
|
||||
github.com/pion/transport/v4 v4.0.1 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 // indirect
|
||||
github.com/tetratelabs/wazero v1.9.0 // indirect
|
||||
github.com/tetratelabs/wazero v1.11.0 // indirect
|
||||
github.com/zaf/g711 v1.4.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.43.0 // indirect
|
||||
@@ -73,19 +72,19 @@ require (
|
||||
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.2 // indirect
|
||||
golang.org/x/crypto v0.50.0 // indirect
|
||||
golang.org/x/net v0.52.0 // indirect
|
||||
golang.org/x/crypto v0.51.0 // indirect
|
||||
golang.org/x/net v0.54.0 // indirect
|
||||
golang.org/x/sync v0.20.0 // indirect
|
||||
golang.org/x/sys v0.43.0 // indirect
|
||||
golang.org/x/text v0.36.0 // indirect
|
||||
golang.org/x/sys v0.44.0 // indirect
|
||||
golang.org/x/text v0.37.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9 // indirect
|
||||
google.golang.org/grpc v1.80.0 // indirect
|
||||
google.golang.org/protobuf v1.36.11 // indirect
|
||||
gopkg.in/hraban/opus.v2 v2.0.0-20230925203106-0188a62cb302 // indirect
|
||||
modernc.org/libc v1.72.1 // indirect
|
||||
modernc.org/libquickjs v0.12.6 // indirect
|
||||
modernc.org/libc v1.72.3 // indirect
|
||||
modernc.org/libquickjs v0.12.7 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.11.0 // indirect
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op h1:Z/MZK75wC/NSrkgqeNIa7jexam9uWzhLmFTSCPI/kn0=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0-default-no-op/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0 h1:uWDG8BqLD1lI2ps38WDz2vXflrTX2+vLX0SvZtztJtE=
|
||||
github.com/antithesishq/antithesis-sdk-go v0.7.0/go.mod h1:FQyySiasQQM8735Ddel3MRojmy4dA1IqCeyJ5jmPMbI=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
@@ -8,14 +8,14 @@ github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1x
|
||||
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/creack/goselect v0.1.2 h1:2DNy14+JPjRBgPzAd1thbQp4BSIihxcBf0IXhQXDRa0=
|
||||
github.com/creack/goselect v0.1.2/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
|
||||
github.com/creack/goselect v0.1.3 h1:MaGNMclRo7P2Jl21hBpR1Cn33ITSbKP6E49RtfblLKc=
|
||||
github.com/creack/goselect v0.1.3/go.mod h1:a/NhLweNvqIYMuxcMOuWY516Cimucms3DglDzQP3hKY=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a h1:UwSIFv5g5lIvbGgtf3tVwC7Ky9rmMFBp0RMs+6f6YqE=
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240819160327-2d926c5d788a/go.mod h1:C8DzXehI4zAbrdlbtOByKX6pfivJTBiV9Jjqv56Yd9Q=
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240828172851-9145d8ad07e1 h1:idfl8M8rPW93NehFw5H1qqH8yG158t5POr+LX9avbJY=
|
||||
github.com/dylibso/observe-sdk/go v0.0.0-20240828172851-9145d8ad07e1/go.mod h1:C8DzXehI4zAbrdlbtOByKX6pfivJTBiV9Jjqv56Yd9Q=
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1 h1:/VSOv3oDLlpqR2Epjn1Q7b2bSTplJIeV2ISgCl2W7nE=
|
||||
github.com/eclipse/paho.mqtt.golang v1.5.1/go.mod h1:1/yJCneuyOoCOzKSsOTUc0AJfpsItBGWvYpBLimhArU=
|
||||
github.com/emiago/diago v0.28.0 h1:VCiimhFYLoBTsxH6WrufLSt6tKWG8Fv7LfCkZHqct2E=
|
||||
@@ -61,8 +61,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 h1:HWRh5R2+9EifMyIHV7ZV+MIZqgz
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0/go.mod h1:JfhWUomR1baixubs02l85lZYYOm7LV6om4ceouMv45c=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca h1:T54Ema1DU8ngI+aef9ZhAhNGQhcRTrWxVeG07F+c/Rw=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20240805132620-81f5be970eca/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20260505044615-1ff4bf46051f h1:NW3E2QSchEk63/fjeEvWOa2cE02FSv9ox//VE/N4c8g=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20260505044615-1ff4bf46051f/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
|
||||
github.com/icholy/digest v1.1.0 h1:HfGg9Irj7i+IX1o1QAmPfIBNu/Q5A5Tu3n/MED9k9H4=
|
||||
github.com/icholy/digest v1.1.0/go.mod h1:QNrsSGQ5v7v9cReDI0+eyjsXGUoRSUZQHeQ5C4XLa0Y=
|
||||
github.com/jwetzell/artnet-go v0.2.1 h1:iYTKWcwYrF5kBkYfkw2UbWvoueeA23iKEn7fR27mWZE=
|
||||
@@ -73,24 +73,24 @@ github.com/jwetzell/osc-go v0.3.0 h1:z75TxuQSEmdcmZ56OAepkDa3m88SdZh//3m4nBb/XZI
|
||||
github.com/jwetzell/osc-go v0.3.0/go.mod h1:kCs329JxY6Qjga08tRQ/Gl0PqhgQzLIMpOhm6uszvIc=
|
||||
github.com/jwetzell/psn-go v0.3.0 h1:WVpCEmExYE8a+I5hQak5jNJJp2x35VdGX/VuMUKPmhY=
|
||||
github.com/jwetzell/psn-go v0.3.0/go.mod h1:bcEAeti4sQM375buujb3mIfmUstD4Aby18gq3ENb6+o=
|
||||
github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE=
|
||||
github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
|
||||
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/minio/highwayhash v1.0.4 h1:asJizugGgchQod2ja9NJlGOWq4s7KsAWr5XUc9Clgl4=
|
||||
github.com/minio/highwayhash v1.0.4/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ=
|
||||
github.com/nats-io/jwt/v2 v2.8.1 h1:V0xpGuD/N8Mi+fQNDynXohVvp7ZztevW5io8CUWlPmU=
|
||||
github.com/nats-io/jwt/v2 v2.8.1/go.mod h1:nWnOEEiVMiKHQpnAy4eXlizVEtSfzacZ1Q43LIRavZg=
|
||||
github.com/nats-io/nats-server/v2 v2.14.0 h1:+8q0HrDFotwLLcGH/legOEOnowunhK+aZ4GYBIWpQlM=
|
||||
github.com/nats-io/nats-server/v2 v2.14.0/go.mod h1:ImVUUDvfClJbb6cuJQRc1VmgDCXKM5ds0OoiG9MVOKo=
|
||||
github.com/nats-io/nats.go v1.51.0 h1:ByW84XTz6W03GSSsygsZcA+xgKK8vPGaa/FCAAEHnAI=
|
||||
github.com/nats-io/nats.go v1.51.0/go.mod h1:26HypzazeOkyO3/mqd1zZd53STJN0EjCYF9Uy2ZOBno=
|
||||
github.com/nats-io/nats.go v1.52.0 h1:n3avV4VBsCgsdwh71TppsTwtv+QdPs7ntSKM8qJLGsc=
|
||||
github.com/nats-io/nats.go v1.52.0/go.mod h1:26HypzazeOkyO3/mqd1zZd53STJN0EjCYF9Uy2ZOBno=
|
||||
github.com/nats-io/nkeys v0.4.15 h1:JACV5jRVO9V856KOapQ7x+EY8Jo3qw1vJt/9Jpwzkk4=
|
||||
github.com/nats-io/nkeys v0.4.15/go.mod h1:CpMchTXC9fxA5zrMo4KpySxNjiDVvr8ANOSZdiNfUrs=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
@@ -103,12 +103,10 @@ github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
|
||||
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
|
||||
github.com/pion/rtcp v1.2.16 h1:fk1B1dNW4hsI78XUCljZJlC4kZOPk67mNRuQ0fcEkSo=
|
||||
github.com/pion/rtcp v1.2.16/go.mod h1:/as7VKfYbs5NIb4h6muQ35kQF/J0ZVNz2Z3xKoCBYOo=
|
||||
github.com/pion/rtp v1.8.26 h1:VB+ESQFQhBXFytD+Gk8cxB6dXeVf2WQzg4aORvAvAAc=
|
||||
github.com/pion/rtp v1.8.26/go.mod h1:rF5nS1GqbR7H/TCpKwylzeq6yDM+MM6k+On5EgeThEM=
|
||||
github.com/pion/srtp/v3 v3.0.9 h1:lRGF4G61xxj+m/YluB3ZnBpiALSri2lTzba0kGZMrQY=
|
||||
github.com/pion/srtp/v3 v3.0.9/go.mod h1:E+AuWd7Ug2Fp5u38MKnhduvpVkveXJX6J4Lq4rxUYt8=
|
||||
github.com/pion/transport/v3 v3.1.1 h1:Tr684+fnnKlhPceU+ICdrw6KKkTms+5qHMgw6bIkYOM=
|
||||
github.com/pion/transport/v3 v3.1.1/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
|
||||
github.com/pion/rtp v1.10.2 h1:l+f6tTDcAH6xwepaAoW791ddhuYsJlqRATOzirO04Mo=
|
||||
github.com/pion/rtp v1.10.2/go.mod h1:Au8fc6cEByy8RLTwKTQTEeQqDB/SJDxwL4mZuxYA5Pk=
|
||||
github.com/pion/srtp/v3 v3.0.10 h1:tFirkpBb3XccP5VEXLi50GqXhv5SKPxqrdlhDCJlZrQ=
|
||||
github.com/pion/srtp/v3 v3.0.10/go.mod h1:3mOTIB0cq9qlbn59V4ozvv9ClW/BSEbRp4cY0VtaR7M=
|
||||
github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
|
||||
github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@@ -123,10 +121,10 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834 h1:ZF+QBjOI+tILZjBaFj3HgFonKXUcwgJ4djLb6i42S3Q=
|
||||
github.com/tetratelabs/wabin v0.0.0-20230304001439-f6f874872834/go.mod h1:m9ymHTgNSEjuxvw8E7WWe4Pl4hZQHXONY8wE6dMLaRk=
|
||||
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
|
||||
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
|
||||
github.com/urfave/cli/v3 v3.8.0 h1:XqKPrm0q4P0q5JpoclYoCAv0/MIvH/jZ2umzuf8pNTI=
|
||||
github.com/urfave/cli/v3 v3.8.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA=
|
||||
github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU=
|
||||
github.com/urfave/cli/v3 v3.9.0 h1:AV9lIiPv3ukYnxunaCUsHnEozptYmDN2F0+yWqLMn/c=
|
||||
github.com/urfave/cli/v3 v3.9.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso=
|
||||
github.com/zaf/g711 v1.4.0 h1:XZYkjjiAg9QTBnHqEg37m2I9q3IIDv5JRYXs2N8ma7c=
|
||||
github.com/zaf/g711 v1.4.0/go.mod h1:eCDXt3dSp/kYYAoooba7ukD/Q75jvAaS4WOMr0l1Roo=
|
||||
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
||||
@@ -161,24 +159,24 @@ go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
|
||||
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
|
||||
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
|
||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
|
||||
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
|
||||
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
|
||||
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/crypto v0.51.0 h1:IBPXwPfKxY7cWQZ38ZCIRPI50YLeevDLlLnyC5wRGTI=
|
||||
golang.org/x/crypto v0.51.0/go.mod h1:8AdwkbraGNABw2kOX6YFPs3WM22XqI4EXEd8g+x7Oc8=
|
||||
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
||||
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
||||
golang.org/x/net v0.54.0 h1:2zJIZAxAHV/OHCDTCOHAYehQzLfSXuf/5SoL/Dv6w/w=
|
||||
golang.org/x/net v0.54.0/go.mod h1:Sj4oj8jK6XmHpBZU/zWHw3BV3abl4Kvi+Ut7cQcY+cQ=
|
||||
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
|
||||
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
|
||||
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
|
||||
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
|
||||
golang.org/x/sys v0.44.0 h1:ildZl3J4uzeKP07r2F++Op7E9B29JRUy+a27EibtBTQ=
|
||||
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
|
||||
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
|
||||
golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s=
|
||||
golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
|
||||
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
|
||||
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 h1:VPWxll4HlMw1Vs/qXtN7BvhZqsS9cdAittCNvVENElA=
|
||||
@@ -198,8 +196,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
||||
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
|
||||
modernc.org/cc/v4 v4.28.1 h1:XpLbkYVQ24E8tX5u8+yWGvaxerxkR/S4zqxI8ZoSBuc=
|
||||
modernc.org/cc/v4 v4.28.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/cc/v4 v4.28.2 h1:3tQ0lf2ADtoby2EtSP+J7IE2SHwEJdP8ioR59wx7XpY=
|
||||
modernc.org/cc/v4 v4.28.2/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
|
||||
modernc.org/ccgo/v4 v4.34.0 h1:yRLPFZieg532OT4rp4JFNIVcquwalMX26G95WQDqwCQ=
|
||||
modernc.org/ccgo/v4 v4.34.0/go.mod h1:AS5WYMyBakQ+fhsHhtP8mWB82KTGPkNNJDGfGQCe0/A=
|
||||
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
|
||||
@@ -210,10 +208,10 @@ modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo=
|
||||
modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
|
||||
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
|
||||
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
|
||||
modernc.org/libc v1.72.1 h1:db1xwJ6u1kE3KHTFTTbe2GCrczHPKzlURP0aDC4NGD0=
|
||||
modernc.org/libc v1.72.1/go.mod h1:HRMiC/PhPGLIPM7GzAFCbI+oSgE3dhZ8FWftmRrHVlY=
|
||||
modernc.org/libquickjs v0.12.6 h1:TlABTRLKOFLeY3NxkoHZeLzGBTreA2a3DhmReVON23s=
|
||||
modernc.org/libquickjs v0.12.6/go.mod h1:ajFW8dWHtF8ggFWGbU2BBEM6FI0vemVWrd8nEHAPZpE=
|
||||
modernc.org/libc v1.72.3 h1:ZnDF4tXn4NBXFutMMQC4vtbTFSXhhKzR73fv0beZEAU=
|
||||
modernc.org/libc v1.72.3/go.mod h1:dn0dZNnnn1clLyvRxLxYExxiKRZIRENOfqQ8XEeg4Qs=
|
||||
modernc.org/libquickjs v0.12.7 h1:jSU4+KWDnA6ILat9SAy5zMBSU3Cxtco1NzSJ7DZgCKc=
|
||||
modernc.org/libquickjs v0.12.7/go.mod h1:ajFW8dWHtF8ggFWGbU2BBEM6FI0vemVWrd8nEHAPZpE=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package common
|
||||
|
||||
type contextKey string
|
||||
|
||||
const RouterContextKey contextKey = contextKey("router")
|
||||
const SourceContextKey contextKey = contextKey("source")
|
||||
const ModulesContextKey contextKey = contextKey("modules")
|
||||
const SenderContextKey contextKey = contextKey("sender")
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
type Module interface {
|
||||
Id() string
|
||||
Type() string
|
||||
Start(context.Context) error
|
||||
Start(context.Context, RouteIO) error
|
||||
Stop()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +1,9 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type WrappedPayload struct {
|
||||
Payload any
|
||||
Router RouteIO
|
||||
Modules map[string]Module
|
||||
Sender any
|
||||
Source string
|
||||
End bool
|
||||
}
|
||||
|
||||
func GetWrappedPayload(ctx context.Context, payload any) WrappedPayload {
|
||||
wrappedPayload := WrappedPayload{
|
||||
Payload: payload,
|
||||
End: false,
|
||||
}
|
||||
modules := ctx.Value(ModulesContextKey)
|
||||
if modules != nil {
|
||||
moduleMap, ok := modules.(map[string]Module)
|
||||
if ok {
|
||||
wrappedPayload.Modules = moduleMap
|
||||
} else {
|
||||
wrappedPayload.Modules = make(map[string]Module)
|
||||
}
|
||||
}
|
||||
|
||||
sender := ctx.Value(SenderContextKey)
|
||||
if sender != nil {
|
||||
wrappedPayload.Sender = sender
|
||||
}
|
||||
|
||||
source := ctx.Value(SourceContextKey)
|
||||
if source != nil {
|
||||
wrappedPayload.Source = source.(string)
|
||||
}
|
||||
return wrappedPayload
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/jwetzell/showbridge-go/internal/common"
|
||||
"github.com/jwetzell/showbridge-go/internal/test"
|
||||
)
|
||||
|
||||
func TestGoodGetWrappedPayload(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
ctx context.Context
|
||||
payload any
|
||||
expected common.WrappedPayload
|
||||
}{
|
||||
{
|
||||
name: "basic",
|
||||
ctx: t.Context(),
|
||||
payload: "test",
|
||||
expected: common.WrappedPayload{
|
||||
Payload: "test",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with modules in context",
|
||||
ctx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
payload: "test",
|
||||
expected: common.WrappedPayload{
|
||||
Payload: "test",
|
||||
Modules: map[string]common.Module{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with sender in context",
|
||||
ctx: test.GetContextWithSender(t.Context(), "sender"),
|
||||
payload: "test",
|
||||
expected: common.WrappedPayload{
|
||||
Payload: "test",
|
||||
Sender: "sender",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with source in context",
|
||||
ctx: test.GetContextWithSource(t.Context(), "source"),
|
||||
payload: "test",
|
||||
expected: common.WrappedPayload{
|
||||
Payload: "test",
|
||||
Source: "source",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with all fields in context",
|
||||
ctx: test.GetContextWithSource(
|
||||
test.GetContextWithSender(
|
||||
test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
"sender",
|
||||
),
|
||||
"source",
|
||||
),
|
||||
payload: "test",
|
||||
expected: common.WrappedPayload{
|
||||
Payload: "test",
|
||||
Modules: map[string]common.Module{},
|
||||
Sender: "sender",
|
||||
Source: "source",
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
wrappedPayload := common.GetWrappedPayload(testCase.ctx, testCase.payload)
|
||||
|
||||
if !reflect.DeepEqual(wrappedPayload, testCase.expected) {
|
||||
t.Fatalf("GetWrappedPayload expected got %+v, expected %+v", wrappedPayload, testCase.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package module
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
@@ -32,7 +31,7 @@ func init() {
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"dsn": {
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
},
|
||||
},
|
||||
Required: []string{"dsn"},
|
||||
@@ -59,13 +58,8 @@ func (t *DbSqlite) Type() string {
|
||||
return t.config.Type
|
||||
}
|
||||
|
||||
func (t *DbSqlite) Start(ctx context.Context) error {
|
||||
func (t *DbSqlite) Start(ctx context.Context, router common.RouteIO) error {
|
||||
t.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("db.sqlite unable to get router from context")
|
||||
}
|
||||
t.router = router
|
||||
t.ctx = ctx
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/google/jsonschema-go/jsonschema"
|
||||
@@ -99,10 +98,6 @@ func (hs *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
if hs.router != nil {
|
||||
inputContext := context.WithValue(hs.ctx, httpServerContextKey("responseWriter"), &responseWriter)
|
||||
senderAddr, err := net.ResolveTCPAddr("tcp", r.RemoteAddr)
|
||||
if err == nil {
|
||||
inputContext = context.WithValue(inputContext, common.SenderContextKey, senderAddr)
|
||||
}
|
||||
aRouteFound, routingErrors := hs.router.HandleInput(inputContext, hs.Id(), r)
|
||||
if !responseWriter.done {
|
||||
if aRouteFound {
|
||||
@@ -160,13 +155,8 @@ func (hs *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) Start(ctx context.Context) error {
|
||||
func (hs *HTTPServer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
hs.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("http.server unable to get router from context")
|
||||
}
|
||||
hs.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
hs.ctx = moduleContext
|
||||
|
||||
@@ -4,7 +4,6 @@ package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
@@ -60,14 +59,9 @@ func (mi *MIDIInput) Type() string {
|
||||
return mi.config.Type
|
||||
}
|
||||
|
||||
func (mi *MIDIInput) Start(ctx context.Context) error {
|
||||
func (mi *MIDIInput) Start(ctx context.Context, router common.RouteIO) error {
|
||||
mi.logger.Debug("running")
|
||||
defer midi.CloseDriver()
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("midi.input unable to get router from context")
|
||||
}
|
||||
mi.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
mi.ctx = moduleContext
|
||||
|
||||
@@ -61,14 +61,9 @@ func (mo *MIDIOutput) Type() string {
|
||||
return mo.config.Type
|
||||
}
|
||||
|
||||
func (mo *MIDIOutput) Start(ctx context.Context) error {
|
||||
func (mo *MIDIOutput) Start(ctx context.Context, router common.RouteIO) error {
|
||||
mo.logger.Debug("running")
|
||||
defer midi.CloseDriver()
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("midi.output unable to get router from context")
|
||||
}
|
||||
mo.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
mo.ctx = moduleContext
|
||||
|
||||
@@ -80,13 +80,8 @@ func (mc *MQTTClient) Type() string {
|
||||
return mc.config.Type
|
||||
}
|
||||
|
||||
func (mc *MQTTClient) Start(ctx context.Context) error {
|
||||
func (mc *MQTTClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
mc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("mqtt.client unable to get router from context")
|
||||
}
|
||||
mc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
mc.ctx = moduleContext
|
||||
|
||||
@@ -68,14 +68,8 @@ func (nc *NATSClient) Type() string {
|
||||
return nc.config.Type
|
||||
}
|
||||
|
||||
func (nc *NATSClient) Start(ctx context.Context) error {
|
||||
func (nc *NATSClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
nc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("nats.client unable to get router from context")
|
||||
}
|
||||
|
||||
nc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
nc.ctx = moduleContext
|
||||
|
||||
@@ -86,14 +86,8 @@ func (ns *NATSServer) Type() string {
|
||||
return ns.config.Type
|
||||
}
|
||||
|
||||
func (ns *NATSServer) Start(ctx context.Context) error {
|
||||
func (ns *NATSServer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
ns.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("nats.server unable to get router from context")
|
||||
}
|
||||
|
||||
ns.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
ns.ctx = moduleContext
|
||||
|
||||
@@ -2,7 +2,6 @@ package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net"
|
||||
"time"
|
||||
@@ -40,13 +39,8 @@ func (pc *PSNClient) Type() string {
|
||||
return pc.config.Type
|
||||
}
|
||||
|
||||
func (pc *PSNClient) Start(ctx context.Context) error {
|
||||
func (pc *PSNClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
pc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("psn.client unable to get router from context")
|
||||
}
|
||||
pc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
pc.ctx = moduleContext
|
||||
|
||||
@@ -68,20 +68,14 @@ func (rc *RedisClient) Type() string {
|
||||
return rc.config.Type
|
||||
}
|
||||
|
||||
func (rc *RedisClient) Printf(ctx context.Context, format string, v ...interface{}) {
|
||||
func (rc *RedisClient) Printf(ctx context.Context, format string, v ...any) {
|
||||
msg := fmt.Sprintf(format, v...)
|
||||
rc.logger.Debug(msg)
|
||||
}
|
||||
|
||||
func (rc *RedisClient) Start(ctx context.Context) error {
|
||||
func (rc *RedisClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
redis.SetLogger(rc)
|
||||
rc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("redis.client unable to get router from context")
|
||||
}
|
||||
|
||||
rc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
rc.ctx = moduleContext
|
||||
|
||||
@@ -99,14 +99,8 @@ func (sc *SerialClient) SetupPort() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SerialClient) Start(ctx context.Context) error {
|
||||
func (sc *SerialClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
sc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("serial.client unable to get router from context")
|
||||
}
|
||||
|
||||
sc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
sc.ctx = moduleContext
|
||||
|
||||
@@ -131,13 +131,8 @@ func (scs *SIPCallServer) Type() string {
|
||||
return scs.config.Type
|
||||
}
|
||||
|
||||
func (scs *SIPCallServer) Start(ctx context.Context) error {
|
||||
func (scs *SIPCallServer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
scs.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("sip.call.server unable to get router from context")
|
||||
}
|
||||
scs.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
scs.ctx = moduleContext
|
||||
|
||||
@@ -78,8 +78,8 @@ func init() {
|
||||
"separator": {
|
||||
Title: "DTMF Separator",
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MaxLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
MaxLength: new(1),
|
||||
},
|
||||
},
|
||||
Required: []string{"separator"},
|
||||
@@ -150,13 +150,8 @@ func (sds *SIPDTMFServer) Type() string {
|
||||
return sds.config.Type
|
||||
}
|
||||
|
||||
func (sds *SIPDTMFServer) Start(ctx context.Context) error {
|
||||
func (sds *SIPDTMFServer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
sds.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("sip.dtmf.server unable to get router from context")
|
||||
}
|
||||
sds.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
sds.ctx = moduleContext
|
||||
|
||||
@@ -91,13 +91,8 @@ func (tc *TCPClient) Type() string {
|
||||
return tc.config.Type
|
||||
}
|
||||
|
||||
func (tc *TCPClient) Start(ctx context.Context) error {
|
||||
func (tc *TCPClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
tc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("net.tcp.client unable to get router from context")
|
||||
}
|
||||
tc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
tc.ctx = moduleContext
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -24,7 +25,7 @@ type TCPServer struct {
|
||||
Framer framer.Framer
|
||||
ctx context.Context
|
||||
router common.RouteIO
|
||||
quit chan interface{}
|
||||
quit chan any
|
||||
wg sync.WaitGroup
|
||||
connections []*net.TCPConn
|
||||
connectionsMu sync.RWMutex
|
||||
@@ -90,7 +91,7 @@ func init() {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &TCPServer{Framer: framer, Addr: addr, config: moduleConfig, quit: make(chan interface{}), logger: CreateLogger(moduleConfig)}, nil
|
||||
return &TCPServer{Framer: framer, Addr: addr, config: moduleConfig, quit: make(chan any), logger: CreateLogger(moduleConfig)}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -166,10 +167,9 @@ ClientRead:
|
||||
messages := ts.Framer.Decode(buffer[0:byteCount])
|
||||
for _, message := range messages {
|
||||
if ts.router != nil {
|
||||
senderAddr, ok := client.RemoteAddr().(*net.TCPAddr)
|
||||
_, ok := client.RemoteAddr().(*net.TCPAddr)
|
||||
if ok {
|
||||
senderCtx := context.WithValue(ts.ctx, common.SenderContextKey, senderAddr)
|
||||
ts.router.HandleInput(senderCtx, ts.Id(), message)
|
||||
ts.router.HandleInput(ts.ctx, ts.Id(), message)
|
||||
} else {
|
||||
ts.router.HandleInput(ts.ctx, ts.Id(), message)
|
||||
}
|
||||
@@ -183,13 +183,8 @@ ClientRead:
|
||||
}
|
||||
}
|
||||
|
||||
func (ts *TCPServer) Start(ctx context.Context) error {
|
||||
func (ts *TCPServer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
ts.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("net.tcp.server unable to get router from context")
|
||||
}
|
||||
ts.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
ts.ctx = moduleContext
|
||||
@@ -219,11 +214,9 @@ AcceptLoop:
|
||||
ts.logger.Debug("problem with listener", "error", err)
|
||||
}
|
||||
} else {
|
||||
ts.wg.Add(1)
|
||||
go func() {
|
||||
ts.wg.Go(func() {
|
||||
ts.handleClient(conn)
|
||||
ts.wg.Done()
|
||||
}()
|
||||
})
|
||||
}
|
||||
}
|
||||
ts.wg.Done()
|
||||
@@ -238,20 +231,20 @@ func (ts *TCPServer) Output(ctx context.Context, payload any) error {
|
||||
return errors.New("net.tcp.server is only able to output bytes")
|
||||
}
|
||||
ts.connectionsMu.Lock()
|
||||
errorString := ""
|
||||
var errorString strings.Builder
|
||||
|
||||
for _, connection := range ts.connections {
|
||||
_, err := connection.Write(payloadBytes)
|
||||
if err != nil {
|
||||
errorString += fmt.Sprintf("%s\n", err.Error())
|
||||
errorString.WriteString(fmt.Sprintf("%s\n", err.Error()))
|
||||
}
|
||||
}
|
||||
ts.connectionsMu.Unlock()
|
||||
|
||||
if errorString == "" {
|
||||
if errorString.String() == "" {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("net.tcp.server error during output: %s", errorString)
|
||||
return fmt.Errorf("net.tcp.server error during output: %s", errorString.String())
|
||||
}
|
||||
|
||||
func (ts *TCPServer) Stop() {
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestBadDbSqlite(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("db.sqlite expected to fail")
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestBadHTTPServer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("http.server expected to fail")
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestBadMIDIInput(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.input expected to fail")
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestBadMIDIOutput(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.output expected to fail")
|
||||
|
||||
@@ -116,7 +116,7 @@ func TestBadMQTTClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("mqtt.client expected to fail")
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestBadNATSClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("nats.client expected to fail")
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestBadNATSServer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("nats.server expected to fail")
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestBadPSNClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("psn.client expected to fail")
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestBadRedisClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("redis.client expected to fail")
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestBadSerialClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("serial.client expected to fail")
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestBadSIPCallServer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("sip.call.server expected to fail")
|
||||
|
||||
@@ -107,7 +107,7 @@ func TestBadSIPDTMFServer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("sip.dtmf.server expected to fail")
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestBadTCPClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("net.tcp.client expected to fail")
|
||||
|
||||
@@ -120,7 +120,7 @@ func TestBadTCPServer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("net.tcp.server expected to fail")
|
||||
|
||||
@@ -75,7 +75,7 @@ func TestBadTimeInterval(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("time.interval expected to fail")
|
||||
|
||||
@@ -75,7 +75,7 @@ func TestBadTimeTimer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("time.timer expected to fail")
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestBadUDPClient(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("net.udp.client expected to fail")
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestBadUDPMulticast(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("net.udp.multicast expected to fail")
|
||||
|
||||
@@ -99,7 +99,7 @@ func TestBadUDPServer(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
err = moduleInstance.Start(t.Context())
|
||||
err = moduleInstance.Start(t.Context(), nil)
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("net.udp.server expected to fail")
|
||||
|
||||
@@ -2,7 +2,6 @@ package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"time"
|
||||
@@ -58,13 +57,8 @@ func (i *TimeInterval) Type() string {
|
||||
return i.config.Type
|
||||
}
|
||||
|
||||
func (i *TimeInterval) Start(ctx context.Context) error {
|
||||
func (i *TimeInterval) Start(ctx context.Context, router common.RouteIO) error {
|
||||
i.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("time.interval unable to get router from context")
|
||||
}
|
||||
i.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
i.ctx = moduleContext
|
||||
|
||||
@@ -2,7 +2,6 @@ package module
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"time"
|
||||
@@ -59,13 +58,8 @@ func (t *TimeTimer) Type() string {
|
||||
return t.config.Type
|
||||
}
|
||||
|
||||
func (t *TimeTimer) Start(ctx context.Context) error {
|
||||
func (t *TimeTimer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
t.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("net.tcp.client unable to get router from context")
|
||||
}
|
||||
t.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
t.ctx = moduleContext
|
||||
|
||||
@@ -79,13 +79,8 @@ func (uc *UDPClient) SetupConn() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (uc *UDPClient) Start(ctx context.Context) error {
|
||||
func (uc *UDPClient) Start(ctx context.Context, router common.RouteIO) error {
|
||||
uc.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("net.udp.client unable to get router from context")
|
||||
}
|
||||
uc.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
uc.ctx = moduleContext
|
||||
|
||||
@@ -73,13 +73,8 @@ func (um *UDPMulticast) Type() string {
|
||||
return um.config.Type
|
||||
}
|
||||
|
||||
func (um *UDPMulticast) Start(ctx context.Context) error {
|
||||
func (um *UDPMulticast) Start(ctx context.Context, router common.RouteIO) error {
|
||||
um.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("net.udp.multicast unable to get router from context")
|
||||
}
|
||||
um.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
um.ctx = moduleContext
|
||||
|
||||
@@ -95,13 +95,8 @@ func (us *UDPServer) Type() string {
|
||||
return us.config.Type
|
||||
}
|
||||
|
||||
func (us *UDPServer) Start(ctx context.Context) error {
|
||||
func (us *UDPServer) Start(ctx context.Context, router common.RouteIO) error {
|
||||
us.logger.Debug("running")
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
|
||||
if !ok {
|
||||
return errors.New("net.udp.server unable to get router from context")
|
||||
}
|
||||
us.router = router
|
||||
moduleContext, cancel := context.WithCancel(ctx)
|
||||
us.ctx = moduleContext
|
||||
@@ -124,7 +119,7 @@ func (us *UDPServer) Start(ctx context.Context) error {
|
||||
default:
|
||||
listener.SetDeadline(time.Now().Add(time.Millisecond * 200))
|
||||
|
||||
numBytes, senderAddr, err := listener.ReadFromUDP(buffer)
|
||||
numBytes, _, err := listener.ReadFromUDP(buffer)
|
||||
if err != nil {
|
||||
//NOTE(jwetzell) we hit deadline
|
||||
if opErr, ok := err.(*net.OpError); ok && opErr.Timeout() {
|
||||
@@ -134,8 +129,7 @@ func (us *UDPServer) Start(ctx context.Context) error {
|
||||
}
|
||||
message := buffer[:numBytes]
|
||||
if us.router != nil {
|
||||
senderCtx := context.WithValue(us.ctx, common.SenderContextKey, senderAddr)
|
||||
us.router.HandleInput(senderCtx, us.Id(), message)
|
||||
us.router.HandleInput(us.ctx, us.Id(), message)
|
||||
} else {
|
||||
us.logger.Error("input received but no router is configured")
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ func (dq *DbQuery) Process(ctx context.Context, wrappedPayload common.WrappedPay
|
||||
results := make([]map[string]any, 0)
|
||||
|
||||
for rows.Next() {
|
||||
columnValues := make([]interface{}, len(columns))
|
||||
columnValues := make([]any, len(columns))
|
||||
|
||||
for i := range columnValues {
|
||||
columnValues[i] = new(interface{})
|
||||
columnValues[i] = new(any)
|
||||
}
|
||||
|
||||
if err := rows.Scan(columnValues...); err != nil {
|
||||
@@ -81,7 +81,7 @@ func (dq *DbQuery) Process(ctx context.Context, wrappedPayload common.WrappedPay
|
||||
|
||||
rowMap := make(map[string]any)
|
||||
for i, colName := range columns {
|
||||
value := *columnValues[i].(*interface{})
|
||||
value := *columnValues[i].(*any)
|
||||
rowMap[colName] = value
|
||||
}
|
||||
results = append(results, rowMap)
|
||||
|
||||
@@ -20,14 +20,12 @@ type RouterInput struct {
|
||||
func (ro *RouterInput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
|
||||
payload := wrappedPayload.Payload
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
if !ok {
|
||||
|
||||
if wrappedPayload.Router == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.input no router found")
|
||||
}
|
||||
|
||||
_, err := router.HandleInput(ctx, ro.SourceId, payload)
|
||||
_, err := wrappedPayload.Router.HandleInput(ctx, ro.SourceId, payload)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
|
||||
@@ -19,13 +19,12 @@ type RouterOutput struct {
|
||||
|
||||
func (ro *RouterOutput) Process(ctx context.Context, wrappedPayload common.WrappedPayload) (common.WrappedPayload, error) {
|
||||
|
||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||
if !ok {
|
||||
if wrappedPayload.Router == nil {
|
||||
wrappedPayload.End = true
|
||||
return wrappedPayload, errors.New("router.output no router found")
|
||||
}
|
||||
|
||||
err := router.HandleOutput(ctx, ro.ModuleId, wrappedPayload.Payload)
|
||||
err := wrappedPayload.Router.HandleOutput(ctx, ro.ModuleId, wrappedPayload.Payload)
|
||||
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
|
||||
@@ -34,8 +34,6 @@ func (sj *ScriptJS) Process(ctx context.Context, wrappedPayload common.WrappedPa
|
||||
|
||||
sj.vm.SetProperty(sj.vm.GlobalObject(), sj.payloadAtom, wrappedPayload.Payload)
|
||||
|
||||
sj.vm.SetProperty(sj.vm.GlobalObject(), sj.senderAtom, wrappedPayload.Sender)
|
||||
|
||||
_, err := sj.vm.Eval(sj.Program, quickjs.EvalGlobal)
|
||||
|
||||
if err != nil {
|
||||
@@ -63,12 +61,12 @@ func (sj *ScriptJS) Process(ctx context.Context, wrappedPayload common.WrappedPa
|
||||
outputObject, ok := output.(*quickjs.Object)
|
||||
|
||||
if ok {
|
||||
var outputSlice []interface{}
|
||||
var outputSlice []any
|
||||
|
||||
err = outputObject.Into(&outputSlice)
|
||||
|
||||
if err != nil {
|
||||
var outputMap map[string]interface{}
|
||||
var outputMap map[string]any
|
||||
err = outputObject.Into(&outputMap)
|
||||
if err != nil {
|
||||
wrappedPayload.End = true
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGoodArtnetPacketDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("artnet.packet.decode processing failed: %s", err)
|
||||
@@ -94,7 +94,7 @@ func TestBadArtnetPacketDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("artnet.packet.decode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGoodArtnetPacketEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("artnet.packet.encode processing failed: %s", err)
|
||||
@@ -89,7 +89,7 @@ func TestBadArtnetPacketEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("artnet.packet.encode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -36,12 +35,12 @@ func TestDbQueryFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := map[string]any{"sqlite_version()": "3.53.0"}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Payload: payload,
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
},
|
||||
), payload))
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("db.query processing failed: %s", err)
|
||||
}
|
||||
@@ -115,12 +114,12 @@ func TestGoodDbQuery(t *testing.T) {
|
||||
t.Fatalf("db.query failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
},
|
||||
), testCase.payload))
|
||||
Payload: testCase.payload,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("db.query processing failed: %s", err)
|
||||
@@ -135,11 +134,11 @@ func TestGoodDbQuery(t *testing.T) {
|
||||
|
||||
func TestBadDbQuery(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadModules map[string]common.Module
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
@@ -147,9 +146,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"query": "SELECT sqlite_version();",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -159,9 +158,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": 1,
|
||||
"query": "SELECT sqlite_version();",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query module error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -170,9 +169,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"module": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query query error: not found",
|
||||
},
|
||||
{
|
||||
@@ -182,9 +181,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": 1,
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query query error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -194,9 +193,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from {{",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "template: query:1: unclosed action",
|
||||
},
|
||||
{
|
||||
@@ -206,9 +205,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from {{.Data}}",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "template: query:1:16: executing \"query\" at <.Data>: can't evaluate field Data in type common.WrappedPayload",
|
||||
},
|
||||
{
|
||||
@@ -218,9 +217,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from asdf;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query error executing query: SQL logic error: no such table: asdf (1)",
|
||||
},
|
||||
{
|
||||
@@ -230,8 +229,8 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "db.query wrapped payload has no modules",
|
||||
wrappedPayloadModules: nil,
|
||||
errorString: "db.query wrapped payload has no modules",
|
||||
},
|
||||
{
|
||||
name: "module not found in context",
|
||||
@@ -240,8 +239,8 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not found in context",
|
||||
@@ -250,8 +249,8 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "db.query unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not a DatabseModule",
|
||||
@@ -260,9 +259,9 @@ func TestBadDbQuery(t *testing.T) {
|
||||
"module": "test",
|
||||
"query": "select * from test;",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "db.query module with id test is not a DatabaseModule",
|
||||
},
|
||||
}
|
||||
@@ -287,7 +286,10 @@ func TestBadDbQuery(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.wrappedPayloadCtx, test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Payload: test.payload,
|
||||
Modules: test.wrappedPayloadModules,
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("db.query expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestDebugLogFromRegistry(t *testing.T) {
|
||||
payload := "test"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("debug.log processing failed: %s", err)
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func TestGoodDebugLog(t *testing.T) {
|
||||
t.Fatalf("debug.log failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("debug.log processing failed: %s", err)
|
||||
}
|
||||
@@ -106,7 +106,7 @@ func TestBadDebugLog(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("debug.log expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -29,7 +29,9 @@ func TestFilterChangeFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("filter.change processing failed: %s", err)
|
||||
}
|
||||
@@ -70,7 +72,7 @@ func TestGoodFilterChange(t *testing.T) {
|
||||
t.Fatalf("filter.change failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("filter.change processing failed: %s", err)
|
||||
@@ -110,7 +112,7 @@ func TestBadFilterChange(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("filter.change expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGoodFilterExpr(t *testing.T) {
|
||||
t.Fatalf("filter.expr failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: testCase.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("filter.expr processing failed: %s", err)
|
||||
@@ -159,7 +159,7 @@ func TestBadFilterExpr(t *testing.T) {
|
||||
}
|
||||
return
|
||||
}
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("filter.expr expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestFilterRegexFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("filter.regex processing failed: %s", err)
|
||||
}
|
||||
@@ -90,7 +90,7 @@ func TestGoodFilterRegex(t *testing.T) {
|
||||
t.Fatalf("filter.regex failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("filter.regex processing failed: %s", err)
|
||||
@@ -161,7 +161,7 @@ func TestBadFilterRegex(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("filter.regex expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestGoodFloatParse(t *testing.T) {
|
||||
t.Fatalf("float.parse failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("float.parse processing failed: %s", err)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func TestBadFloatParse(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("float.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestGoodFloatRandom(t *testing.T) {
|
||||
t.Fatalf("float.random failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("float.random processing failed: %s", err)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func TestBadFloatRandom(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("float.random expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -103,7 +103,7 @@ func TestGoodFreeDCreate(t *testing.T) {
|
||||
t.Fatalf("freed.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("freed.create processing failed: %s", err)
|
||||
}
|
||||
@@ -865,7 +865,7 @@ func TestBadFreeDCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("freed.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodFreeDDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("freed.decode processing failed: %s", err)
|
||||
@@ -90,7 +90,7 @@ func TestBadFreeDDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("freed.decode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodFreeDEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("freed.encode processing failed: %s", err)
|
||||
@@ -90,7 +90,7 @@ func TestBadFreeDEncode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := packetEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := packetEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("freed.encode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestGoodHTTPRequestDo(t *testing.T) {
|
||||
t.Fatalf("http.request.do failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("http.request.do processing failed: %s", err)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func TestBadHTTPRequestDo(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("http.request.do expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestGoodHTTPResponseCreate(t *testing.T) {
|
||||
t.Fatalf("http.response.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("http.response.create processing failed: %s", err)
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func TestBadHTTPResponseCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("http.response.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestGoodIntParse(t *testing.T) {
|
||||
t.Fatalf("int.parse failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.parse processing failed: %s", err)
|
||||
}
|
||||
@@ -186,7 +186,7 @@ func TestBadIntParse(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("int.parse expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestIntRandomGoodConfig(t *testing.T) {
|
||||
|
||||
payload := "12345"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.random processing failed: %s", err)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func TestGoodIntRandom(t *testing.T) {
|
||||
t.Fatalf("int.random failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.random processing failed: %s", err)
|
||||
}
|
||||
@@ -183,7 +183,7 @@ func TestBadIntRandom(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("int.random expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestGoodIntScale(t *testing.T) {
|
||||
t.Fatalf("int.scale failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("int.scale processing failed: %s", err)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func TestBadIntScale(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("int.scale expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestJsonDecodeFromRegistry(t *testing.T) {
|
||||
"property": "hello",
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestGoodJsonDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := jsonDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := jsonDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ func TestBadJsonDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("json.decode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -35,7 +35,7 @@ func TestJsonEncodeFromRegistry(t *testing.T) {
|
||||
|
||||
expected := []byte("{\"property\":\"hello\"}")
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func TestGoodJsonEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := jsonEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := jsonEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("json.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -102,7 +102,7 @@ func TestBadJsonEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("json.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -35,12 +34,12 @@ func TestKvGetFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
},
|
||||
), payload))
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("kv.get processing failed: %s", err)
|
||||
}
|
||||
@@ -95,12 +94,12 @@ func TestGoodKvGet(t *testing.T) {
|
||||
t.Fatalf("kv.get failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
},
|
||||
), testCase.payload))
|
||||
Payload: testCase.payload,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("kv.get processing failed: %s", err)
|
||||
@@ -115,11 +114,11 @@ func TestGoodKvGet(t *testing.T) {
|
||||
|
||||
func TestBadKvGet(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadModules map[string]common.Module
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
@@ -127,9 +126,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -139,9 +138,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": 1,
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get module error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -150,9 +149,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
params: map[string]any{
|
||||
"module": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get key error: not found",
|
||||
},
|
||||
{
|
||||
@@ -162,9 +161,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": 1,
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestKVModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get key error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -174,8 +173,8 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "kv.get wrapped payload has no modules",
|
||||
wrappedPayloadModules: nil,
|
||||
errorString: "kv.get wrapped payload has no modules",
|
||||
},
|
||||
{
|
||||
name: "module not found in context",
|
||||
@@ -184,8 +183,8 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "kv.get unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "kv.get unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not a kv module",
|
||||
@@ -194,9 +193,9 @@ func TestBadKvGet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.get module with id test is not a KeyValueModule",
|
||||
},
|
||||
}
|
||||
@@ -221,7 +220,7 @@ func TestBadKvGet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.wrappedPayloadCtx, test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Modules: test.wrappedPayloadModules, Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("kv.get expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -36,12 +35,12 @@ func TestKvSetFromRegistry(t *testing.T) {
|
||||
payload := ""
|
||||
expected := ""
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
},
|
||||
), payload))
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("kv.set processing failed: %s", err)
|
||||
}
|
||||
@@ -86,12 +85,12 @@ func TestGoodKvSet(t *testing.T) {
|
||||
t.Fatalf("kv.set failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithModules(
|
||||
t.Context(),
|
||||
map[string]common.Module{
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Modules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
},
|
||||
), testCase.payload))
|
||||
Payload: testCase.payload,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("kv.set processing failed: %s", err)
|
||||
@@ -106,11 +105,11 @@ func TestGoodKvSet(t *testing.T) {
|
||||
|
||||
func TestBadKvSet(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
wrappedPayloadModules map[string]common.Module
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
@@ -119,9 +118,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set module error: not found",
|
||||
},
|
||||
{
|
||||
@@ -132,9 +131,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set module error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -144,9 +143,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"module": "test",
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set key error: not found",
|
||||
},
|
||||
{
|
||||
@@ -157,9 +156,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": 1,
|
||||
"value": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set key error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -169,9 +168,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"module": "test",
|
||||
"key": "test",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set value error: not found",
|
||||
},
|
||||
{
|
||||
@@ -182,9 +181,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": 1,
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set value error: not a string",
|
||||
},
|
||||
{
|
||||
@@ -195,8 +194,8 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "hello",
|
||||
},
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "kv.set wrapped payload has no modules",
|
||||
wrappedPayloadModules: nil,
|
||||
errorString: "kv.set wrapped payload has no modules",
|
||||
},
|
||||
{
|
||||
name: "value template syntax error",
|
||||
@@ -206,9 +205,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "{{",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "template: template:1: unclosed action",
|
||||
},
|
||||
{
|
||||
@@ -219,9 +218,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "{{.Data}}",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": &test.TestKVModule{},
|
||||
}),
|
||||
},
|
||||
errorString: "template: template:1:2: executing \"template\" at <.Data>: can't evaluate field Data in type common.WrappedPayload",
|
||||
},
|
||||
{
|
||||
@@ -232,8 +231,8 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "hello",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{}),
|
||||
errorString: "kv.set unable to find module with id: test",
|
||||
wrappedPayloadModules: map[string]common.Module{},
|
||||
errorString: "kv.set unable to find module with id: test",
|
||||
},
|
||||
{
|
||||
name: "module not a kv module",
|
||||
@@ -243,9 +242,9 @@ func TestBadKvSet(t *testing.T) {
|
||||
"key": "test",
|
||||
"value": "hello",
|
||||
},
|
||||
wrappedPayloadCtx: test.GetContextWithModules(t.Context(), map[string]common.Module{
|
||||
wrappedPayloadModules: map[string]common.Module{
|
||||
"test": test.NewTestDBModule("test"),
|
||||
}),
|
||||
},
|
||||
errorString: "kv.set module with id test is not a KeyValueModule",
|
||||
},
|
||||
}
|
||||
@@ -270,7 +269,7 @@ func TestBadKvSet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(testCase.wrappedPayloadCtx, testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Modules: testCase.wrappedPayloadModules, Payload: testCase.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("kv.set expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestGoodMIDIControlChangeCreate(t *testing.T) {
|
||||
t.Fatalf("midi.control_change.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.control_change.create processing failed: %s", err)
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func TestBadMIDIControlChangeCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.control_change.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestGoodMIDIMessageDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.message.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestBadMIDIMessageDecode(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.message.decode expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestGoodMIDIMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.message.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func TestBadMIDIMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := midiMessageEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.message.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGoodMIDIMessageUnpack(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.message.unpack processing failed: %s", err)
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func TestBadMIDIMessageUnpack(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.message.unpack expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestGoodMIDINoteOffCretea(t *testing.T) {
|
||||
t.Fatalf("midi.note_off.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.note_off.create processing failed: %s", err)
|
||||
}
|
||||
@@ -146,7 +146,7 @@ func TestBadMIDINoteOffCretea(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.note_off.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestGoodMIDINoteOnCreate(t *testing.T) {
|
||||
t.Fatalf("midi.note_on.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.note_on.create processing failed: %s", err)
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func TestBadMIDINoteOnCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.note_on.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestGoodMIDIProgramChangeCreate(t *testing.T) {
|
||||
t.Fatalf("midi.program_change.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("midi.program_change.create processing failed: %s", err)
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func TestBadMIDIProgramChangeCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("midi.program_change.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestGoodMQTTMessageCreate(t *testing.T) {
|
||||
t.Fatalf("mqtt.message.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("mqtt.message.create processing failed: %s", err)
|
||||
@@ -228,7 +228,7 @@ func TestBadMQTTMessageCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("mqtt.message.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGoodNATSMessageCreate(t *testing.T) {
|
||||
t.Fatalf("nats.message.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("nats.message.create processing failed: %s", err)
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func TestBadNATSMessageCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("nats.message.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and string arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -69,7 +69,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and mixed args",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"arg1", "42", "3.14"},
|
||||
"args": []any{"arg1", "42", "3.14"},
|
||||
"types": "sif",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -86,7 +86,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and int64 arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"42"},
|
||||
"args": []any{"42"},
|
||||
"types": "h",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -96,7 +96,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and double arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{"42"},
|
||||
"args": []any{"42"},
|
||||
"types": "d",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -106,7 +106,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and true arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{""},
|
||||
"args": []any{""},
|
||||
"types": "T",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -116,7 +116,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and false arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{""},
|
||||
"args": []any{""},
|
||||
"types": "F",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -126,7 +126,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "address with template and nil arg",
|
||||
params: map[string]any{
|
||||
"address": "/test/{{.Payload.Value}}",
|
||||
"args": []interface{}{""},
|
||||
"args": []any{""},
|
||||
"types": "N",
|
||||
},
|
||||
payload: map[string]any{"Value": "value"},
|
||||
@@ -136,7 +136,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
name: "blob arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"deadbeef"},
|
||||
"args": []any{"deadbeef"},
|
||||
"types": "b",
|
||||
},
|
||||
payload: "",
|
||||
@@ -160,7 +160,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
||||
t.Fatalf("osc.message.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("osc.message.create processing failed: %s", err)
|
||||
@@ -228,7 +228,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "args without types parameter",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
},
|
||||
payload: "test",
|
||||
errorString: "osc.message.create types error: not found",
|
||||
@@ -237,7 +237,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "args and types length mismatch",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1", "arg2"},
|
||||
"args": []any{"arg1", "arg2"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -247,7 +247,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "non-string arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1", 123},
|
||||
"args": []any{"arg1", 123},
|
||||
"types": "ss",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -257,7 +257,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "bad arg template",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{"},
|
||||
"args": []any{"{{"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -267,7 +267,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "non-string types parameter",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
"types": 123,
|
||||
},
|
||||
payload: "test",
|
||||
@@ -277,7 +277,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "invalid type in types parameter",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"arg1"},
|
||||
"args": []any{"arg1"},
|
||||
"types": "x",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -311,7 +311,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "address template with missing field",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.missing}}"},
|
||||
"args": []any{"{{.missing}}"},
|
||||
"types": "s",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -321,7 +321,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for int arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "i",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -331,7 +331,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for float arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "f",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -341,7 +341,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for blob arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "b",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -351,7 +351,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for int64 arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "h",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -361,7 +361,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
name: "wrong arg type for double arg",
|
||||
params: map[string]any{
|
||||
"address": "/test",
|
||||
"args": []interface{}{"{{.Payload}}"},
|
||||
"args": []any{"{{.Payload}}"},
|
||||
"types": "d",
|
||||
},
|
||||
payload: "test",
|
||||
@@ -388,7 +388,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("osc.message.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestGoodOSCMessageDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("osc.message.decode processing failed: %s", err)
|
||||
@@ -110,7 +110,7 @@ func TestBadOSCMessageDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("osc.message.decode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestGoodOSCMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("osc.message.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func TestBadOSCMessageEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("osc.message.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -35,7 +34,10 @@ func TestRouterOutputFromRegistry(t *testing.T) {
|
||||
payload := "test"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(test.GetContextWithRouter(t.Context()), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Router: test.GetNewTestRouter(),
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("router.output processing failed: %s", err)
|
||||
}
|
||||
@@ -71,7 +73,7 @@ func TestGoodRouterOutput(t *testing.T) {
|
||||
t.Fatalf("router.output failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithRouter(t.Context()), testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: testCase.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("router.output processing failed: %s", err)
|
||||
}
|
||||
@@ -85,40 +87,37 @@ func TestGoodRouterOutput(t *testing.T) {
|
||||
|
||||
func TestBadRouterOutput(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
processCtx context.Context
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
router common.RouteIO
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no module param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.output module error: not found",
|
||||
name: "no module param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
errorString: "router.output module error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string module",
|
||||
params: map[string]any{
|
||||
"module": 123,
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.output module error: not a string",
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
|
||||
errorString: "router.output module error: not a string",
|
||||
},
|
||||
{
|
||||
name: "router not found in context",
|
||||
params: map[string]any{
|
||||
"module": "test",
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: t.Context(),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.output no router found",
|
||||
payload: "test",
|
||||
router: nil,
|
||||
errorString: "router.output no router found",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -142,7 +141,7 @@ func TestBadRouterOutput(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(testCase.processCtx, common.GetWrappedPayload(testCase.wrappedPayloadCtx, testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Router: testCase.router, Payload: testCase.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("router.output expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package processor_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -35,7 +34,10 @@ func TestRouterInputFromRegistry(t *testing.T) {
|
||||
payload := "test"
|
||||
expected := "test"
|
||||
|
||||
got, err := processorInstance.Process(test.GetContextWithRouter(t.Context()), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{
|
||||
Router: test.GetNewTestRouter(),
|
||||
Payload: payload,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("router.input processing failed: %s", err)
|
||||
}
|
||||
@@ -71,7 +73,7 @@ func TestGoodRouterInput(t *testing.T) {
|
||||
t.Fatalf("router.input failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(test.GetContextWithRouter(t.Context()), testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: testCase.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("router.input processing failed: %s", err)
|
||||
}
|
||||
@@ -85,40 +87,36 @@ func TestGoodRouterInput(t *testing.T) {
|
||||
|
||||
func TestBadRouterInput(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
processCtx context.Context
|
||||
wrappedPayloadCtx context.Context
|
||||
errorString string
|
||||
name string
|
||||
params map[string]any
|
||||
payload any
|
||||
router common.RouteIO
|
||||
errorString string
|
||||
}{
|
||||
{
|
||||
name: "no source param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.input source error: not found",
|
||||
name: "no source param",
|
||||
params: map[string]any{},
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
errorString: "router.input source error: not found",
|
||||
},
|
||||
{
|
||||
name: "non-string source",
|
||||
params: map[string]any{
|
||||
"source": 123,
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: test.GetContextWithRouter(t.Context()),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.input source error: not a string",
|
||||
payload: "test",
|
||||
router: test.GetNewTestRouter(),
|
||||
errorString: "router.input source error: not a string",
|
||||
},
|
||||
{
|
||||
name: "router not found in context",
|
||||
params: map[string]any{
|
||||
"source": "test",
|
||||
},
|
||||
payload: "test",
|
||||
processCtx: t.Context(),
|
||||
wrappedPayloadCtx: t.Context(),
|
||||
errorString: "router.input no router found",
|
||||
payload: "test",
|
||||
router: nil,
|
||||
errorString: "router.input no router found",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -142,7 +140,7 @@ func TestBadRouterInput(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(testCase.processCtx, common.GetWrappedPayload(testCase.wrappedPayloadCtx, testCase.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Router: testCase.router, Payload: testCase.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("router.input expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestGoodScriptExpr(t *testing.T) {
|
||||
t.Fatalf("script.expr failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("script.expr processing failed: %s", err)
|
||||
@@ -134,7 +134,7 @@ func TestBadScriptExpr(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("script.expr expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestScriptJSFromRegistry(t *testing.T) {
|
||||
payload := 1
|
||||
expected := 2
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("script.js processing failed: %s", err)
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func TestGoodScriptJS(t *testing.T) {
|
||||
"program": "",
|
||||
},
|
||||
payload: []byte("test"),
|
||||
expected: []interface{}{float64('t'), float64('e'), float64('s'), float64('t')},
|
||||
expected: []any{float64('t'), float64('e'), float64('s'), float64('t')},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func TestGoodScriptJS(t *testing.T) {
|
||||
t.Fatalf("script.js failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("script.js processing failed: %s", err)
|
||||
@@ -209,7 +209,7 @@ func TestBadScriptJS(t *testing.T) {
|
||||
Params: test.params,
|
||||
})
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("script.js expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestGoodScriptWASM(t *testing.T) {
|
||||
t.Fatalf("script.wasm failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("script.wasm processing failed: %s", err)
|
||||
@@ -176,7 +176,7 @@ func TestBadScriptWASM(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("script.wasm expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestGoodSipResponseAudioCreate(t *testing.T) {
|
||||
t.Fatalf("sip.response.audio.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("sip.response.audio.create processing failed: %s", err)
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func TestBadSipResponseAudioCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("sip.response.audio.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -88,7 +88,7 @@ func TestGoodSipResponseDTMFCreate(t *testing.T) {
|
||||
t.Fatalf("sip.response.dtmf.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("sip.response.dtmf.create processing failed: %s", err)
|
||||
}
|
||||
@@ -208,7 +208,7 @@ func TestBadSipResponseDTMFCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("sip.response.dtmf.create expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestStringCreateFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.create processing failed: %s", err)
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func TestGoodStringCreate(t *testing.T) {
|
||||
t.Fatalf("string.create failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("string.create processing failed: %s", err)
|
||||
@@ -174,7 +174,7 @@ func TestBadStringCreate(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.create expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestStringDecodeFromRegistry(t *testing.T) {
|
||||
payload := []byte{'h', 'e', 'l', 'l', 'o'}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func TestGoodStringDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.decode processing failed: %s", err)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func TestBadStringDecode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringDecoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringDecoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.decode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestStringEncodeFromRegistry(t *testing.T) {
|
||||
payload := "hello"
|
||||
expected := []byte{'h', 'e', 'l', 'l', 'o'}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestGoodStringEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.encode processing failed: %s", err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func TestBadStringEncode(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got, err := stringEncoder.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := stringEncoder.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.encode expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestStringSplitFromRegistry(t *testing.T) {
|
||||
payload := "part1,part2,part3"
|
||||
expected := []string{"part1", "part2", "part3"}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.split processing failed: %s", err)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestGoodStringSplit(t *testing.T) {
|
||||
t.Fatalf("string.split failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
if err != nil {
|
||||
t.Fatalf("string.split processing failed: %s", err)
|
||||
}
|
||||
@@ -142,7 +142,7 @@ func TestBadStringSplit(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("string.split expected error but got none, payload: %+v", got)
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestStructFieldGetFromRegistry(t *testing.T) {
|
||||
payload := test.TestStruct{Data: "hello"}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("struct.field.get processing failed: %s", err)
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func TestGoodStructFieldGet(t *testing.T) {
|
||||
t.Fatalf("struct.field.get failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("struct.field.get processing failed: %s", err)
|
||||
@@ -179,7 +179,7 @@ func TestBadStructFieldGet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("struct.field.get expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestStructMethodGetFromRegistry(t *testing.T) {
|
||||
payload := test.TestStruct{Data: "hello"}
|
||||
expected := "hello"
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: payload})
|
||||
if err != nil {
|
||||
t.Fatalf("struct.method.get processing failed: %s", err)
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func TestGoodStructMethodGet(t *testing.T) {
|
||||
t.Fatalf("struct.method.get failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("struct.method.get processing failed: %s", err)
|
||||
@@ -204,7 +204,7 @@ func TestBadStructMethodGet(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("struct.method.get expected to fail but got payload: %+v", got)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestGoodTimeSleep(t *testing.T) {
|
||||
t.Fatalf("time.sleep failed to create processor: %s", err)
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("time.sleep processing failed: %s", err)
|
||||
@@ -114,7 +114,7 @@ func TestBadTimeSleep(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
got, err := processorInstance.Process(t.Context(), common.GetWrappedPayload(t.Context(), test.payload))
|
||||
got, err := processorInstance.Process(t.Context(), common.WrappedPayload{Payload: test.payload})
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("time.sleep expected to fail but succeeded, got: %v", got)
|
||||
|
||||
@@ -43,10 +43,9 @@ func (r *Route) Input() string {
|
||||
return r.input
|
||||
}
|
||||
|
||||
func (r *Route) ProcessPayload(ctx context.Context, payload any) (any, error) {
|
||||
wrappedPayload := common.GetWrappedPayload(ctx, payload)
|
||||
func (r *Route) ProcessPayload(ctx context.Context, wrappedPayload common.WrappedPayload) (any, error) {
|
||||
tracer := otel.Tracer("route")
|
||||
processCtx, processSpan := tracer.Start(ctx, "ProcessPayload", trace.WithAttributes(attribute.String("payload.type", fmt.Sprintf("%T", payload))))
|
||||
processCtx, processSpan := tracer.Start(ctx, "ProcessPayload", trace.WithAttributes(attribute.String("payload.type", fmt.Sprintf("%T", wrappedPayload.Payload))))
|
||||
defer processSpan.End()
|
||||
for processorIndex, processor := range r.processors {
|
||||
processorCtx, processorSpan := otel.Tracer("processor").Start(processCtx, "process", trace.WithAttributes(attribute.Int("processor.index", processorIndex), attribute.String("processor.type", processor.Type())))
|
||||
|
||||
@@ -55,7 +55,10 @@ func TestGoodRouteHandleInput(t *testing.T) {
|
||||
}
|
||||
|
||||
inputData := "test input data"
|
||||
payload, err := testRoute.ProcessPayload(context.WithValue(t.Context(), common.RouterContextKey, &MockRouter{}), inputData)
|
||||
payload, err := testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
Router: &MockRouter{},
|
||||
Payload: inputData,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("route ProcessPayload returned error: %v", err)
|
||||
}
|
||||
@@ -90,7 +93,10 @@ func TestRouteHandleInputWithProcessorError(t *testing.T) {
|
||||
}
|
||||
|
||||
inputData := "test input data"
|
||||
_, err = testRoute.ProcessPayload(context.WithValue(t.Context(), common.RouterContextKey, &MockRouter{}), inputData)
|
||||
_, err = testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
Router: &MockRouter{},
|
||||
Payload: inputData,
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatalf("route HandleOutput did not return error for bad processor")
|
||||
}
|
||||
@@ -115,7 +121,10 @@ func TestRouteHandleNilPayload(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
payload, err := testRoute.ProcessPayload(context.WithValue(t.Context(), common.RouterContextKey, &MockRouter{}), nil)
|
||||
payload, err := testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
Router: &MockRouter{},
|
||||
Payload: nil,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("route ProcessPayload returned error: %v", err)
|
||||
}
|
||||
@@ -143,7 +152,10 @@ func TestRouteHandleNilPayloadFromProcessor(t *testing.T) {
|
||||
t.Fatalf("route failed to create: %v", err)
|
||||
}
|
||||
|
||||
_, err = testRoute.ProcessPayload(context.WithValue(t.Context(), common.RouterContextKey, &MockRouter{}), "test")
|
||||
_, err = testRoute.ProcessPayload(t.Context(), common.WrappedPayload{
|
||||
Router: &MockRouter{},
|
||||
Payload: "test",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("route HandleOutput returned error for nil payload: %v", err)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func GetModulesSchema() *jsonschema.Schema {
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"id": {
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
},
|
||||
"type": {
|
||||
Const: jsonschema.Ptr[any](mod.Type),
|
||||
|
||||
@@ -17,7 +17,7 @@ var RoutesConfigSchema = jsonschema.Schema{
|
||||
Properties: map[string]*jsonschema.Schema{
|
||||
"input": {
|
||||
Type: "string",
|
||||
MinLength: jsonschema.Ptr(1),
|
||||
MinLength: new(1),
|
||||
},
|
||||
"processors": {
|
||||
Ref: "https://showbridge.io/processors.schema.json",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user