pkg

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Client identifier configurations
	Username = "Username"
	Password = "Password"
	ClientId = "ClientId"

	// Connection configuration names
	ConnectTimeout = "ConnectTimeout"
	AutoReconnect  = "AutoReconnect"

	// TLS configuration names
	SkipCertVerify = "SkipCertVerify"
	CertFile       = "CertFile"
	KeyFile        = "KeyFile"
	CaFile         = "CaFile"
	KeyPEMBlock    = "KeyPEMBlock"
	CertPEMBlock   = "CertPEMBlock"
	CaPEMBlock     = "CaPEMBlock"

	// MQTT Specifics
	Qos          = "Qos"
	KeepAlive    = "KeepAlive"
	Retained     = "Retained"
	CleanSession = "CleanSession"

	// NATS specifics
	RetryOnFailedConnect = "RetryOnFailedConnect"
	Format               = "Format"
	QueueGroup           = "QueueGroup"
	ExactlyOnce          = "ExactlyOnce"

	// NATS JetStream specifics
	Durable                 = "Durable"
	Subject                 = "Subject"
	AutoProvision           = "AutoProvision"
	Deliver                 = "Deliver"
	DefaultPubRetryAttempts = "DefaultPubRetryAttempts"
)

Variables

View Source
var TlsSchemes = []string{"tcps", "ssl", "tls", "redis", "nats"}

Functions

func DoRequest

func DoRequest(
	subscribe func(topics []types.TopicChannel, messageErrors chan error) error,
	unsubscribe func(topics ...string) error,
	publish func(message types.MessageEnvelope, topic string) error,
	requestMessage types.MessageEnvelope,
	requestTopic string,
	responseTopicPrefix string,
	requestTimeout time.Duration) (*types.MessageEnvelope, error)

DoRequest publishes a request containing a RequestID to the specified topic, then subscribes to a response topic which contains the RequestID. Once the response is received, the response topic is unsubscribed and the response data is returned. If no response is received within the timeout period, a timed out error returned.

func GenerateTLSForClientClientOptions

func GenerateTLSForClientClientOptions(
	brokerURL string,
	tlsConfigurationOptions TlsConfigurationOptions,
	certCreator X509KeyPairCreator,
	certLoader X509KeyLoader,
	caCertCreator X509CaCertCreator,
	caCertLoader X509CaCertLoader,
	pemDecoder PEMDecoder) (*tls.Config, error)

GenerateTLSForClientClientOptions creates a tls.Config which can be used when configuring the underlying client. If TLS is not needed then nil will be returned which can be used to signal no TLS is needed to the client.

func Load

func Load(config map[string]string, des interface{}) error

load by reflect to check map key and then fetch the value. This function ignores properties that have not been provided from the source. Therefore it is recommended to provide a destination struct with reasonable defaults.

NOTE: This logic was borrowed from device-mqtt-go and some additional logic was added to accommodate more types. https://github.com/edgexfoundry/device-mqtt-go/blob/a0d50c6e03a7f7dcb28f133885c803ffad3ec502/internal/driver/config.go#L74-L101

Types

type BrokerURLErr

type BrokerURLErr struct {
	// contains filtered or unexported fields
}

BrokerURLErr represents an error associated parsing a broker's URL.

func NewBrokerURLErr

func NewBrokerURLErr(description string) BrokerURLErr

NewBrokerURLErr constructs a new BrokerURLErr

func (BrokerURLErr) Error

func (bue BrokerURLErr) Error() string

type CertificateErr

type CertificateErr struct {
	// contains filtered or unexported fields
}

CertificateErr represents an error associated with interacting with a Certificate.

func NewCertificateErr

func NewCertificateErr(message string) CertificateErr

NewCertificateErr constructs a new CertificateErr

func (CertificateErr) Error

func (ce CertificateErr) Error() string

type InvalidTopicErr

type InvalidTopicErr struct {
	// contains filtered or unexported fields
}

func NewInvalidTopicErr

func NewInvalidTopicErr(topic string, description string) InvalidTopicErr

func (InvalidTopicErr) Error

func (ite InvalidTopicErr) Error() string

type MissingConfigurationErr

type MissingConfigurationErr struct {
	// contains filtered or unexported fields
}

func NewMissingConfigurationErr

func NewMissingConfigurationErr(missingConfiguration string, message string) MissingConfigurationErr

func (MissingConfigurationErr) Error

func (mce MissingConfigurationErr) Error() string

type NoopClient

type NoopClient struct{}

func (NoopClient) Connect

func (n NoopClient) Connect() error

func (NoopClient) Disconnect

func (n NoopClient) Disconnect() error

func (NoopClient) Publish

func (n NoopClient) Publish(message types.MessageEnvelope, topic string) error

func (NoopClient) Request

func (n NoopClient) Request(message types.MessageEnvelope, targetServiceName string, requestTopic string, timeout time.Duration) (*types.MessageEnvelope, error)

func (NoopClient) Subscribe

func (n NoopClient) Subscribe(topics []types.TopicChannel, messageErrors chan error) error

func (NoopClient) Unsubscribe

func (n NoopClient) Unsubscribe(topics ...string) error

type PEMDecoder

type PEMDecoder func(data []byte) (*pem.Block, []byte)

PEMDecoder defines the function signature for finding the next PEM formatted block in the input. It returns that block and the remainder of the input.

type PublishHostURLErr

type PublishHostURLErr struct {
	// contains filtered or unexported fields
}

func NewPublishHostURLErr

func NewPublishHostURLErr(message string) PublishHostURLErr

func (PublishHostURLErr) Error

func (p PublishHostURLErr) Error() string

type SubscribeHostURLErr

type SubscribeHostURLErr struct {
	// contains filtered or unexported fields
}

func NewSubscribeHostURLErr

func NewSubscribeHostURLErr(message string) SubscribeHostURLErr

func (SubscribeHostURLErr) Error

func (p SubscribeHostURLErr) Error() string

type TlsConfigurationOptions

type TlsConfigurationOptions struct {
	SkipCertVerify bool
	CertFile       string
	KeyFile        string
	CaFile         string
	KeyPEMBlock    string
	CertPEMBlock   string
	CaPEMBlock     string
}

func CreateDefaultTlsConfigurationOptions

func CreateDefaultTlsConfigurationOptions() TlsConfigurationOptions

type X509CaCertCreator

type X509CaCertCreator func(caCertPEMBlock []byte) (*x509.Certificate, error)

X509CaCertCreator defines the function signature for creating a CA certificate based on PEM encoding.

type X509CaCertLoader

type X509CaCertLoader func(caCertFile string) ([]byte, error)

X509CaCertLoader defines the function signature for loading a PEM formatted block from the given CA certificate file.

type X509KeyLoader

type X509KeyLoader func(certFile string, keyFile string) (tls.Certificate, error)

X509KeyLoader defines a function signature for loading a tls.Certificate from cert and key files.

type X509KeyPairCreator

type X509KeyPairCreator func(certPEMBlock []byte, keyPEMBlock []byte) (tls.Certificate, error)

X509KeyPairCreator defines the function signature for creating a tls.Certificate based on PEM encoding.

Directories

Path Synopsis
Package redis contains a RedisClient which leverages go-redis to interact with a Redis server.
Package redis contains a RedisClient which leverages go-redis to interact with a Redis server.

Jump to

Keyboard shortcuts

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