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-extras.git
The following commit(s) were added to refs/heads/develop by this push:
new 2cfe104 feat(plc4go): update upstream version
2cfe104 is described below
commit 2cfe10401d72181f995286112d1956eaec0e0637
Author: Sebastian Rühl <[email protected]>
AuthorDate: Mon Nov 24 12:06:22 2025 +0100
feat(plc4go): update upstream version
---
plc4go/go.mod | 14 ++---
plc4go/go.sum | 36 ++++++-------
plc4go/tools/plc4xbrowser/ui/commands.go | 87 ++++++++++++++++----------------
3 files changed, 69 insertions(+), 68 deletions(-)
diff --git a/plc4go/go.mod b/plc4go/go.mod
index ed19101..fb8eac7 100644
--- a/plc4go/go.mod
+++ b/plc4go/go.mod
@@ -19,10 +19,10 @@
module github.com/apache/plc4x-extras/plc4go
-go 1.24.0
+go 1.25
require (
- github.com/apache/plc4x/plc4go v0.0.0-20241008110309-501f1a6d1550
+ github.com/apache/plc4x/plc4go v0.0.0-20251124092144-6738c00ca1a7
github.com/fatih/color v1.18.0
github.com/gdamore/tcell/v2 v2.11.0
github.com/gopacket/gopacket v1.5.0
@@ -49,11 +49,11 @@ require (
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
- github.com/huandu/xstrings v1.4.0 // indirect
+ github.com/huandu/xstrings v1.5.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/icza/bitio v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
- github.com/incu6us/goimports-reviser/v3 v3.9.1 // indirect
+ github.com/incu6us/goimports-reviser/v3 v3.10.0 // indirect
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4 //
indirect
github.com/jinzhu/copier v0.4.0 // indirect
github.com/libp2p/go-reuseport v0.4.0 // indirect
@@ -76,13 +76,13 @@ require (
github.com/vektra/mockery/v2 v2.53.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
- golang.org/x/mod v0.29.0 // indirect
+ golang.org/x/mod v0.30.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
- golang.org/x/tools v0.38.0 // indirect
- gotest.tools/gotestsum v1.12.1 // indirect
+ golang.org/x/tools v0.39.0 // indirect
+ gotest.tools/gotestsum v1.13.0 // indirect
)
tool golang.org/x/tools/cmd/stringer
diff --git a/plc4go/go.sum b/plc4go/go.sum
index 8d143ce..46d86c3 100644
--- a/plc4go/go.sum
+++ b/plc4go/go.sum
@@ -4,8 +4,8 @@ github.com/ajankovic/xdiff v0.0.1
h1:V1cj8t5xwYzm6ZGPqPOlAc9AIajXuTEn41D/1MJBWMM
github.com/ajankovic/xdiff v0.0.1/go.mod
h1:SUmEZ67uB97I0zkiuQ+lb+LOms9ipn8X+p+2RdJV710=
github.com/antchfx/xpath v0.0.0-20170515025933-1f3266e77307
h1:C735MoY/X+UOx6SECmHk5pVOj51h839Ph13pEoY8UmU=
github.com/antchfx/xpath v0.0.0-20170515025933-1f3266e77307/go.mod
h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
-github.com/apache/plc4x/plc4go v0.0.0-20241008110309-501f1a6d1550
h1:a9B90K93GxRxOcjKIdHu3URLhEMddsLxtG7NqIu8WX0=
-github.com/apache/plc4x/plc4go v0.0.0-20241008110309-501f1a6d1550/go.mod
h1:PAZSiax81l2aEKoUcrKS5uAJuixc7ZfHRtoQr2szNEg=
+github.com/apache/plc4x/plc4go v0.0.0-20251124092144-6738c00ca1a7
h1:kDoe4hT0iZcB/2+mbHPnLdPCEkmeqPUCGxaxMFw+5CA=
+github.com/apache/plc4x/plc4go v0.0.0-20251124092144-6738c00ca1a7/go.mod
h1:yDBaYPcJ6jyhjEAMVN0TryBpyKAmpxYF/3MQ9IXhWmY=
github.com/bitfield/gotestdox v0.2.2
h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE=
github.com/bitfield/gotestdox v0.2.2/go.mod
h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY=
github.com/chengxilo/virtualterm v1.0.4
h1:Z6IpERbRVlfB8WkOmtbHiDbBANU7cimRIof7mk9/PwM=
@@ -34,16 +34,16 @@ github.com/gdamore/tcell/v2 v2.11.0/go.mod
h1:pytyB+bE6zrRVf6u/ZMWX9AZqSVcW4bpim
github.com/go-viper/mapstructure/v2 v2.4.0
h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod
h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/godbus/dbus/v5 v5.0.4/go.mod
h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
-github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
-github.com/google/go-cmp v0.6.0/go.mod
h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
+github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
+github.com/google/go-cmp v0.7.0/go.mod
h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod
h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod
h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopacket/gopacket v1.5.0
h1:9s9fcSUVKFlRV97B77Bq9XNV3ly2gvvsneFMQUGjc+M=
github.com/gopacket/gopacket v1.5.0/go.mod
h1:i3NaGaqfoWKAr1+g7qxEdWsmfT+MXuWkAe9+THv8LME=
-github.com/huandu/xstrings v1.4.0
h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
-github.com/huandu/xstrings v1.4.0/go.mod
h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
+github.com/huandu/xstrings v1.5.0
h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
+github.com/huandu/xstrings v1.5.0/go.mod
h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/strcase v0.3.0
h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI=
github.com/iancoleman/strcase v0.3.0/go.mod
h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/icza/bitio v1.1.0 h1:ysX4vtldjdi3Ygai5m1cWy4oLkhWTAi+SyO6HC8L9T0=
@@ -52,8 +52,8 @@ github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6
h1:8UsGZ2rr2ksmEru6lTo
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod
h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
github.com/inconshreveable/mousetrap v1.1.0
h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod
h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
-github.com/incu6us/goimports-reviser/v3 v3.9.1
h1:LqIuqUPlMLXZCya/Aps0bI068pKKsWa/Tt0Cn5l05fI=
-github.com/incu6us/goimports-reviser/v3 v3.9.1/go.mod
h1:5ORZPzRojNeWys/8rPHJovL44cV0bovZK0S3THxVIV4=
+github.com/incu6us/goimports-reviser/v3 v3.10.0
h1:hhN6UcrkjK6gLpPAuqGqMd5evW8ZNMD5obQq1OsENIg=
+github.com/incu6us/goimports-reviser/v3 v3.10.0/go.mod
h1:5ORZPzRojNeWys/8rPHJovL44cV0bovZK0S3THxVIV4=
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4
h1:G2ztCwXov8mRvP0ZfjE6nAlaCX2XbykaeHdbT6KwDz0=
github.com/jacobsa/go-serial v0.0.0-20180131005756-15cf729a72d4/go.mod
h1:2RvX5ZjVtsznNZPEt4xwJXNJrM3VTZoQf7V6gk0ysvs=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
@@ -139,14 +139,14 @@ golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
h1:l5+whBCLH3iH2ZNHYLbAe58bo
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac/go.mod
h1:hH+7mtFmImwwcMvScyxUhjuVHR3HGaDPMn9rMSUUbxo=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod
h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
-golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
-golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
+golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
+golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod
h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod
h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod
h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
-golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
+golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
+golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod
h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod
h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -179,15 +179,15 @@ golang.org/x/tools
v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod
h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod
h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod
h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
-golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
-golang.org/x/tools v0.38.0/go.mod
h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
+golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ=
+golang.org/x/tools v0.39.0/go.mod
h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f
h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod
h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
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/gotestsum v1.12.1 h1:dvcxFBTFR1QsQmrCQa4k/vDXow9altdYz4CjdW+XeBE=
-gotest.tools/gotestsum v1.12.1/go.mod
h1:mwDmLbx9DIvr09dnAoGgQPLaSXszNpXpWo2bsQge5BE=
-gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
-gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
+gotest.tools/gotestsum v1.13.0 h1:+Lh454O9mu9AMG1APV4o0y7oDYKyik/3kBOiCqiEpRo=
+gotest.tools/gotestsum v1.13.0/go.mod
h1:7f0NS5hFb0dWr4NtcsAsF0y1kzjEFfAil0HiBQJE03Q=
+gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
+gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
diff --git a/plc4go/tools/plc4xbrowser/ui/commands.go
b/plc4go/tools/plc4xbrowser/ui/commands.go
index e05b4b0..5637dc8 100644
--- a/plc4go/tools/plc4xbrowser/ui/commands.go
+++ b/plc4go/tools/plc4xbrowser/ui/commands.go
@@ -20,6 +20,7 @@
package ui
import (
+ "context"
"fmt"
"net/url"
"runtime/debug"
@@ -49,12 +50,12 @@ var rootCommand = Command{
{
Name: "discover",
Description: "Discovers devices",
- action: func(_ Command, driverId string) error {
+ action: func(ctx context.Context, _ Command, driverId
string) error {
if driver, ok := registeredDrivers[driverId];
ok {
if !driver.SupportsDiscovery() {
return errors.Errorf("%s
doesn't support discovery", driverId)
}
- return driver.Discover(func(event
apiModel.PlcDiscoveryItem) {
+ return driver.Discover(ctx, func(event
apiModel.PlcDiscoveryItem) {
_, _ =
fmt.Fprintf(messageOutput, "%v\n", event)
})
} else {
@@ -71,7 +72,7 @@ var rootCommand = Command{
{
Name: "connect",
Description: "Connects to a device",
- action: func(_ Command, connectionString string) error {
+ action: func(ctx context.Context, _ Command,
connectionString string) error {
log.Info().Str("connectionString",
connectionString).Msg("connect connectionString")
connectionUrl, err :=
url.Parse(connectionString)
if err != nil {
@@ -82,12 +83,12 @@ var rootCommand = Command{
if _, ok := connections[connectionId]; ok {
return errors.Errorf("%s already
connected", connectionId)
}
- connectionResult :=
<-driverManager.GetConnection(connectionString)
- if err := connectionResult.GetErr(); err != nil
{
+ connection, err :=
driverManager.GetConnection(ctx, connectionString)
+ if err != nil {
return errors.Wrapf(err, "%s can't
connect to", connectionUrl.Host)
}
log.Info().Str("connectionId",
connectionId).Msg("connected")
- connections[connectionId] =
connectionResult.GetConnection()
+ connections[connectionId] = connection
connectionsChanged()
return nil
},
@@ -108,15 +109,15 @@ var rootCommand = Command{
{
Name: "disconnect",
Description: "Disconnect a connection",
- action: func(_ Command, connectionString string) error {
+ action: func(ctx context.Context, _ Command,
connectionString string) error {
if connection, ok :=
connections[connectionString]; !ok {
return errors.Errorf("%s not
connected", connectionString)
} else {
- closeResult := <-connection.Close()
+ err := connection.Close()
log.Info().Str("connectionString",
connectionString).Msg("connectionString disconnected")
delete(connections, connectionString)
connectionsChanged()
- if err := closeResult.GetErr(); err !=
nil {
+ if err != nil {
return errors.Wrapf(err, "%s
can't close", connectionString)
}
}
@@ -132,7 +133,7 @@ var rootCommand = Command{
{
Name: "read",
Description: "Starts a read request (switched mode to
read edit)",
- action: func(_ Command, connectionsString string) error
{
+ action: func(ctx context.Context, _ Command,
connectionsString string) error {
if connection, ok :=
connections[connectionsString]; !ok {
return errors.Errorf("%s not
connected", connectionsString)
} else {
@@ -149,7 +150,7 @@ var rootCommand = Command{
{
Name: "read-direct",
Description: "Builds a read request with the supplied
field",
- action: func(c Command, connectionsStringAndFieldQuery
string) error {
+ action: func(ctx context.Context, c Command,
connectionsStringAndFieldQuery string) error {
split :=
strings.Split(connectionsStringAndFieldQuery, " ")
if len(split) != 2 {
return errors.Errorf("%s expects
exactly two arguments [connection url] [fieldQuery]", c)
@@ -165,7 +166,7 @@ var rootCommand = Command{
if err != nil {
return errors.Wrapf(err, "%s
can't read", connectionsString)
}
- readRequestResult :=
<-readRequest.Execute()
+ readRequestResult :=
<-readRequest.Execute(ctx)
if err := readRequestResult.GetErr();
err != nil {
return errors.Wrapf(err, "%s
can't read", connectionsString)
}
@@ -196,7 +197,7 @@ var rootCommand = Command{
{
Name: "write",
Description: "Starts a write request (switched mode to
write edit)",
- action: func(_ Command, connectionsString string) error
{
+ action: func(ctx context.Context, _ Command,
connectionsString string) error {
if connection, ok :=
connections[connectionsString]; !ok {
return errors.Errorf("%s not
connected", connectionsString)
} else {
@@ -213,7 +214,7 @@ var rootCommand = Command{
{
Name: "write-direct",
Description: "Builds a write request with the supplied
field",
- action: func(c Command, connectionsStringAndFieldQuery
string) error {
+ action: func(ctx context.Context, c Command,
connectionsStringAndFieldQuery string) error {
split :=
strings.Split(connectionsStringAndFieldQuery, " ")
if len(split) != 3 {
return errors.Errorf("%s expects
exactly three arguments [connection url] [fieldQuery] [value]", c)
@@ -229,7 +230,7 @@ var rootCommand = Command{
if err != nil {
return errors.Wrapf(err, "%s
can't write", connectionsString)
}
- writeRequestResult :=
<-writeRequest.Execute()
+ writeRequestResult :=
<-writeRequest.Execute(ctx)
if err := writeRequestResult.GetErr();
err != nil {
return errors.Wrapf(err, "%s
can't write", connectionsString)
}
@@ -260,7 +261,7 @@ var rootCommand = Command{
{
Name: "browse",
Description: "Starts a browse request (switched mode to
browse edit)",
- action: func(_ Command, connectionsString string) error
{
+ action: func(ctx context.Context, _ Command,
connectionsString string) error {
if connection, ok :=
connections[connectionsString]; !ok {
return errors.Errorf("%s not
connected", connectionsString)
} else {
@@ -277,7 +278,7 @@ var rootCommand = Command{
{
Name: "browse-direct",
Description: "Builds a browse request with the supplied
field",
- action: func(c Command, connectionsStringAndFieldQuery
string) error {
+ action: func(ctx context.Context, c Command,
connectionsStringAndFieldQuery string) error {
split :=
strings.Split(connectionsStringAndFieldQuery, " ")
if len(split) != 2 {
return errors.Errorf("%s expects
exactly three arguments [connection url] [fieldQuery]", c)
@@ -293,7 +294,7 @@ var rootCommand = Command{
if err != nil {
return errors.Wrapf(err, "%s
can't browse", connectionsString)
}
- browseRequestResult :=
<-browseRequest.ExecuteWithInterceptor(func(result apiModel.PlcBrowseItem) bool
{
+ browseRequestResult :=
<-browseRequest.ExecuteWithInterceptor(ctx, func(result apiModel.PlcBrowseItem)
bool {
// TODO: Disabled for now ...
not quite sure what this is for ...
//numberOfMessagesReceived++
//messageReceived(numberOfMessagesReceived, time.Now(), result)
@@ -330,7 +331,7 @@ var rootCommand = Command{
{
Name: "register",
Description: "register a driver in the subsystem",
- action: func(_ Command, driver string) error {
+ action: func(ctx context.Context, _ Command, driver
string) error {
return registerDriver(driver)
},
parameterSuggestions: func(currentText string) (entries
[]string) {
@@ -345,7 +346,7 @@ var rootCommand = Command{
{
Name: "subscribe",
Description: "Starts a subscription request (switched
mode to subscribe edit)",
- action: func(_ Command, connectionsString string) error
{
+ action: func(ctx context.Context, _ Command,
connectionsString string) error {
if connection, ok :=
connections[connectionsString]; !ok {
return errors.Errorf("%s not
connected", connectionsString)
} else {
@@ -362,7 +363,7 @@ var rootCommand = Command{
{
Name: "subscribe-direct",
Description: "Builds a subscriptions request with the
supplied field",
- action: func(c Command, connectionsStringAndFieldQuery
string) error {
+ action: func(ctx context.Context, c Command,
connectionsStringAndFieldQuery string) error {
split :=
strings.Split(connectionsStringAndFieldQuery, " ")
if len(split) != 2 {
return errors.Errorf("%s expects
exactly two arguments [connection url] [fieldQuery]", c)
@@ -381,7 +382,7 @@ var rootCommand = Command{
if err != nil {
return errors.Wrapf(err, "%s
can't subscribe", connectionsString)
}
- subscriptionRequestResult :=
<-subscriptionRequest.Execute()
+ subscriptionRequestResult :=
<-subscriptionRequest.Execute(ctx)
if err :=
subscriptionRequestResult.GetErr(); err != nil {
return errors.Wrapf(err, "%s
can't subscribe", connectionsString)
}
@@ -416,7 +417,7 @@ var rootCommand = Command{
{
Name: "get",
Description: "Get a log level",
- action: func(_ Command, _ string) error
{
+ action: func(ctx context.Context, _
Command, _ string) error {
_, _ =
fmt.Fprintf(commandOutput, "Current log level %s", log.Logger.GetLevel())
return nil
},
@@ -424,7 +425,7 @@ var rootCommand = Command{
{
Name: "set",
Description: "Sets a log level",
- action: func(_ Command, level string)
error {
+ action: func(ctx context.Context, _
Command, level string) error {
parseLevel, err :=
zerolog.ParseLevel(level)
if err != nil {
return
errors.Wrapf(err, "Error setting log level")
@@ -462,7 +463,7 @@ var rootCommand = Command{
{
Name: "on",
Description: "trace on",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xConfig.TraceTransactionManagerWorkers = true
return nil
},
@@ -470,7 +471,7 @@ var rootCommand = Command{
{
Name: "off",
Description: "trace
off",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xConfig.TraceTransactionManagerWorkers = false
return nil
},
@@ -484,7 +485,7 @@ var rootCommand = Command{
{
Name: "on",
Description: "trace on",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xConfig.TraceTransactionManagerTransactions = true
return nil
},
@@ -492,7 +493,7 @@ var rootCommand = Command{
{
Name: "off",
Description: "trace
off",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xConfig.TraceTransactionManagerTransactions = false
return nil
},
@@ -506,7 +507,7 @@ var rootCommand = Command{
{
Name: "on",
Description: "trace on",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xConfig.TraceDefaultMessageCodecWorker = true
return nil
},
@@ -514,7 +515,7 @@ var rootCommand = Command{
{
Name: "off",
Description: "trace
off",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xConfig.TraceDefaultMessageCodecWorker = false
return nil
},
@@ -528,7 +529,7 @@ var rootCommand = Command{
{
Name: "on",
Description: "debug on",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xBrowserLog
= zerolog.New(zerolog.ConsoleWriter{Out: tview.ANSIWriter(consoleOutput)})
return nil
},
@@ -536,7 +537,7 @@ var rootCommand = Command{
{
Name: "off",
Description: "debug
off",
- action: func(_ Command,
_ string) error {
+ action: func(ctx
context.Context, _ Command, _ string) error {
plc4xBrowserLog
= zerolog.Nop()
return nil
},
@@ -549,14 +550,14 @@ var rootCommand = Command{
subCommands: []Command{
{
Name: "list",
- action:
func(currentCommand Command, argument string) error {
+ action: func(ctx
context.Context, currentCommand Command, argument string) error {
_, _ =
fmt.Fprintf(commandOutput, "Auto-register enabled drivers:\n %s\n",
strings.Join(config.AutoRegisterDrivers, "\n "))
return nil
},
},
{
Name: "enable",
- action: func(_ Command,
argument string) error {
+ action: func(ctx
context.Context, _ Command, argument string) error {
return
enableAutoRegister(argument)
},
parameterSuggestions:
func(currentText string) (entries []string) {
@@ -570,7 +571,7 @@ var rootCommand = Command{
},
{
Name: "disable",
- action: func(_ Command,
argument string) error {
+ action: func(ctx
context.Context, _ Command, argument string) error {
return
disableAutoRegister(argument)
},
parameterSuggestions:
func(currentText string) (entries []string) {
@@ -589,7 +590,7 @@ var rootCommand = Command{
{
Name: "history",
Description: "outputs the last commands",
- action: func(_ Command, _ string) error {
+ action: func(ctx context.Context, _ Command, _ string)
error {
outputCommandHistory()
return nil
},
@@ -597,7 +598,7 @@ var rootCommand = Command{
{
Name: "clear",
Description: "clear all outputs",
- action: func(_ Command, _ string) error {
+ action: func(ctx context.Context, _ Command, _ string)
error {
messageOutputClear()
consoleOutputClear()
commandOutputClear()
@@ -607,7 +608,7 @@ var rootCommand = Command{
{
Name: "message",
Description: "clears message output",
- action: func(_ Command, _ string) error
{
+ action: func(ctx context.Context, _
Command, _ string) error {
messageOutputClear()
return nil
},
@@ -615,7 +616,7 @@ var rootCommand = Command{
{
Name: "console",
Description: "clears console output",
- action: func(_ Command, _ string) error
{
+ action: func(ctx context.Context, _
Command, _ string) error {
consoleOutputClear()
return nil
},
@@ -623,7 +624,7 @@ var rootCommand = Command{
{
Name: "command",
Description: "clears command output",
- action: func(_ Command, _ string) error
{
+ action: func(ctx context.Context, _
Command, _ string) error {
commandOutputClear()
return nil
},
@@ -638,7 +639,7 @@ func init() {
rootCommand.subCommands = append(rootCommand.subCommands, Command{
Name: "help",
Description: "prints out this help",
- action: func(_ Command, _ string) error {
+ action: func(_ context.Context, _ Command, _ string) error {
_, _ = fmt.Fprintf(commandOutput, "[#0000ff]Available
commands[white]\n")
rootCommand.visit(0, func(currentIndent int, command
Command) {
indentString := strings.Repeat(" ",
currentIndent)
@@ -658,7 +659,7 @@ var NotDirectlyExecutable = errors.New("Not directly
executable")
type Command struct {
Name string
Description string
- action func(currentCommand Command, argument string) error
+ action func(ctx context.Context, currentCommand Command,
argument string) error
subCommands []Command
parameterSuggestions func(currentText string) (entries []string)
}
@@ -786,7 +787,7 @@ func (c Command) Execute(commandText string) (err error) {
Str("commandText", commandText).
Msg("c executes commandText directly")
preparedForParameters := c.prepareForParameters(commandText)
- return c.action(c, preparedForParameters)
+ return c.action(context.TODO(), c, preparedForParameters)
}
}