You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/08/15 11:07:41 UTC
[plc4x] branch develop updated: feat(plc4go): added DiscoverWithContext to driver manager
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
The following commit(s) were added to refs/heads/develop by this push:
new 5ff39f7a1 feat(plc4go): added DiscoverWithContext to driver manager
5ff39f7a1 is described below
commit 5ff39f7a16ea0acee5f8e2817c02c471a1a125c2
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Aug 15 13:07:35 2022 +0200
feat(plc4go): added DiscoverWithContext to driver manager
---
plc4go/pkg/api/driverManager.go | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/plc4go/pkg/api/driverManager.go b/plc4go/pkg/api/driverManager.go
index 5cd317985..8f0be21c9 100644
--- a/plc4go/pkg/api/driverManager.go
+++ b/plc4go/pkg/api/driverManager.go
@@ -20,6 +20,7 @@
package plc4go
import (
+ "context"
"github.com/apache/plc4x/plc4go/pkg/api/model"
"github.com/apache/plc4x/plc4go/spi/options"
"github.com/apache/plc4x/plc4go/spi/transports"
@@ -42,6 +43,8 @@ type PlcDriverManager interface {
// Discover Execute all available discovery methods on all available drivers using all transports
Discover(callback func(event model.PlcDiscoveryEvent), discoveryOptions ...WithDiscoveryOption) error
+ // DiscoverWithContext Execute all available discovery methods on all available drivers using all transports
+ DiscoverWithContext(ctx context.Context, callback func(event model.PlcDiscoveryEvent), discoveryOptions ...WithDiscoveryOption) error
}
func NewPlcDriverManager() PlcDriverManager {
@@ -283,6 +286,10 @@ func (m *plcDriverManger) GetConnection(connectionString string) <-chan PlcConne
}
func (m *plcDriverManger) Discover(callback func(event model.PlcDiscoveryEvent), discoveryOptions ...WithDiscoveryOption) error {
+ return m.DiscoverWithContext(context.TODO(), callback, discoveryOptions...)
+}
+
+func (m *plcDriverManger) DiscoverWithContext(ctx context.Context, callback func(event model.PlcDiscoveryEvent), discoveryOptions ...WithDiscoveryOption) error {
// Check if we've got at least one option to restrict to certain protocols only.
// If there is at least one, we only check that protocol, if there are none, all
// available protocols are checked.
@@ -302,7 +309,7 @@ func (m *plcDriverManger) Discover(callback func(event model.PlcDiscoveryEvent),
// Execute discovery on all selected drivers
for _, driver := range discoveryDrivers {
if driver.SupportsDiscovery() {
- err := driver.Discover(callback, internalOptions...)
+ err := driver.DiscoverWithContext(ctx, callback, internalOptions...)
if err != nil {
return errors.Wrapf(err, "Error running Discover on driver %s", driver.GetProtocolName())
}