common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

View Source
const APIVersion = "2018-01-16"

APIVersion is yet to figure out what it implies.

Variables

This section is empty.

Functions

func GenID

func GenID() string

func RootCAs

func RootCAs() *x509.CertPool

RootCAs root CA certificates pool for connecting to the cloud.

func TLSConfig

func TLSConfig(hostname string) *tls.Config

Types

type LevelLogger added in v0.1.0

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

LevelLogger is a logger that supports log levels.

func NewLogger added in v0.1.0

func NewLogger(name string, lvl LogLevel, print PrintFunc) *LevelLogger

NewLogger creates a new leveled logger instance with the given parameters.

func NewLoggerFromEnv added in v0.1.0

func NewLoggerFromEnv(name, key string) *LevelLogger

NewLoggerFromEnv returns a LevelLogger with the name prefix and severity based on the named environment variable or it falls back to LevelWarn if it's missing.

It uses the standard log.Print function for output so it can be controlled via the exposed configuration methods.

func (*LevelLogger) Debugf added in v0.1.0

func (l *LevelLogger) Debugf(format string, v ...interface{})

func (*LevelLogger) Errorf added in v0.1.0

func (l *LevelLogger) Errorf(format string, v ...interface{})

func (*LevelLogger) Infof added in v0.1.0

func (l *LevelLogger) Infof(format string, v ...interface{})

func (*LevelLogger) Warnf added in v0.1.0

func (l *LevelLogger) Warnf(format string, v ...interface{})

type LogLevel added in v0.1.0

type LogLevel uint8

LogLevel is logging severity.

const (
	LevelError LogLevel = iota
	LevelWarn
	LevelInfo
	LevelDebug
)

func (LogLevel) String added in v0.1.0

func (lvl LogLevel) String() string

String returns log level string representation.

type Logger

type Logger interface {
	Errorf(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Debugf(format string, v ...interface{})
}

Logger is common logging interface.

type Message

type Message struct {
	// MessageID is a user-settable identifier for the message used for request-reply patterns.
	MessageID string `json:"MessageId,omitempty"`

	// To is a destination specified in cloud-to-device messages.
	To string `json:"To,omitempty"`

	// ExpiryTime is time of message expiration.
	ExpiryTime *time.Time `json:"ExpiryTimeUtc,omitempty"`

	// EnqueuedTime is time the Cloud-to-Device message was received by IoT Hub.
	EnqueuedTime *time.Time `json:"EnqueuedTime,omitempty"`

	// CorrelationID is a string property in a response message that typically
	// contains the MessageId of the request, in request-reply patterns.
	CorrelationID string `json:"CorrelationId,omitempty"`

	// UserID is an ID used to specify the origin of messages.
	UserID string `json:"UserId,omitempty"`

	// ConnectionDeviceID is an ID set by IoT Hub on device-to-cloud messages.
	// It contains the deviceId of the device that sent the message.
	ConnectionDeviceID string `json:"ConnectionDeviceId,omitempty"`

	// ConnectionDeviceGenerationID is an ID set by IoT Hub on device-to-cloud messages.
	// It contains the generationId (as per Device identity properties)
	// of the device that sent the message.
	ConnectionDeviceGenerationID string `json:"ConnectionDeviceGenerationId,omitempty"`

	// ConnectionAuthMethod is an authentication method set by IoT Hub on
	// device-to-cloud messages. This property contains information about
	// the authentication method used to authenticate the device sending the message.
	ConnectionAuthMethod string `json:"ConnectionAuthMethod,omitempty"`

	// MessageSource determines a device-to-cloud message transport.
	MessageSource string `json:"MessageSource,omitempty"`

	// Payload is message data.
	Payload []byte `json:"Payload,omitempty"`

	// Properties are custom message properties (property bags).
	Properties map[string]string `json:"Properties,omitempty"`

	// TransportOptions transport specific options.
	TransportOptions map[string]interface{} `json:"-"`
}

Message is a common message format for all device-facing protocols. This message format is used for both device-to-cloud and cloud-to-device messages. See: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-construct

type PrintFunc added in v0.1.0

type PrintFunc func(v ...interface{})

PrintFunc is used for writing logs that works as fmt.Print.

Jump to

Keyboard shortcuts

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