gopcua

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context) (opcua.Provider, error)

func GetEnity

func GetEnity(ctx context.Context, enityName string) (interface{}, error)

func Registrate

func Registrate(ctx context.Context) (context.Context, error)

func RegistrateEnity

func RegistrateEnity(ctx context.Context, enityName string, options interface{}) (context.Context, error)

func VariantToFloat64

func VariantToFloat64(value *ua.Variant) float64

Types

type Config

type Config struct {
	// DSN is a connection string in form of DSN. Example:
	// opc.tcp://host:port.
	// Default: "opc.tcp://localhost:4840"
	DSN string `envconfig:"optional"`
	// SecurityPolicy sets the security policy uri for the secure channel.
	SecurityPolicy string `envconfig:"optional"`
	// SecurityModeString sets the security mode for the secure channel.
	// Valid values are "None", "Sign", and "SignAndEncrypt".
	SecurityMode string `envconfig:"optional"`
	// Certificate sets the client X509 certificate in the secure channel configuration
	// from the PEM or DER encoded file. It also detects and sets the ApplicationURI
	// from the URI within the certificate.
	CertificateFile string `envconfig:"optional"`
	// PrivateKeyFile sets the RSA private key in the secure channel configuration
	// from a PEM or DER encoded file.
	PrivateKeyFile string `envconfig:"optional"`
	// Subscription interval
	Interval time.Duration `envconfig:"optional"`
	// Handle is a client gandle
	Handle uint32 `envconfig:"optional"`
	// Queue size
	QueueSize int `envconfig:"optional"`
	// StartWatcher indicates to connection controller that it should
	// also start asynchronous connection watcher.
	StartWatcher bool `envconfig:"optional"`
	// Timeout is a timeout in seconds for connection checking. Every
	// this count of seconds opcua connection will be checked for
	// aliveness and, if it dies, attempt to reestablish connection
	// will be made. Default timeout is 10 seconds.
	Timeout time.Duration `envconfig:"optional"`
}

Config represents configuration structure for every connection.

func (*Config) SetDefault

func (c *Config) SetDefault() *Config

SetDefault checks connection config. If required field is empty - it will be filled with some default value. Returns a copy of config.

type CosumeHandler

type CosumeHandler func(*monitor.DataChangeMessage) error

CosumeHandler is handler for consume messages

type Enity

type Enity struct {
	// Metrics
	stats.Service
	// OPC UA connection
	Conn *opcua.Client
	// Subscription
	Subscription *monitor.Subscription
	// contains filtered or unexported fields
}

Enity is a connection controlling structure. It controls connection, asynchronous queue and everything that related to specified connection.

func GetEnityTypeCast

func GetEnityTypeCast(ctx context.Context, enityName string) (*Enity, error)

func NewEnity

func NewEnity(ctx context.Context, name string, cfg interface{}) (*Enity, error)

NewEnity create new enity.

func (*Enity) GetMetrics

func (c *Enity) GetMetrics(prefix string) stats.MapMetricsOptions

GetMetrics return map of the metrics from database connection

func (*Enity) GetReadyHandlers

func (c *Enity) GetReadyHandlers(prefix string) stats.MapCheckFunc

GetReadyHandlers return array of the readyHandlers from database connection

func (*Enity) Shutdown

func (c *Enity) Shutdown() error

Shutdown shutdowns queue worker and connection watcher. Later will also close connection to database. This is a blocking call.

func (*Enity) Start

func (c *Enity) Start() error

Start starts connection workers and connection procedure itself.

func (*Enity) Subscribe

func (c *Enity) Subscribe(options *SubscribeOptions) error

Subscribe to channel for receiving message

func (*Enity) SubscribeNodeID

func (c *Enity) SubscribeNodeID(nodeID string) error

func (*Enity) WaitForEstablishing

func (c *Enity) WaitForEstablishing()

WaitForEstablishing will block execution until connection will be successfully established and database migrations will be applied (or rolled back).

type Provider

type Provider struct {
	*providerwithmetrics.Provider
}

Provider provides PostgreSQL database worker. This provider supports asynchronous database actions (like bulk inserting). Every connection will have own goroutine for queue processing.

func NewProvider

func NewProvider(ctx context.Context) *Provider

Initialize should initialize provider. If asynchronous mode supported by provider (e.g. for batch inserting using transactions) queue processor should also be started here.

func (*Provider) CreateEnity

func (p *Provider) CreateEnity(enityName string, options interface{}) error

CreateEnity should create enity using passed parameters.

func (*Provider) GetEnity

func (p *Provider) GetEnity(connectionName string) (interface{}, error)

GetEnity should return pointer to connection structure to caller.

type SubscribeOptions

type SubscribeOptions struct {
	ConsumeHndl CosumeHandler
}

SubscribeOptions describes struct with options for subscriber

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL