This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit b9c1d4509ae211834232597ce89b57fd1d65f1d2
Author: Sebastian Rühl <[email protected]>
AuthorDate: Fri Nov 14 13:36:02 2025 +0100

    feat(plc4go)!: simplify ping
---
 plc4go/internal/knxnetip/Connection.go             |  39 ++---
 plc4go/internal/modbus/Connection.go               |  81 +++++----
 plc4go/internal/simulated/Connection.go            |  78 ++++-----
 plc4go/internal/simulated/Connection_test.go       |  38 ++---
 plc4go/internal/simulated/Driver_test.go           |   3 +-
 plc4go/pkg/api/PlcConnection.go                    |   2 +-
 plc4go/pkg/api/cache/PlcConnectionCache_test.go    |  66 +++++---
 plc4go/pkg/api/cache/mocks_test.go                 |  35 ++--
 plc4go/pkg/api/cache/plcConnectionLease.go         |  23 +--
 plc4go/pkg/api/cache/plcConnectionLease_test.go    |   4 +-
 plc4go/pkg/api/mocks_test.go                       |  35 ++--
 plc4go/spi/default/DefaultConnection.go            |  21 +--
 plc4go/spi/default/DefaultConnection_test.go       |  89 ++--------
 .../spi/default/DefaultPlcConnectionPingResult.go  |  41 -----
 .../defaultPlcConnectionPingResult_plc4xgen.go     |  75 ---------
 plc4go/spi/default/mocks_test.go                   | 185 +++++----------------
 16 files changed, 264 insertions(+), 551 deletions(-)

diff --git a/plc4go/internal/knxnetip/Connection.go 
b/plc4go/internal/knxnetip/Connection.go
index 9c6260f22c..0fe2108cff 100644
--- a/plc4go/internal/knxnetip/Connection.go
+++ b/plc4go/internal/knxnetip/Connection.go
@@ -34,12 +34,10 @@ import (
        "github.com/pkg/errors"
        "github.com/rs/zerolog"
 
-       "github.com/apache/plc4x/plc4go/pkg/api"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/pkg/api/values"
        driverModel 
"github.com/apache/plc4x/plc4go/protocols/knxnetip/readwrite/model"
        "github.com/apache/plc4x/plc4go/spi"
-       _default "github.com/apache/plc4x/plc4go/spi/default"
        "github.com/apache/plc4x/plc4go/spi/interceptors"
        spiModel "github.com/apache/plc4x/plc4go/spi/model"
        "github.com/apache/plc4x/plc4go/spi/options"
@@ -407,39 +405,22 @@ func (m *Connection) IsConnected() bool {
        defer cancelFunc()
 
        if m.messageCodec != nil {
-               pingChannel := m.Ping()
-               select {
-               case pingResponse := <-pingChannel:
-                       return pingResponse.GetErr() == nil
-               case <-ctx.Done():
-                       m.handleTimeout()
+               if err := m.Ping(ctx); err != nil {
+                       if errors.Is(err, context.DeadlineExceeded) {
+                               m.handleTimeout()
+                       }
                        return false
                }
        }
        return false
 }
 
-func (m *Connection) Ping() <-chan plc4go.PlcConnectionPingResult {
-       ctx := context.TODO()
-       result := make(chan plc4go.PlcConnectionPingResult, 1)
-
-       m.wg.Go(func() {
-               defer func() {
-                       if err := recover(); err != nil {
-                               result <- 
_default.NewDefaultPlcConnectionPingResult(errors.Errorf("panic-ed %v. Stack: 
%s", err, debug.Stack()))
-                       }
-               }()
-               // Send the connection state request
-               _, err := m.sendConnectionStateRequest(ctx)
-               if err != nil {
-                       result <- 
_default.NewDefaultPlcConnectionPingResult(errors.Wrap(err, "got an error"))
-               } else {
-                       result <- 
_default.NewDefaultPlcConnectionPingResult(nil)
-               }
-               return
-       })
-
-       return result
+func (m *Connection) Ping(ctx context.Context) error {
+       // Send the connection state request
+       if _, err := m.sendConnectionStateRequest(ctx); err != nil {
+               return errors.Wrap(err, "got an error")
+       }
+       return nil
 }
 
 func (m *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
diff --git a/plc4go/internal/modbus/Connection.go 
b/plc4go/internal/modbus/Connection.go
index b02c41801f..329d4c140f 100644
--- a/plc4go/internal/modbus/Connection.go
+++ b/plc4go/internal/modbus/Connection.go
@@ -22,7 +22,6 @@ package modbus
 import (
        "context"
        "fmt"
-       "runtime/debug"
        "sync"
 
        "github.com/pkg/errors"
@@ -105,44 +104,56 @@ func (c *Connection) GetMessageCodec() spi.MessageCodec {
        return c.messageCodec
 }
 
-func (c *Connection) Ping() <-chan plc4go.PlcConnectionPingResult {
-       ctx := context.TODO()
+func (c *Connection) Ping(ctx context.Context) error {
        c.log.Trace().Msg("Pinging")
-       result := make(chan plc4go.PlcConnectionPingResult, 1)
-       c.wg.Go(func() {
-               defer func() {
-                       if err := recover(); err != nil {
-                               result <- 
_default.NewDefaultPlcConnectionPingResult(errors.Errorf("panic-ed %v. Stack: 
%s", err, debug.Stack()))
-                       }
-               }()
-               diagnosticRequestPdu := 
readWriteModel.NewModbusPDUDiagnosticRequest(0, 0x42)
-               pingRequest := readWriteModel.NewModbusTcpADU(1, 
c.unitIdentifier, diagnosticRequestPdu)
-               if err := c.messageCodec.SendRequest(ctx, pingRequest, 
func(message spi.Message) bool {
-                       responseAdu, ok := message.(readWriteModel.ModbusTcpADU)
-                       if !ok {
-                               return false
+       errChan := make(chan error, 1)
+       successChan := make(chan struct{}, 1)
+       diagnosticRequestPdu := readWriteModel.NewModbusPDUDiagnosticRequest(0, 
0x42)
+       pingRequest := readWriteModel.NewModbusTcpADU(1, c.unitIdentifier, 
diagnosticRequestPdu)
+       if err := c.messageCodec.SendRequest(ctx, pingRequest, func(message 
spi.Message) bool {
+               responseAdu, ok := message.(readWriteModel.ModbusTcpADU)
+               if !ok {
+                       return false
+               }
+               return responseAdu.GetTransactionIdentifier() == 1 && 
responseAdu.GetUnitIdentifier() == c.unitIdentifier
+       }, func(message spi.Message) error {
+               c.log.Trace().Msg("Received Message")
+               if message != nil {
+                       // If we got a valid response (even if it will probably 
contain an error, we know the remote is available)
+                       c.log.Trace().Msg("got valid response")
+                       select {
+                       case successChan <- struct{}{}:
+                       default:
+                               c.log.Warn().Msg("failed to send success 
signal")
                        }
-                       return responseAdu.GetTransactionIdentifier() == 1 && 
responseAdu.GetUnitIdentifier() == c.unitIdentifier
-               }, func(message spi.Message) error {
-                       c.log.Trace().Msg("Received Message")
-                       if message != nil {
-                               // If we got a valid response (even if it will 
probably contain an error, we know the remote is available)
-                               c.log.Trace().Msg("got valid response")
-                               result <- 
_default.NewDefaultPlcConnectionPingResult(nil)
-                       } else {
-                               c.log.Trace().Msg("got no response")
-                               result <- 
_default.NewDefaultPlcConnectionPingResult(errors.New("no response"))
+               } else {
+                       c.log.Trace().Msg("got no response")
+                       select {
+                       case errChan <- errors.New("no response"):
+                       default:
+                               c.log.Warn().Msg("failed to send error signal")
                        }
-                       return nil
-               }, func(err error) error {
-                       c.log.Trace().Msg("Received Error")
-                       result <- 
_default.NewDefaultPlcConnectionPingResult(errors.Wrap(err, "got error 
processing request"))
-                       return nil
-               }); err != nil {
-                       result <- 
_default.NewDefaultPlcConnectionPingResult(err)
                }
-       })
-       return result
+               return nil
+       }, func(err error) error {
+               c.log.Trace().Msg("Received Error")
+               select {
+               case errChan <- errors.Wrap(err, "got error processing 
request"):
+               default:
+                       c.log.Warn().Msg("failed to send error signal")
+               }
+               return nil
+       }); err != nil {
+               return errors.Wrap(err, "error sending ping request")
+       }
+       select {
+       case err := <-errChan:
+               return errors.Wrap(err, "got error while waiting for response")
+       case <-successChan:
+               return nil
+       case <-ctx.Done():
+               return ctx.Err()
+       }
 }
 
 func (c *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
diff --git a/plc4go/internal/simulated/Connection.go 
b/plc4go/internal/simulated/Connection.go
index ae346a962a..9452a1d694 100644
--- a/plc4go/internal/simulated/Connection.go
+++ b/plc4go/internal/simulated/Connection.go
@@ -21,7 +21,6 @@ package simulated
 
 import (
        "context"
-       "runtime/debug"
        "strconv"
        "sync"
        "time"
@@ -29,7 +28,6 @@ import (
        "github.com/pkg/errors"
        "github.com/rs/zerolog"
 
-       "github.com/apache/plc4x/plc4go/pkg/api"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/spi"
        _default "github.com/apache/plc4x/plc4go/spi/default"
@@ -165,53 +163,47 @@ func (c *Connection) IsConnected() bool {
        return c.connected
 }
 
-func (c *Connection) Ping() <-chan plc4go.PlcConnectionPingResult {
-       ch := make(chan plc4go.PlcConnectionPingResult, 1)
-       c.wg.Go(func() {
-               defer func() {
-                       if err := recover(); err != nil {
-                               ch <- 
_default.NewDefaultPlcConnectionPingResult(errors.Errorf("panic-ed %v. Stack: 
%s", err, debug.Stack()))
+func (c *Connection) Ping(ctx context.Context) error {
+       // Check if the connection is connected
+       if !c.connected {
+               if c.tracer != nil {
+                       c.tracer.AddTrace("ping", "error: not connected")
+               }
+               return errors.New("not connected")
+       }
+       var txId string
+       if c.tracer != nil {
+               txId = c.tracer.AddTransactionalStartTrace("ping", "started")
+       }
+       if delayString, ok := c.options["pingDelay"]; ok {
+               // This is the length of the array, not the string
+               if len(delayString) == 1 {
+                       delay, err := strconv.Atoi(delayString[0])
+                       if err != nil {
+                               return errors.Wrapf(err, "invalid delay '%s'", 
delayString[0])
                        }
-               }()
-               // Check if the connection is connected
-               if !c.connected {
-                       if c.tracer != nil {
-                               c.tracer.AddTrace("ping", "error: not 
connected")
+                       timer := time.NewTimer(time.Duration(delay) * 
time.Millisecond)
+                       c.log.Info().Msgf("Ping delay of %d ms", delay)
+                       select {
+                       case <-timer.C:
+                       case <-ctx.Done():
+                               return ctx.Err()
                        }
-                       // Return an error to the user.
-                       ch <- 
_default.NewDefaultPlcConnectionPingResult(errors.New("not connected"))
-                       return
                }
-               var txId string
+       }
+       if errorString, ok := c.options["pingError"]; ok {
+               // If the ping operation should fail with an error, do so.
                if c.tracer != nil {
-                       txId = c.tracer.AddTransactionalStartTrace("ping", 
"started")
+                       c.tracer.AddTransactionalTrace(txId, "ping", "error: 
"+errorString[0])
                }
-               if delayString, ok := c.options["pingDelay"]; ok {
-                       // This is the length of the array, not the string
-                       if len(delayString) == 1 {
-                               delay, err := strconv.Atoi(delayString[0])
-                               if err == nil {
-                                       time.Sleep(time.Duration(delay) * 
time.Millisecond)
-                               }
-                       }
-               }
-               if errorString, ok := c.options["pingError"]; ok {
-                       // If the ping operation should fail with an error, do 
so.
-                       if len(errorString) == 1 {
-                               ch <- 
_default.NewDefaultPlcConnectionPingResult(errors.New(errorString[0]))
-                       }
-                       if c.tracer != nil {
-                               c.tracer.AddTransactionalTrace(txId, "ping", 
"error: "+errorString[0])
-                       }
-               } else {
-                       // Otherwise, give a positive response.
-                       if c.tracer != nil {
-                               c.tracer.AddTransactionalTrace(txId, "ping", 
"success")
-                       }
-                       ch <- _default.NewDefaultPlcConnectionPingResult(nil)
+               return errors.New(errorString[0])
+       } else {
+               // Otherwise, give a positive response.
+               if c.tracer != nil {
+                       c.tracer.AddTransactionalTrace(txId, "ping", "success")
                }
-       })
-       return ch
+               return nil
+       }
 }
 
 func (c *Connection) GetMetadata() apiModel.PlcConnectionMetadata {
diff --git a/plc4go/internal/simulated/Connection_test.go 
b/plc4go/internal/simulated/Connection_test.go
index 8350841ff0..52e79df9a6 100644
--- a/plc4go/internal/simulated/Connection_test.go
+++ b/plc4go/internal/simulated/Connection_test.go
@@ -27,7 +27,6 @@ import (
 
        "github.com/stretchr/testify/assert"
 
-       "github.com/apache/plc4x/plc4go/pkg/api"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/spi"
        _default "github.com/apache/plc4x/plc4go/spi/default"
@@ -345,10 +344,14 @@ func TestConnection_Ping(t *testing.T) {
                options      map[string][]string
                connected    bool
        }
+       type args struct {
+               ctx context.Context
+       }
        tests := []struct {
                name         string
                fields       fields
-               want         plc4go.PlcConnectionPingResult
+               args         args
+               wantErr      assert.ErrorAssertionFunc
                delayAtLeast time.Duration
        }{
                {
@@ -360,7 +363,10 @@ func TestConnection_Ping(t *testing.T) {
                                options:      map[string][]string{},
                                connected:    true,
                        },
-                       want:         
_default.NewDefaultPlcConnectionPingResult(nil),
+                       args: args{
+                               ctx: t.Context(),
+                       },
+                       wantErr:      assert.NoError,
                        delayAtLeast: 0,
                },
                {
@@ -374,7 +380,10 @@ func TestConnection_Ping(t *testing.T) {
                                },
                                connected: true,
                        },
-                       want:         
_default.NewDefaultPlcConnectionPingResult(nil),
+                       args: args{
+                               ctx: t.Context(),
+                       },
+                       wantErr:      assert.NoError,
                        delayAtLeast: 1000,
                },
        }
@@ -387,25 +396,8 @@ func TestConnection_Ping(t *testing.T) {
                                options:      tt.fields.options,
                                connected:    tt.fields.connected,
                        }
-                       timeBeforePing := time.Now()
-                       pingChan := c.Ping()
-                       select {
-                       case pingResult := <-pingChan:
-                               timeAfterPing := time.Now()
-                               // If an expected delay was defined, check if 
closing
-                               // took at least this long.
-                               if tt.delayAtLeast > 0 {
-                                       pingTime := 
timeAfterPing.Sub(timeBeforePing)
-                                       if pingTime < tt.delayAtLeast {
-                                               t.Errorf("TestConnection.Ping() 
completed too fast. Expected at least %v but returned after %v", 
tt.delayAtLeast, pingTime)
-                                       }
-                               }
-                               if !assert.Equal(t, tt.want, pingResult) {
-                                       t.Errorf("TestConnection.Ping() = %v, 
want %v", pingResult, tt.want)
-                               }
-                       case <-t.Context().Done():
-                               t.Errorf("TestConnection.Ping() got timeout")
-                       }
+                       err := c.Ping(tt.args.ctx)
+                       tt.wantErr(t, err)
                })
        }
 }
diff --git a/plc4go/internal/simulated/Driver_test.go 
b/plc4go/internal/simulated/Driver_test.go
index a6bfb28948..22904d6c0d 100644
--- a/plc4go/internal/simulated/Driver_test.go
+++ b/plc4go/internal/simulated/Driver_test.go
@@ -23,11 +23,12 @@ import (
        "net/url"
        "testing"
 
+       "github.com/stretchr/testify/assert"
+
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/spi/options"
        "github.com/apache/plc4x/plc4go/spi/testutils"
        "github.com/apache/plc4x/plc4go/spi/transports"
-       "github.com/stretchr/testify/assert"
 )
 
 func TestDriver_CheckQuery(t *testing.T) {
diff --git a/plc4go/pkg/api/PlcConnection.go b/plc4go/pkg/api/PlcConnection.go
index 9295c7675b..c24cdd2697 100644
--- a/plc4go/pkg/api/PlcConnection.go
+++ b/plc4go/pkg/api/PlcConnection.go
@@ -37,7 +37,7 @@ type PlcConnection interface {
        IsConnected() bool
 
        // Ping Executes a no-op operation to check if the current connection 
is still able to communicate
-       Ping() <-chan PlcConnectionPingResult
+       Ping(ctx context.Context) error
 
        // GetMetadata Get some metadata regarding the current connection
        GetMetadata() model.PlcConnectionMetadata
diff --git a/plc4go/pkg/api/cache/PlcConnectionCache_test.go 
b/plc4go/pkg/api/cache/PlcConnectionCache_test.go
index cd20cc0deb..fdb8bb227b 100644
--- a/plc4go/pkg/api/cache/PlcConnectionCache_test.go
+++ b/plc4go/pkg/api/cache/PlcConnectionCache_test.go
@@ -20,6 +20,8 @@
 package cache
 
 import (
+       "context"
+       "fmt"
        "strings"
        "testing"
        "time"
@@ -182,7 +184,7 @@ func TestPlcConnectionCache_Close(t *testing.T) {
        }
 }
 
-func readFromPlc(t *testing.T, c *plcConnectionCache, preConnectJob func(), 
connectionString string, resourceString string) <-chan []tracer.TraceEntry {
+func readFromPlc(t *testing.T, ctx context.Context, c *plcConnectionCache, 
preConnectJob func(), connectionString string, resourceString string) <-chan 
[]tracer.TraceEntry {
        t.Helper()
        t.Log("readFromPlc")
        t.Log("Creating tracer channel")
@@ -194,7 +196,7 @@ func readFromPlc(t *testing.T, c *plcConnectionCache, 
preConnectJob func(), conn
        }
        t.Log("Getting connection from cache")
        // Get a connection
-       connection, err := c.GetConnection(t.Context(), connectionString)
+       connection, err := c.GetConnection(ctx, connectionString)
        if err != nil {
                t.Errorf("PlcConnectionCache.GetConnection() error = %v", err)
                return nil
@@ -205,7 +207,8 @@ func readFromPlc(t *testing.T, c *plcConnectionCache, 
preConnectJob func(), conn
                if err := connection.Close(); err != nil {
                        t.Log("Error closing connection", err)
                }
-               tracerChan <- connection.(interface{ GetLastTraces() 
[]tracer.TraceEntry }).GetLastTraces()
+               leasedConnection := connection.(*plcConnectionLease)
+               tracerChan <- leasedConnection.GetLastTraces()
                t.Log("Closed connection")
        }()
 
@@ -219,7 +222,7 @@ func readFromPlc(t *testing.T, c *plcConnectionCache, 
preConnectJob func(), conn
 
        // Execute the read request.
        t.Log("Executing read request")
-       execution := readRequest.Execute(t.Context())
+       execution := readRequest.Execute(ctx)
        select {
        case readRequestResult := <-execution:
                err := readRequestResult.GetErr()
@@ -232,7 +235,7 @@ func readFromPlc(t *testing.T, c *plcConnectionCache, 
preConnectJob func(), conn
        return tracerChan
 }
 
-func executeAndTestReadFromPlc(t *testing.T, c *plcConnectionCache, 
preConnectJob func(), connectionString string, resourceString string, 
expectedTraceEntries []string, expectedNumTotalConnections int) <-chan struct{} 
{
+func executeAndTestReadFromPlc(t *testing.T, ctx context.Context, c 
*plcConnectionCache, preConnectJob func(), connectionString string, 
resourceString string, expectedTraceEntries []string, 
expectedNumTotalConnections int) <-chan struct{} {
        t.Helper()
        ch := make(chan struct{}, 1)
        c.wg.Go(func() {
@@ -241,26 +244,31 @@ func executeAndTestReadFromPlc(t *testing.T, c 
*plcConnectionCache, preConnectJo
                t.Log("Reading from the cache")
                var traces []tracer.TraceEntry
                select {
-               case traces = <-readFromPlc(t, c, preConnectJob, 
connectionString, resourceString):
+               case traces = <-readFromPlc(t, ctx, c, preConnectJob, 
connectionString, resourceString):
+               case <-ctx.Done():
+                       t.Log("Context done", t.Context().Err())
+                       ch <- struct{}{}
+                       return
                case <-t.Context().Done():
                        t.Log("Context done", t.Context().Err())
+                       ch <- struct{}{}
                        return
                }
 
                t.Log("Finished reading from the cache")
 
-               // In the log we should see one "Successfully connected" entry.
-               if len(traces) != len(expectedTraceEntries) {
-                       t.Errorf("Expected %d 'Successfully connected' entries 
in the log but got %d", len(expectedTraceEntries), len(traces))
-                       ch <- struct{}{}
-                       return
-               }
                t.Log("Checking trace entries")
-               for i, expectedTraceEntry := range expectedTraceEntries {
-                       currentTraceEntry := traces[i].Operation + "-" + 
traces[i].Message
-                       if expectedTraceEntry != currentTraceEntry {
-                               t.Errorf("Expected %s as trace entry but got 
%s", expectedTraceEntry, currentTraceEntry)
+               t.Log("actual, expected")
+               for i := 0; i < max(len(traces), len(expectedTraceEntries)); 
i++ {
+                       actual, expected := "\t\t\t\t\t", "\t\t\t\t\t"
+                       if i < len(traces)-1 {
+                               actual = fmt.Sprintf("%s-%s", 
traces[i].Operation, traces[i].Message)
                        }
+                       if i < len(expectedTraceEntries)-1 {
+                               expected = fmt.Sprintf("%v", 
expectedTraceEntries[i])
+                       }
+                       t.Logf("%s\t\t%s", actual, expected)
+                       assert.Equal(t, actual, expected)
                }
                t.Log("Trace entries are as expected")
                t.Log("Checking number of connections in the cache")
@@ -299,6 +307,7 @@ func TestPlcConnectionCache_ReusingAnExistingConnection(t 
*testing.T) {
        // Read once from the cache.
        finishedChan := executeAndTestReadFromPlc(
                t,
+               t.Context(),
                cache,
                nil,
                "simulated://1.2.3.4:42?traceEnabled=true",
@@ -322,6 +331,7 @@ func TestPlcConnectionCache_ReusingAnExistingConnection(t 
*testing.T) {
        // Request the same connection for a second time.
        finishedChan = executeAndTestReadFromPlc(
                t,
+               t.Context(),
                cache,
                nil,
                "simulated://1.2.3.4:42?traceEnabled=true",
@@ -381,6 +391,7 @@ func 
TestPlcConnectionCache_MultipleConcurrentConnectionRequests(t *testing.T) {
        // Read once from the cache.
        firstRun := executeAndTestReadFromPlc(
                t,
+               t.Context(),
                cache,
                func() {
                        floodGate.RLock()
@@ -405,6 +416,7 @@ func 
TestPlcConnectionCache_MultipleConcurrentConnectionRequests(t *testing.T) {
        // to wait for the first operation to be finished first.
        secondRun := executeAndTestReadFromPlc(
                t,
+               t.Context(),
                cache,
                func() {
                        floodGate.RLock()
@@ -511,10 +523,7 @@ func 
TestPlcConnectionCache_ReturningConnectionWithPingError(t *testing.T) {
        // In the connection string, we tell the driver to return an error with
        // the given message on executing a ping operation.
        conn, err := cache.GetConnection(t.Context(), 
"simulated://1.2.3.4:42?pingError=hurz&traceEnabled=true")
-       if err != nil {
-               t.Errorf("PlcConnectionCache.GetConnection() error = %v", err)
-               t.FailNow()
-       }
+       require.NoError(t, err, "Error getting connection from cache: %s", err)
        connection := conn.(*plcConnectionLease)
        if err := connection.Close(); err != nil {
                traces := connection.GetLastTraces()
@@ -559,9 +568,13 @@ func TestPlcConnectionCache_PingTimeout(t *testing.T) {
                t.Errorf("Expected %d connections in the cache but got %d", 0, 
len(cache.connections))
        }
 
+       ctx, cancelFunc := context.WithTimeout(t.Context(), 
100*time.Millisecond)
+       t.Cleanup(cancelFunc)
+
        // Read once from the cache.
        firstRun := executeAndTestReadFromPlc(
                t,
+               ctx,
                cache,
                nil,
                "simulated://1.2.3.4:42?pingDelay=10000&traceEnabled=true",
@@ -581,7 +594,7 @@ func TestPlcConnectionCache_PingTimeout(t *testing.T) {
        case <-time.After(20 * time.Second * time.Duration(debugTimeout)):
                t.Errorf("Timeout")
        }
-
+       t.Log("done")
 }
 
 // In this test there are multiple requests for the same connection but the 
first operation fails at returning
@@ -609,9 +622,13 @@ func 
TestPlcConnectionCache_SecondCallGetNewConnectionAfterPingTimeout(t *testin
                t.Errorf("Expected %d connections in the cache but got %d", 0, 
len(cache.connections))
        }
 
+       ctx, cancelFunc := context.WithTimeout(t.Context(), 10*time.Second)
+       t.Cleanup(cancelFunc)
+
        // Read once from the cache.
        firstRun := executeAndTestReadFromPlc(
                t,
+               ctx,
                cache,
                nil,
                
"simulated://1.2.3.4:42?pingDelay=10000&connectionDelay=100&traceEnabled=true",
@@ -627,12 +644,16 @@ func 
TestPlcConnectionCache_SecondCallGetNewConnectionAfterPingTimeout(t *testin
 
        time.Sleep(time.Millisecond * 1)
 
+       ctx, cancelFunc = context.WithTimeout(t.Context(), 10*time.Second)
+       t.Cleanup(cancelFunc)
+
        // Almost instantly request the same connection for a second time.
        // As the connection takes 100ms, the second connection request will 
come
        // in while the first is still not finished. So in theory it would have
        // to wait for the first operation to be finished first.
        secondRun := executeAndTestReadFromPlc(
                t,
+               ctx,
                cache,
                nil,
                
"simulated://1.2.3.4:42?pingDelay=10000&connectionDelay=100&traceEnabled=true",
@@ -654,13 +675,12 @@ func 
TestPlcConnectionCache_SecondCallGetNewConnectionAfterPingTimeout(t *testin
                case <-time.After(20 * time.Second * 
time.Duration(debugTimeout)):
                        t.Errorf("Timeout")
                }
-               break
        case <-time.After(30 * time.Second * time.Duration(debugTimeout)):
                t.Errorf("Timeout")
        }
 
        // This should be quite equal to the serial case as the connections are 
requested serially.
-       assert.NotNil(t, cache.GetTracer(), "Tracer should be available")
+       require.NotNil(t, cache.GetTracer(), "Tracer should be available")
        traces := cache.GetTracer().GetTraces()
        require.Equal(t, 5, len(traces), "Unexpected number of trace entries")
        // First is needs to create a new container for this connection
diff --git a/plc4go/pkg/api/cache/mocks_test.go 
b/plc4go/pkg/api/cache/mocks_test.go
index b382a54404..b90f26a087 100644
--- a/plc4go/pkg/api/cache/mocks_test.go
+++ b/plc4go/pkg/api/cache/mocks_test.go
@@ -704,20 +704,18 @@ func (_c *mocktracedPlcConnection_IsTraceEnabled_Call) 
RunAndReturn(run func() b
 }
 
 // Ping provides a mock function for the type mocktracedPlcConnection
-func (_mock *mocktracedPlcConnection) Ping() <-chan 
plc4go.PlcConnectionPingResult {
-       ret := _mock.Called()
+func (_mock *mocktracedPlcConnection) Ping(ctx context.Context) error {
+       ret := _mock.Called(ctx)
 
        if len(ret) == 0 {
                panic("no return value specified for Ping")
        }
 
-       var r0 <-chan plc4go.PlcConnectionPingResult
-       if returnFunc, ok := ret.Get(0).(func() <-chan 
plc4go.PlcConnectionPingResult); ok {
-               r0 = returnFunc()
+       var r0 error
+       if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
+               r0 = returnFunc(ctx)
        } else {
-               if ret.Get(0) != nil {
-                       r0 = ret.Get(0).(<-chan plc4go.PlcConnectionPingResult)
-               }
+               r0 = ret.Error(0)
        }
        return r0
 }
@@ -728,23 +726,30 @@ type mocktracedPlcConnection_Ping_Call struct {
 }
 
 // Ping is a helper method to define mock.On call
-func (_e *mocktracedPlcConnection_Expecter) Ping() 
*mocktracedPlcConnection_Ping_Call {
-       return &mocktracedPlcConnection_Ping_Call{Call: _e.mock.On("Ping")}
+//   - ctx context.Context
+func (_e *mocktracedPlcConnection_Expecter) Ping(ctx interface{}) 
*mocktracedPlcConnection_Ping_Call {
+       return &mocktracedPlcConnection_Ping_Call{Call: _e.mock.On("Ping", ctx)}
 }
 
-func (_c *mocktracedPlcConnection_Ping_Call) Run(run func()) 
*mocktracedPlcConnection_Ping_Call {
+func (_c *mocktracedPlcConnection_Ping_Call) Run(run func(ctx 
context.Context)) *mocktracedPlcConnection_Ping_Call {
        _c.Call.Run(func(args mock.Arguments) {
-               run()
+               var arg0 context.Context
+               if args[0] != nil {
+                       arg0 = args[0].(context.Context)
+               }
+               run(
+                       arg0,
+               )
        })
        return _c
 }
 
-func (_c *mocktracedPlcConnection_Ping_Call) Return(plcConnectionPingResultCh 
<-chan plc4go.PlcConnectionPingResult) *mocktracedPlcConnection_Ping_Call {
-       _c.Call.Return(plcConnectionPingResultCh)
+func (_c *mocktracedPlcConnection_Ping_Call) Return(err error) 
*mocktracedPlcConnection_Ping_Call {
+       _c.Call.Return(err)
        return _c
 }
 
-func (_c *mocktracedPlcConnection_Ping_Call) RunAndReturn(run func() <-chan 
plc4go.PlcConnectionPingResult) *mocktracedPlcConnection_Ping_Call {
+func (_c *mocktracedPlcConnection_Ping_Call) RunAndReturn(run func(ctx 
context.Context) error) *mocktracedPlcConnection_Ping_Call {
        _c.Call.Return(run)
        return _c
 }
diff --git a/plc4go/pkg/api/cache/plcConnectionLease.go 
b/plc4go/pkg/api/cache/plcConnectionLease.go
index baadf3c26a..ecf299d553 100644
--- a/plc4go/pkg/api/cache/plcConnectionLease.go
+++ b/plc4go/pkg/api/cache/plcConnectionLease.go
@@ -24,7 +24,8 @@ import (
        "fmt"
        "time"
 
-       plc4go "github.com/apache/plc4x/plc4go/pkg/api"
+       "github.com/pkg/errors"
+
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/spi/tracer"
 )
@@ -87,25 +88,15 @@ func (t *plcConnectionLease) Close() error {
        }
 
        // Check if the connection is still alive, if it is, put it back into 
the cache
-       pingResults := t.Ping()
-       pingTimeout := time.NewTimer(5 * time.Second)
        newState := StateIdle
-       select {
-       case pingResult := <-pingResults:
-               {
-                       if pingResult.GetErr() != nil {
-                               newState = StateInvalid
-                       }
-               }
-       case <-pingTimeout.C:
-               {
+       if err := t.Ping(ctx); err != nil {
+               if errors.Is(err, context.DeadlineExceeded) {
                        // Add some trace information
                        if t.connection.IsTraceEnabled() {
                                t.connection.GetTracer().AddTrace("ping", 
"timeout")
                        }
-                       // Mark the connection as broken ...
-                       newState = StateInvalid
                }
+               newState = StateInvalid
        }
 
        // Extract the trace entries from the connection.
@@ -139,11 +130,11 @@ func (t *plcConnectionLease) IsConnected() bool {
        return t.connection.IsConnected()
 }
 
-func (t *plcConnectionLease) Ping() <-chan plc4go.PlcConnectionPingResult {
+func (t *plcConnectionLease) Ping(ctx context.Context) error {
        if t.connection == nil {
                panic("Called 'Ping' on a closed cached connection")
        }
-       return t.connection.Ping()
+       return t.connection.Ping(ctx)
 }
 
 func (t *plcConnectionLease) GetMetadata() apiModel.PlcConnectionMetadata {
diff --git a/plc4go/pkg/api/cache/plcConnectionLease_test.go 
b/plc4go/pkg/api/cache/plcConnectionLease_test.go
index fd7271c904..49904879ee 100644
--- a/plc4go/pkg/api/cache/plcConnectionLease_test.go
+++ b/plc4go/pkg/api/cache/plcConnectionLease_test.go
@@ -263,7 +263,7 @@ func TestLeasedPlcConnection_Ping(t *testing.T) {
        // The first and second connection should work fine
        connection, err := cache.GetConnection(t.Context(), 
"simulated://1.2.3.4:42?connectionDelay=100&traceEnabled=true")
        assert.Nil(t, err)
-       connection.Ping()
+       _ = connection.Ping(t.Context())
        assert.NoError(t, connection.Close())
        func() {
                defer func() {
@@ -273,7 +273,7 @@ func TestLeasedPlcConnection_Ping(t *testing.T) {
                                t.Errorf("The code did not panic")
                        }
                }()
-               connection.Ping()
+               _ = connection.Ping(t.Context())
        }()
 }
 
diff --git a/plc4go/pkg/api/mocks_test.go b/plc4go/pkg/api/mocks_test.go
index 81efe957b9..83d5ae6d63 100644
--- a/plc4go/pkg/api/mocks_test.go
+++ b/plc4go/pkg/api/mocks_test.go
@@ -292,20 +292,18 @@ func (_c *MockPlcConnection_IsConnected_Call) 
RunAndReturn(run func() bool) *Moc
 }
 
 // Ping provides a mock function for the type MockPlcConnection
-func (_mock *MockPlcConnection) Ping() <-chan PlcConnectionPingResult {
-       ret := _mock.Called()
+func (_mock *MockPlcConnection) Ping(ctx context.Context) error {
+       ret := _mock.Called(ctx)
 
        if len(ret) == 0 {
                panic("no return value specified for Ping")
        }
 
-       var r0 <-chan PlcConnectionPingResult
-       if returnFunc, ok := ret.Get(0).(func() <-chan 
PlcConnectionPingResult); ok {
-               r0 = returnFunc()
+       var r0 error
+       if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
+               r0 = returnFunc(ctx)
        } else {
-               if ret.Get(0) != nil {
-                       r0 = ret.Get(0).(<-chan PlcConnectionPingResult)
-               }
+               r0 = ret.Error(0)
        }
        return r0
 }
@@ -316,23 +314,30 @@ type MockPlcConnection_Ping_Call struct {
 }
 
 // Ping is a helper method to define mock.On call
-func (_e *MockPlcConnection_Expecter) Ping() *MockPlcConnection_Ping_Call {
-       return &MockPlcConnection_Ping_Call{Call: _e.mock.On("Ping")}
+//   - ctx context.Context
+func (_e *MockPlcConnection_Expecter) Ping(ctx interface{}) 
*MockPlcConnection_Ping_Call {
+       return &MockPlcConnection_Ping_Call{Call: _e.mock.On("Ping", ctx)}
 }
 
-func (_c *MockPlcConnection_Ping_Call) Run(run func()) 
*MockPlcConnection_Ping_Call {
+func (_c *MockPlcConnection_Ping_Call) Run(run func(ctx context.Context)) 
*MockPlcConnection_Ping_Call {
        _c.Call.Run(func(args mock.Arguments) {
-               run()
+               var arg0 context.Context
+               if args[0] != nil {
+                       arg0 = args[0].(context.Context)
+               }
+               run(
+                       arg0,
+               )
        })
        return _c
 }
 
-func (_c *MockPlcConnection_Ping_Call) Return(plcConnectionPingResultCh <-chan 
PlcConnectionPingResult) *MockPlcConnection_Ping_Call {
-       _c.Call.Return(plcConnectionPingResultCh)
+func (_c *MockPlcConnection_Ping_Call) Return(err error) 
*MockPlcConnection_Ping_Call {
+       _c.Call.Return(err)
        return _c
 }
 
-func (_c *MockPlcConnection_Ping_Call) RunAndReturn(run func() <-chan 
PlcConnectionPingResult) *MockPlcConnection_Ping_Call {
+func (_c *MockPlcConnection_Ping_Call) RunAndReturn(run func(ctx 
context.Context) error) *MockPlcConnection_Ping_Call {
        _c.Call.Return(run)
        return _c
 }
diff --git a/plc4go/spi/default/DefaultConnection.go 
b/plc4go/spi/default/DefaultConnection.go
index 0400c45899..be9277a08f 100644
--- a/plc4go/spi/default/DefaultConnection.go
+++ b/plc4go/spi/default/DefaultConnection.go
@@ -21,7 +21,6 @@ package _default
 
 import (
        "context"
-       "runtime/debug"
        "sync"
        "sync/atomic"
 
@@ -159,21 +158,11 @@ func (d *defaultConnection) IsConnected() bool {
        return d.connected.Load()
 }
 
-func (d *defaultConnection) Ping() <-chan plc4go.PlcConnectionPingResult {
-       ch := make(chan plc4go.PlcConnectionPingResult, 1)
-       d.wg.Go(func() {
-               defer func() {
-                       if err := recover(); err != nil {
-                               ch <- 
NewDefaultPlcConnectionPingResult(errors.Errorf("panic-ed %v. Stack: %s", err, 
debug.Stack()))
-                       }
-               }()
-               if d.DefaultConnectionRequirements.IsConnected() {
-                       ch <- NewDefaultPlcConnectionPingResult(nil)
-               } else {
-                       ch <- NewDefaultPlcConnectionPingResult(errors.New("not 
connected"))
-               }
-       })
-       return ch
+func (d *defaultConnection) Ping(_ context.Context) error {
+       if !d.DefaultConnectionRequirements.IsConnected() {
+               return errors.New("not connected")
+       }
+       return nil
 }
 
 func (d *defaultConnection) GetMetadata() apiModel.PlcConnectionMetadata {
diff --git a/plc4go/spi/default/DefaultConnection_test.go 
b/plc4go/spi/default/DefaultConnection_test.go
index 5f58f4e516..40ec3b75f4 100644
--- a/plc4go/spi/default/DefaultConnection_test.go
+++ b/plc4go/spi/default/DefaultConnection_test.go
@@ -21,14 +21,12 @@ package _default
 
 import (
        "context"
-       "fmt"
        "testing"
 
        "github.com/rs/zerolog/log"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/mock"
 
-       "github.com/apache/plc4x/plc4go/pkg/api"
        apiModel "github.com/apache/plc4x/plc4go/pkg/api/model"
        "github.com/apache/plc4x/plc4go/spi"
        "github.com/apache/plc4x/plc4go/spi/options"
@@ -215,27 +213,6 @@ func TestNewDefaultConnection(t *testing.T) {
        }
 }
 
-func TestNewDefaultPlcConnectionPingResult(t *testing.T) {
-       type args struct {
-               err error
-       }
-       tests := []struct {
-               name string
-               args args
-               want plc4go.PlcConnectionPingResult
-       }{
-               {
-                       name: "create it",
-                       want: &defaultPlcConnectionPingResult{},
-               },
-       }
-       for _, tt := range tests {
-               t.Run(tt.name, func(t *testing.T) {
-                       assert.Equalf(t, tt.want, 
NewDefaultPlcConnectionPingResult(tt.args.err), 
"NewDefaultPlcConnectionPingResult(%v)", tt.args.err)
-               })
-       }
-}
-
 func TestWithPlcTagHandler(t *testing.T) {
        type args struct {
                tagHandler spi.PlcTagHandler
@@ -608,15 +585,22 @@ func Test_defaultConnection_Ping(t *testing.T) {
                tagHandler                    spi.PlcTagHandler
                valueHandler                  spi.PlcValueHandler
        }
+       type args struct {
+               ctx context.Context
+       }
        tests := []struct {
-               name         string
-               fields       fields
-               setup        func(t *testing.T, fields *fields)
-               connected    bool
-               wantAsserter func(t *testing.T, results <-chan 
plc4go.PlcConnectionPingResult) bool
+               name      string
+               fields    fields
+               args      args
+               setup     func(t *testing.T, fields *fields)
+               connected bool
+               wantErr   assert.ErrorAssertionFunc
        }{
                {
                        name: "ping it",
+                       args: args{
+                               ctx: t.Context(),
+                       },
                        setup: func(t *testing.T, fields *fields) {
                                requirements := 
NewMockDefaultConnectionRequirements(t)
                                {
@@ -624,18 +608,13 @@ func Test_defaultConnection_Ping(t *testing.T) {
                                }
                                fields.DefaultConnectionRequirements = 
requirements
                        },
-                       wantAsserter: func(t *testing.T, results <-chan 
plc4go.PlcConnectionPingResult) bool {
-                               select {
-                               case <-t.Context().Done():
-                                       t.Error("timeout")
-                               case result := <-results:
-                                       assert.NotNil(t, result.GetErr())
-                               }
-                               return true
-                       },
+                       wantErr: assert.Error,
                },
                {
                        name: "ping it connected",
+                       args: args{
+                               ctx: t.Context(),
+                       },
                        setup: func(t *testing.T, fields *fields) {
                                requirements := 
NewMockDefaultConnectionRequirements(t)
                                {
@@ -644,15 +623,7 @@ func Test_defaultConnection_Ping(t *testing.T) {
                                fields.DefaultConnectionRequirements = 
requirements
                        },
                        connected: true,
-                       wantAsserter: func(t *testing.T, results <-chan 
plc4go.PlcConnectionPingResult) bool {
-                               select {
-                               case <-t.Context().Done():
-                                       t.Error("timeout")
-                               case result := <-results:
-                                       assert.Nil(t, result.GetErr())
-                               }
-                               return true
-                       },
+                       wantErr:   assert.NoError,
                },
        }
        for _, tt := range tests {
@@ -668,7 +639,7 @@ func Test_defaultConnection_Ping(t *testing.T) {
                        if tt.connected {
                                d.connected.Store(true)
                        }
-                       assert.Truef(t, tt.wantAsserter(t, d.Ping()), "Ping()")
+                       assert.Truef(t, tt.wantErr(t, d.Ping(tt.args.ctx)), 
"Ping()")
                })
        }
 }
@@ -838,27 +809,3 @@ func Test_defaultConnection_WriteRequestBuilder(t 
*testing.T) {
                })
        }
 }
-
-func Test_plcConnectionPingResult_GetErr(t *testing.T) {
-       type fields struct {
-               err error
-       }
-       tests := []struct {
-               name    string
-               fields  fields
-               wantErr assert.ErrorAssertionFunc
-       }{
-               {
-                       name:    "get it",
-                       wantErr: assert.NoError,
-               },
-       }
-       for _, tt := range tests {
-               t.Run(tt.name, func(t *testing.T) {
-                       d := &defaultPlcConnectionPingResult{
-                               err: tt.fields.err,
-                       }
-                       tt.wantErr(t, d.GetErr(), fmt.Sprintf("GetErr()"))
-               })
-       }
-}
diff --git a/plc4go/spi/default/DefaultPlcConnectionPingResult.go 
b/plc4go/spi/default/DefaultPlcConnectionPingResult.go
deleted file mode 100644
index 7d0d1027e2..0000000000
--- a/plc4go/spi/default/DefaultPlcConnectionPingResult.go
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package _default
-
-import plc4go "github.com/apache/plc4x/plc4go/pkg/api"
-
-type DefaultPlcConnectionPingResult interface {
-       plc4go.PlcConnectionPingResult
-}
-
-func NewDefaultPlcConnectionPingResult(err error) 
plc4go.PlcConnectionPingResult {
-       return &defaultPlcConnectionPingResult{
-               err: err,
-       }
-}
-
-//go:generate go tool plc4xGenerator -type=defaultPlcConnectionPingResult
-type defaultPlcConnectionPingResult struct {
-       err error
-}
-
-func (d *defaultPlcConnectionPingResult) GetErr() error {
-       return d.err
-}
diff --git a/plc4go/spi/default/defaultPlcConnectionPingResult_plc4xgen.go 
b/plc4go/spi/default/defaultPlcConnectionPingResult_plc4xgen.go
deleted file mode 100644
index d27743b52c..0000000000
--- a/plc4go/spi/default/defaultPlcConnectionPingResult_plc4xgen.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// Code generated by "plc4xGenerator -type=defaultPlcConnectionPingResult"; DO 
NOT EDIT.
-
-package _default
-
-import (
-       "context"
-       "encoding/binary"
-       "fmt"
-       "github.com/apache/plc4x/plc4go/spi/utils"
-)
-
-var _ = fmt.Printf
-
-func (d *defaultPlcConnectionPingResult) Serialize() ([]byte, error) {
-       if d == nil {
-               return nil, fmt.Errorf("(*DeviceInfoCache)(nil)")
-       }
-       wb := 
utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.BigEndian))
-       if err := d.SerializeWithWriteBuffer(context.Background(), wb); err != 
nil {
-               return nil, err
-       }
-       return wb.GetBytes(), nil
-}
-
-func (d *defaultPlcConnectionPingResult) SerializeWithWriteBuffer(ctx 
context.Context, writeBuffer utils.WriteBuffer) error {
-       if d == nil {
-               return fmt.Errorf("(*DeviceInfoCache)(nil)")
-       }
-       if err := writeBuffer.PushContext("defaultPlcConnectionPingResult"); 
err != nil {
-               return err
-       }
-
-       if d.err != nil {
-               _errString := d.err.Error()
-               if err := writeBuffer.WriteString("err", 
uint32(len(_errString)*8), _errString); err != nil {
-                       return err
-               }
-       }
-       if err := writeBuffer.PopContext("defaultPlcConnectionPingResult"); err 
!= nil {
-               return err
-       }
-       return nil
-}
-
-func (d *defaultPlcConnectionPingResult) String() string {
-       if alternateStringer, ok := any(d).(utils.AlternateStringer); ok {
-               if alternateString, use := alternateStringer.AlternateString(); 
use {
-                       return alternateString
-               }
-       }
-       wb := 
utils.NewWriteBufferBoxBased(utils.WithWriteBufferBoxBasedMergeSingleBoxes(), 
utils.WithWriteBufferBoxBasedOmitEmptyBoxes())
-       if err := wb.WriteSerializable(context.Background(), d); err != nil {
-               return err.Error()
-       }
-       return wb.GetBox().String()
-}
diff --git a/plc4go/spi/default/mocks_test.go b/plc4go/spi/default/mocks_test.go
index ac37d69acc..2373d14683 100644
--- a/plc4go/spi/default/mocks_test.go
+++ b/plc4go/spi/default/mocks_test.go
@@ -1561,20 +1561,18 @@ func (_c *MockDefaultConnection_IsConnected_Call) 
RunAndReturn(run func() bool)
 }
 
 // Ping provides a mock function for the type MockDefaultConnection
-func (_mock *MockDefaultConnection) Ping() <-chan 
plc4go.PlcConnectionPingResult {
-       ret := _mock.Called()
+func (_mock *MockDefaultConnection) Ping(ctx context.Context) error {
+       ret := _mock.Called(ctx)
 
        if len(ret) == 0 {
                panic("no return value specified for Ping")
        }
 
-       var r0 <-chan plc4go.PlcConnectionPingResult
-       if returnFunc, ok := ret.Get(0).(func() <-chan 
plc4go.PlcConnectionPingResult); ok {
-               r0 = returnFunc()
+       var r0 error
+       if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
+               r0 = returnFunc(ctx)
        } else {
-               if ret.Get(0) != nil {
-                       r0 = ret.Get(0).(<-chan plc4go.PlcConnectionPingResult)
-               }
+               r0 = ret.Error(0)
        }
        return r0
 }
@@ -1585,23 +1583,30 @@ type MockDefaultConnection_Ping_Call struct {
 }
 
 // Ping is a helper method to define mock.On call
-func (_e *MockDefaultConnection_Expecter) Ping() 
*MockDefaultConnection_Ping_Call {
-       return &MockDefaultConnection_Ping_Call{Call: _e.mock.On("Ping")}
+//   - ctx context.Context
+func (_e *MockDefaultConnection_Expecter) Ping(ctx interface{}) 
*MockDefaultConnection_Ping_Call {
+       return &MockDefaultConnection_Ping_Call{Call: _e.mock.On("Ping", ctx)}
 }
 
-func (_c *MockDefaultConnection_Ping_Call) Run(run func()) 
*MockDefaultConnection_Ping_Call {
+func (_c *MockDefaultConnection_Ping_Call) Run(run func(ctx context.Context)) 
*MockDefaultConnection_Ping_Call {
        _c.Call.Run(func(args mock.Arguments) {
-               run()
+               var arg0 context.Context
+               if args[0] != nil {
+                       arg0 = args[0].(context.Context)
+               }
+               run(
+                       arg0,
+               )
        })
        return _c
 }
 
-func (_c *MockDefaultConnection_Ping_Call) Return(plcConnectionPingResultCh 
<-chan plc4go.PlcConnectionPingResult) *MockDefaultConnection_Ping_Call {
-       _c.Call.Return(plcConnectionPingResultCh)
+func (_c *MockDefaultConnection_Ping_Call) Return(err error) 
*MockDefaultConnection_Ping_Call {
+       _c.Call.Return(err)
        return _c
 }
 
-func (_c *MockDefaultConnection_Ping_Call) RunAndReturn(run func() <-chan 
plc4go.PlcConnectionPingResult) *MockDefaultConnection_Ping_Call {
+func (_c *MockDefaultConnection_Ping_Call) RunAndReturn(run func(ctx 
context.Context) error) *MockDefaultConnection_Ping_Call {
        _c.Call.Return(run)
        return _c
 }
@@ -2756,121 +2761,6 @@ func (_c *MockDefaultDriver_SupportsDiscovery_Call) 
RunAndReturn(run func() bool
        return _c
 }
 
-// NewMockDefaultPlcConnectionPingResult creates a new instance of 
MockDefaultPlcConnectionPingResult. It also registers a testing interface on 
the mock and a cleanup function to assert the mocks expectations.
-// The first argument is typically a *testing.T value.
-func NewMockDefaultPlcConnectionPingResult(t interface {
-       mock.TestingT
-       Cleanup(func())
-}) *MockDefaultPlcConnectionPingResult {
-       mock := &MockDefaultPlcConnectionPingResult{}
-       mock.Mock.Test(t)
-
-       t.Cleanup(func() { mock.AssertExpectations(t) })
-
-       return mock
-}
-
-// MockDefaultPlcConnectionPingResult is an autogenerated mock type for the 
DefaultPlcConnectionPingResult type
-type MockDefaultPlcConnectionPingResult struct {
-       mock.Mock
-}
-
-type MockDefaultPlcConnectionPingResult_Expecter struct {
-       mock *mock.Mock
-}
-
-func (_m *MockDefaultPlcConnectionPingResult) EXPECT() 
*MockDefaultPlcConnectionPingResult_Expecter {
-       return &MockDefaultPlcConnectionPingResult_Expecter{mock: &_m.Mock}
-}
-
-// GetErr provides a mock function for the type 
MockDefaultPlcConnectionPingResult
-func (_mock *MockDefaultPlcConnectionPingResult) GetErr() error {
-       ret := _mock.Called()
-
-       if len(ret) == 0 {
-               panic("no return value specified for GetErr")
-       }
-
-       var r0 error
-       if returnFunc, ok := ret.Get(0).(func() error); ok {
-               r0 = returnFunc()
-       } else {
-               r0 = ret.Error(0)
-       }
-       return r0
-}
-
-// MockDefaultPlcConnectionPingResult_GetErr_Call is a *mock.Call that shadows 
Run/Return methods with type explicit version for method 'GetErr'
-type MockDefaultPlcConnectionPingResult_GetErr_Call struct {
-       *mock.Call
-}
-
-// GetErr is a helper method to define mock.On call
-func (_e *MockDefaultPlcConnectionPingResult_Expecter) GetErr() 
*MockDefaultPlcConnectionPingResult_GetErr_Call {
-       return &MockDefaultPlcConnectionPingResult_GetErr_Call{Call: 
_e.mock.On("GetErr")}
-}
-
-func (_c *MockDefaultPlcConnectionPingResult_GetErr_Call) Run(run func()) 
*MockDefaultPlcConnectionPingResult_GetErr_Call {
-       _c.Call.Run(func(args mock.Arguments) {
-               run()
-       })
-       return _c
-}
-
-func (_c *MockDefaultPlcConnectionPingResult_GetErr_Call) Return(err error) 
*MockDefaultPlcConnectionPingResult_GetErr_Call {
-       _c.Call.Return(err)
-       return _c
-}
-
-func (_c *MockDefaultPlcConnectionPingResult_GetErr_Call) RunAndReturn(run 
func() error) *MockDefaultPlcConnectionPingResult_GetErr_Call {
-       _c.Call.Return(run)
-       return _c
-}
-
-// String provides a mock function for the type 
MockDefaultPlcConnectionPingResult
-func (_mock *MockDefaultPlcConnectionPingResult) String() string {
-       ret := _mock.Called()
-
-       if len(ret) == 0 {
-               panic("no return value specified for String")
-       }
-
-       var r0 string
-       if returnFunc, ok := ret.Get(0).(func() string); ok {
-               r0 = returnFunc()
-       } else {
-               r0 = ret.Get(0).(string)
-       }
-       return r0
-}
-
-// MockDefaultPlcConnectionPingResult_String_Call is a *mock.Call that shadows 
Run/Return methods with type explicit version for method 'String'
-type MockDefaultPlcConnectionPingResult_String_Call struct {
-       *mock.Call
-}
-
-// String is a helper method to define mock.On call
-func (_e *MockDefaultPlcConnectionPingResult_Expecter) String() 
*MockDefaultPlcConnectionPingResult_String_Call {
-       return &MockDefaultPlcConnectionPingResult_String_Call{Call: 
_e.mock.On("String")}
-}
-
-func (_c *MockDefaultPlcConnectionPingResult_String_Call) Run(run func()) 
*MockDefaultPlcConnectionPingResult_String_Call {
-       _c.Call.Run(func(args mock.Arguments) {
-               run()
-       })
-       return _c
-}
-
-func (_c *MockDefaultPlcConnectionPingResult_String_Call) Return(s string) 
*MockDefaultPlcConnectionPingResult_String_Call {
-       _c.Call.Return(s)
-       return _c
-}
-
-func (_c *MockDefaultPlcConnectionPingResult_String_Call) RunAndReturn(run 
func() string) *MockDefaultPlcConnectionPingResult_String_Call {
-       _c.Call.Return(run)
-       return _c
-}
-
 // NewMockPlcConnection creates a new instance of MockPlcConnection. It also 
registers a testing interface on the mock and a cleanup function to assert the 
mocks expectations.
 // The first argument is typically a *testing.T value.
 func NewMockPlcConnection(t interface {
@@ -3130,20 +3020,18 @@ func (_c *MockPlcConnection_IsConnected_Call) 
RunAndReturn(run func() bool) *Moc
 }
 
 // Ping provides a mock function for the type MockPlcConnection
-func (_mock *MockPlcConnection) Ping() <-chan plc4go.PlcConnectionPingResult {
-       ret := _mock.Called()
+func (_mock *MockPlcConnection) Ping(ctx context.Context) error {
+       ret := _mock.Called(ctx)
 
        if len(ret) == 0 {
                panic("no return value specified for Ping")
        }
 
-       var r0 <-chan plc4go.PlcConnectionPingResult
-       if returnFunc, ok := ret.Get(0).(func() <-chan 
plc4go.PlcConnectionPingResult); ok {
-               r0 = returnFunc()
+       var r0 error
+       if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
+               r0 = returnFunc(ctx)
        } else {
-               if ret.Get(0) != nil {
-                       r0 = ret.Get(0).(<-chan plc4go.PlcConnectionPingResult)
-               }
+               r0 = ret.Error(0)
        }
        return r0
 }
@@ -3154,23 +3042,30 @@ type MockPlcConnection_Ping_Call struct {
 }
 
 // Ping is a helper method to define mock.On call
-func (_e *MockPlcConnection_Expecter) Ping() *MockPlcConnection_Ping_Call {
-       return &MockPlcConnection_Ping_Call{Call: _e.mock.On("Ping")}
+//   - ctx context.Context
+func (_e *MockPlcConnection_Expecter) Ping(ctx interface{}) 
*MockPlcConnection_Ping_Call {
+       return &MockPlcConnection_Ping_Call{Call: _e.mock.On("Ping", ctx)}
 }
 
-func (_c *MockPlcConnection_Ping_Call) Run(run func()) 
*MockPlcConnection_Ping_Call {
+func (_c *MockPlcConnection_Ping_Call) Run(run func(ctx context.Context)) 
*MockPlcConnection_Ping_Call {
        _c.Call.Run(func(args mock.Arguments) {
-               run()
+               var arg0 context.Context
+               if args[0] != nil {
+                       arg0 = args[0].(context.Context)
+               }
+               run(
+                       arg0,
+               )
        })
        return _c
 }
 
-func (_c *MockPlcConnection_Ping_Call) Return(plcConnectionPingResultCh <-chan 
plc4go.PlcConnectionPingResult) *MockPlcConnection_Ping_Call {
-       _c.Call.Return(plcConnectionPingResultCh)
+func (_c *MockPlcConnection_Ping_Call) Return(err error) 
*MockPlcConnection_Ping_Call {
+       _c.Call.Return(err)
        return _c
 }
 
-func (_c *MockPlcConnection_Ping_Call) RunAndReturn(run func() <-chan 
plc4go.PlcConnectionPingResult) *MockPlcConnection_Ping_Call {
+func (_c *MockPlcConnection_Ping_Call) RunAndReturn(run func(ctx 
context.Context) error) *MockPlcConnection_Ping_Call {
        _c.Call.Return(run)
        return _c
 }

Reply via email to