mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
cleanup logging
This commit is contained in:
@@ -27,29 +27,29 @@ func init() {
|
|||||||
host, ok := params["host"]
|
host, ok := params["host"]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp client requires a host parameter")
|
return nil, fmt.Errorf("net.tcp.client requires a host parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
hostString, ok := host.(string)
|
hostString, ok := host.(string)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp client host must be uint16")
|
return nil, fmt.Errorf("net.tcp.client host must be uint16")
|
||||||
}
|
}
|
||||||
|
|
||||||
port, ok := params["port"]
|
port, ok := params["port"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp client requires a port parameter")
|
return nil, fmt.Errorf("net.tcp.client requires a port parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
portNum, ok := port.(float64)
|
portNum, ok := port.(float64)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp client port must be uint16")
|
return nil, fmt.Errorf("net.tcp.client port must be uint16")
|
||||||
}
|
}
|
||||||
|
|
||||||
framingMethod, ok := params["framing"]
|
framingMethod, ok := params["framing"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp client requires a framing method")
|
return nil, fmt.Errorf("net.tcp.client requires a framing method")
|
||||||
}
|
}
|
||||||
|
|
||||||
framingMethodString, ok := framingMethod.(string)
|
framingMethodString, ok := framingMethod.(string)
|
||||||
@@ -132,7 +132,7 @@ func (tc *TCPClient) Run(ctx context.Context) error {
|
|||||||
if tc.router != nil {
|
if tc.router != nil {
|
||||||
tc.router.HandleInput(tc.config.Id, message)
|
tc.router.HandleInput(tc.config.Id, message)
|
||||||
} else {
|
} else {
|
||||||
slog.Error("tcp-client has no router", "id", tc.config.Id)
|
slog.Error("net.tcp.client has no router", "id", tc.config.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ func (tc *TCPClient) Output(payload any) error {
|
|||||||
if tc.conn != nil {
|
if tc.conn != nil {
|
||||||
payloadBytes, ok := payload.([]byte)
|
payloadBytes, ok := payload.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("tcp-client is only able to output bytes")
|
return fmt.Errorf("net.tcp.client is only able to output bytes")
|
||||||
}
|
}
|
||||||
_, err := tc.conn.Write(tc.framer.Encode(payloadBytes))
|
_, err := tc.conn.Write(tc.framer.Encode(payloadBytes))
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -23,18 +23,18 @@ func init() {
|
|||||||
params := config.Params
|
params := config.Params
|
||||||
port, ok := params["port"]
|
port, ok := params["port"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp server requires a port parameter")
|
return nil, fmt.Errorf("net.tcp.server requires a port parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
portNum, ok := port.(float64)
|
portNum, ok := port.(float64)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp server port must be uint16")
|
return nil, fmt.Errorf("net.tcp.server port must be uint16")
|
||||||
}
|
}
|
||||||
|
|
||||||
framingMethod, ok := params["framing"]
|
framingMethod, ok := params["framing"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("tcp server requires a framing method")
|
return nil, fmt.Errorf("net.tcp.server requires a framing method")
|
||||||
}
|
}
|
||||||
|
|
||||||
framingMethodString, ok := framingMethod.(string)
|
framingMethodString, ok := framingMethod.(string)
|
||||||
@@ -129,5 +129,5 @@ func (ts TCPServer) Run(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *TCPServer) Output(payload any) error {
|
func (ts *TCPServer) Output(payload any) error {
|
||||||
return fmt.Errorf("tcp-server output is not implemented")
|
return fmt.Errorf("net.tcp.server output is not implemented")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,24 +23,24 @@ func init() {
|
|||||||
host, ok := params["host"]
|
host, ok := params["host"]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("udp client requires a host parameter")
|
return nil, fmt.Errorf("net.udp.client requires a host parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
hostString, ok := host.(string)
|
hostString, ok := host.(string)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("udp client host must be uint16")
|
return nil, fmt.Errorf("net.udp.client host must be uint16")
|
||||||
}
|
}
|
||||||
|
|
||||||
port, ok := params["port"]
|
port, ok := params["port"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("udp client requires a port parameter")
|
return nil, fmt.Errorf("net.udp.client requires a port parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
portNum, ok := port.(float64)
|
portNum, ok := port.(float64)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("udp client port must be uint16")
|
return nil, fmt.Errorf("net.udp.client port must be uint16")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &UDPClient{Host: hostString, Port: uint16(portNum), config: config}, nil
|
return &UDPClient{Host: hostString, Port: uint16(portNum), config: config}, nil
|
||||||
@@ -80,7 +80,7 @@ func (uc *UDPClient) Output(payload any) error {
|
|||||||
if uc.conn != nil {
|
if uc.conn != nil {
|
||||||
payloadBytes, ok := payload.([]byte)
|
payloadBytes, ok := payload.([]byte)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("udp-client is only able to output bytes")
|
return fmt.Errorf("net.udp.client is only able to output bytes")
|
||||||
}
|
}
|
||||||
_, err := uc.conn.Write(payloadBytes)
|
_, err := uc.conn.Write(payloadBytes)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ func init() {
|
|||||||
params := config.Params
|
params := config.Params
|
||||||
port, ok := params["port"]
|
port, ok := params["port"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("udp server requires a port parameter")
|
return nil, fmt.Errorf("net.udp.server requires a port parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
portNum, ok := port.(float64)
|
portNum, ok := port.(float64)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("udp server port must be uint16")
|
return nil, fmt.Errorf("net.udp.server port must be uint16")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &UDPServer{Port: uint16(portNum), config: config}, nil
|
return &UDPServer{Port: uint16(portNum), config: config}, nil
|
||||||
@@ -75,7 +75,7 @@ func (us *UDPServer) Run(ctx context.Context) error {
|
|||||||
if us.router != nil {
|
if us.router != nil {
|
||||||
us.router.HandleInput(us.config.Id, message)
|
us.router.HandleInput(us.config.Id, message)
|
||||||
} else {
|
} else {
|
||||||
slog.Error("tcp-server has no router", "id", us.config.Id)
|
slog.Error("net.udp.server has no router", "id", us.config.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,5 +83,5 @@ func (us *UDPServer) Run(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (us *UDPServer) Output(payload any) error {
|
func (us *UDPServer) Output(payload any) error {
|
||||||
return fmt.Errorf("udp-server output is not implemented")
|
return fmt.Errorf("net.udp.server output is not implemented")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user