Skip to content

Commit

Permalink
Add context to GetEndpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Mar 26, 2021
1 parent e8807bb commit 4ab5e03
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
)

// GetEndpoints returns the available endpoint descriptions for the server.
func GetEndpoints(endpoint string) ([]*ua.EndpointDescription, error) {
func GetEndpoints(ctx context.Context, endpoint string) ([]*ua.EndpointDescription, error) {
c := NewClient(endpoint, AutoReconnect(false))
if err := c.Dial(context.Background()); err != nil {
if err := c.Dial(ctx); err != nil {
return nil, err
}
defer c.Close()
Expand Down
2 changes: 1 addition & 1 deletion examples/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func main() {
ctx := context.Background()

// Get a list of the endpoints for our target server
endpoints, err := opcua.GetEndpoints(*endpoint)
endpoints, err := opcua.GetEndpoints(ctx, *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/datetime/datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {

ctx := context.Background()

endpoints, err := opcua.GetEndpoints(*endpoint)
endpoints, err := opcua.GetEndpoints(ctx, *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion examples/endpoints/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package main

import (
"context"
"flag"
"log"

Expand All @@ -19,7 +20,7 @@ func main() {
flag.Parse()
log.SetFlags(0)

eps, err := opcua.GetEndpoints(*endpoint)
eps, err := opcua.GetEndpoints(context.Background(), *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func main() {
cancel()
}()

endpoints, err := opcua.GetEndpoints(*endpoint)
endpoints, err := opcua.GetEndpoints(ctx, *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/subscribe/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), d)
defer cancel()

endpoints, err := opcua.GetEndpoints(*endpoint)
endpoints, err := opcua.GetEndpoints(ctx, *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/trigger/trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), d)
defer cancel()

endpoints, err := opcua.GetEndpoints(*endpoint)
endpoints, err := opcua.GetEndpoints(ctx, *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/udt/udt.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {

ctx := context.Background()

endpoints, err := opcua.GetEndpoints(*endpoint)
endpoints, err := opcua.GetEndpoints(ctx, *endpoint)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 4ab5e03

Please sign in to comment.