mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-05-13 21:14:16 +00:00
chore: go fix
This commit is contained in:
@@ -31,7 +31,7 @@ func init() {
|
|||||||
Properties: map[string]*jsonschema.Schema{
|
Properties: map[string]*jsonschema.Schema{
|
||||||
"dsn": {
|
"dsn": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
MinLength: jsonschema.Ptr(1),
|
MinLength: new(1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Required: []string{"dsn"},
|
Required: []string{"dsn"},
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ func (rc *RedisClient) Type() string {
|
|||||||
return rc.config.Type
|
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...)
|
msg := fmt.Sprintf(format, v...)
|
||||||
rc.logger.Debug(msg)
|
rc.logger.Debug(msg)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ func init() {
|
|||||||
"separator": {
|
"separator": {
|
||||||
Title: "DTMF Separator",
|
Title: "DTMF Separator",
|
||||||
Type: "string",
|
Type: "string",
|
||||||
MinLength: jsonschema.Ptr(1),
|
MinLength: new(1),
|
||||||
MaxLength: jsonschema.Ptr(1),
|
MaxLength: new(1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Required: []string{"separator"},
|
Required: []string{"separator"},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -24,7 +25,7 @@ type TCPServer struct {
|
|||||||
Framer framer.Framer
|
Framer framer.Framer
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
router common.RouteIO
|
router common.RouteIO
|
||||||
quit chan interface{}
|
quit chan any
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
connections []*net.TCPConn
|
connections []*net.TCPConn
|
||||||
connectionsMu sync.RWMutex
|
connectionsMu sync.RWMutex
|
||||||
@@ -90,7 +91,7 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -213,11 +214,9 @@ AcceptLoop:
|
|||||||
ts.logger.Debug("problem with listener", "error", err)
|
ts.logger.Debug("problem with listener", "error", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ts.wg.Add(1)
|
ts.wg.Go(func() {
|
||||||
go func() {
|
|
||||||
ts.handleClient(conn)
|
ts.handleClient(conn)
|
||||||
ts.wg.Done()
|
})
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts.wg.Done()
|
ts.wg.Done()
|
||||||
@@ -232,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")
|
return errors.New("net.tcp.server is only able to output bytes")
|
||||||
}
|
}
|
||||||
ts.connectionsMu.Lock()
|
ts.connectionsMu.Lock()
|
||||||
errorString := ""
|
var errorString strings.Builder
|
||||||
|
|
||||||
for _, connection := range ts.connections {
|
for _, connection := range ts.connections {
|
||||||
_, err := connection.Write(payloadBytes)
|
_, err := connection.Write(payloadBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorString += fmt.Sprintf("%s\n", err.Error())
|
errorString.WriteString(fmt.Sprintf("%s\n", err.Error()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts.connectionsMu.Unlock()
|
ts.connectionsMu.Unlock()
|
||||||
|
|
||||||
if errorString == "" {
|
if errorString.String() == "" {
|
||||||
return nil
|
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() {
|
func (ts *TCPServer) Stop() {
|
||||||
|
|||||||
@@ -68,10 +68,10 @@ func (dq *DbQuery) Process(ctx context.Context, wrappedPayload common.WrappedPay
|
|||||||
results := make([]map[string]any, 0)
|
results := make([]map[string]any, 0)
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
columnValues := make([]interface{}, len(columns))
|
columnValues := make([]any, len(columns))
|
||||||
|
|
||||||
for i := range columnValues {
|
for i := range columnValues {
|
||||||
columnValues[i] = new(interface{})
|
columnValues[i] = new(any)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := rows.Scan(columnValues...); err != nil {
|
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)
|
rowMap := make(map[string]any)
|
||||||
for i, colName := range columns {
|
for i, colName := range columns {
|
||||||
value := *columnValues[i].(*interface{})
|
value := *columnValues[i].(*any)
|
||||||
rowMap[colName] = value
|
rowMap[colName] = value
|
||||||
}
|
}
|
||||||
results = append(results, rowMap)
|
results = append(results, rowMap)
|
||||||
|
|||||||
@@ -61,12 +61,12 @@ func (sj *ScriptJS) Process(ctx context.Context, wrappedPayload common.WrappedPa
|
|||||||
outputObject, ok := output.(*quickjs.Object)
|
outputObject, ok := output.(*quickjs.Object)
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
var outputSlice []interface{}
|
var outputSlice []any
|
||||||
|
|
||||||
err = outputObject.Into(&outputSlice)
|
err = outputObject.Into(&outputSlice)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
var outputMap map[string]interface{}
|
var outputMap map[string]any
|
||||||
err = outputObject.Into(&outputMap)
|
err = outputObject.Into(&outputMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wrappedPayload.End = true
|
wrappedPayload.End = true
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and string arg",
|
name: "address with template and string arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{"arg1"},
|
"args": []any{"arg1"},
|
||||||
"types": "s",
|
"types": "s",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -69,7 +69,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and mixed args",
|
name: "address with template and mixed args",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{"arg1", "42", "3.14"},
|
"args": []any{"arg1", "42", "3.14"},
|
||||||
"types": "sif",
|
"types": "sif",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -86,7 +86,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and int64 arg",
|
name: "address with template and int64 arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{"42"},
|
"args": []any{"42"},
|
||||||
"types": "h",
|
"types": "h",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -96,7 +96,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and double arg",
|
name: "address with template and double arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{"42"},
|
"args": []any{"42"},
|
||||||
"types": "d",
|
"types": "d",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -106,7 +106,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and true arg",
|
name: "address with template and true arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{""},
|
"args": []any{""},
|
||||||
"types": "T",
|
"types": "T",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -116,7 +116,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and false arg",
|
name: "address with template and false arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{""},
|
"args": []any{""},
|
||||||
"types": "F",
|
"types": "F",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -126,7 +126,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address with template and nil arg",
|
name: "address with template and nil arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test/{{.Payload.Value}}",
|
"address": "/test/{{.Payload.Value}}",
|
||||||
"args": []interface{}{""},
|
"args": []any{""},
|
||||||
"types": "N",
|
"types": "N",
|
||||||
},
|
},
|
||||||
payload: map[string]any{"Value": "value"},
|
payload: map[string]any{"Value": "value"},
|
||||||
@@ -136,7 +136,7 @@ func TestGoodOSCMessageCreate(t *testing.T) {
|
|||||||
name: "blob arg",
|
name: "blob arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"deadbeef"},
|
"args": []any{"deadbeef"},
|
||||||
"types": "b",
|
"types": "b",
|
||||||
},
|
},
|
||||||
payload: "",
|
payload: "",
|
||||||
@@ -228,7 +228,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "args without types parameter",
|
name: "args without types parameter",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"arg1"},
|
"args": []any{"arg1"},
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
errorString: "osc.message.create types error: not found",
|
errorString: "osc.message.create types error: not found",
|
||||||
@@ -237,7 +237,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "args and types length mismatch",
|
name: "args and types length mismatch",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"arg1", "arg2"},
|
"args": []any{"arg1", "arg2"},
|
||||||
"types": "s",
|
"types": "s",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -247,7 +247,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "non-string arg",
|
name: "non-string arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"arg1", 123},
|
"args": []any{"arg1", 123},
|
||||||
"types": "ss",
|
"types": "ss",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -257,7 +257,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "bad arg template",
|
name: "bad arg template",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{"},
|
"args": []any{"{{"},
|
||||||
"types": "s",
|
"types": "s",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -267,7 +267,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "non-string types parameter",
|
name: "non-string types parameter",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"arg1"},
|
"args": []any{"arg1"},
|
||||||
"types": 123,
|
"types": 123,
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -277,7 +277,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "invalid type in types parameter",
|
name: "invalid type in types parameter",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"arg1"},
|
"args": []any{"arg1"},
|
||||||
"types": "x",
|
"types": "x",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -311,7 +311,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "address template with missing field",
|
name: "address template with missing field",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{.missing}}"},
|
"args": []any{"{{.missing}}"},
|
||||||
"types": "s",
|
"types": "s",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -321,7 +321,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for int arg",
|
name: "wrong arg type for int arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{.Payload}}"},
|
"args": []any{"{{.Payload}}"},
|
||||||
"types": "i",
|
"types": "i",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -331,7 +331,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for float arg",
|
name: "wrong arg type for float arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{.Payload}}"},
|
"args": []any{"{{.Payload}}"},
|
||||||
"types": "f",
|
"types": "f",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -341,7 +341,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for blob arg",
|
name: "wrong arg type for blob arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{.Payload}}"},
|
"args": []any{"{{.Payload}}"},
|
||||||
"types": "b",
|
"types": "b",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -351,7 +351,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for int64 arg",
|
name: "wrong arg type for int64 arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{.Payload}}"},
|
"args": []any{"{{.Payload}}"},
|
||||||
"types": "h",
|
"types": "h",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
@@ -361,7 +361,7 @@ func TestBadOSCMessageCreate(t *testing.T) {
|
|||||||
name: "wrong arg type for double arg",
|
name: "wrong arg type for double arg",
|
||||||
params: map[string]any{
|
params: map[string]any{
|
||||||
"address": "/test",
|
"address": "/test",
|
||||||
"args": []interface{}{"{{.Payload}}"},
|
"args": []any{"{{.Payload}}"},
|
||||||
"types": "d",
|
"types": "d",
|
||||||
},
|
},
|
||||||
payload: "test",
|
payload: "test",
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ func TestGoodScriptJS(t *testing.T) {
|
|||||||
"program": "",
|
"program": "",
|
||||||
},
|
},
|
||||||
payload: []byte("test"),
|
payload: []byte("test"),
|
||||||
expected: []interface{}{float64('t'), float64('e'), float64('s'), float64('t')},
|
expected: []any{float64('t'), float64('e'), float64('s'), float64('t')},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func GetModulesSchema() *jsonschema.Schema {
|
|||||||
Properties: map[string]*jsonschema.Schema{
|
Properties: map[string]*jsonschema.Schema{
|
||||||
"id": {
|
"id": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
MinLength: jsonschema.Ptr(1),
|
MinLength: new(1),
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
Const: jsonschema.Ptr[any](mod.Type),
|
Const: jsonschema.Ptr[any](mod.Type),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var RoutesConfigSchema = jsonschema.Schema{
|
|||||||
Properties: map[string]*jsonschema.Schema{
|
Properties: map[string]*jsonschema.Schema{
|
||||||
"input": {
|
"input": {
|
||||||
Type: "string",
|
Type: "string",
|
||||||
MinLength: jsonschema.Ptr(1),
|
MinLength: new(1),
|
||||||
},
|
},
|
||||||
"processors": {
|
"processors": {
|
||||||
Ref: "https://showbridge.io/processors.schema.json",
|
Ref: "https://showbridge.io/processors.schema.json",
|
||||||
|
|||||||
Reference in New Issue
Block a user