diff --git a/providers/opcua/connection/connection.go b/providers/opcua/connection/connection.go index f918f4ee91..0c62b31d49 100644 --- a/providers/opcua/connection/connection.go +++ b/providers/opcua/connection/connection.go @@ -14,7 +14,7 @@ import ( ) type OpcuaConnection struct { - id uint32 + plugin.Connection Conf *inventory.Config asset *inventory.Asset client *opcua.Client @@ -23,9 +23,9 @@ type OpcuaConnection struct { func NewOpcuaConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*OpcuaConnection, error) { conn := &OpcuaConnection{ - Conf: conf, - id: id, - asset: asset, + Connection: plugin.NewConnection(id, asset), + Conf: conf, + asset: asset, } // initialize connection @@ -82,10 +82,6 @@ func (c *OpcuaConnection) Name() string { return "opcua" } -func (c *OpcuaConnection) ID() uint32 { - return c.id -} - func (c *OpcuaConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/opcua/provider/provider.go b/providers/opcua/provider/provider.go index ab2450caca..33f92e2cf2 100644 --- a/providers/opcua/provider/provider.go +++ b/providers/opcua/provider/provider.go @@ -106,16 +106,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err