kubeClient

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package kubeClient provide the functionality to initalize a MQTT connection and update the device twin in a feauture version this package should also provide to handle incomming message via a callback function

Index

Constants

This section is empty.

Variables

View Source
var (
	Prefix                = "$hw/events/device/"
	StateUpdateSuffix     = "/state/update"
	TwinUpdateSuffix      = "/twin/update"
	TwinCloudUpdateSuffix = "/twin/cloud_updated"
	TwinGetResultSuffix   = "/twin/get/result"
	TwinGetSuffix         = "/twin/get"
)

Functions

func Init

func Init(ipAddress, id, user, password string)

Init hit initalise the MQTT connection and set the used ipAddress and deviceID in a feature version this function also register the callback method to handle incomming messages ipAddress and deviceID has to be set! If you don't want to add an user or an password in the MQTT Connection set user and password to nil

func Update

func Update(value string)

Update this function is used to update values on the edge and in the cloud

Types

type BaseMessage

type BaseMessage struct {
	EventID   string `json:"event_id"`
	Timestamp int64  `json:"timestamp"`
}

BaseMessage the base struct of event message

type DeviceStateUpdate

type DeviceStateUpdate struct {
	State string `json:"state,omitempty"`
}

DeviceStateUpdate is the structure used in updating the device state

type DeviceTwinUpdate

type DeviceTwinUpdate struct {
	BaseMessage
	Twin map[string]*MsgTwin `json:"twin"`
}

DeviceTwinUdpdate the struct of device twin update

type DeviceTwinUpdateDelta

type DeviceTwinUpdateDelta struct {
	BaseMessage
	Twin  map[string]*MsgTwin `json:"twin"`
	Delta map[string]string   `json:"delta"`
}

type MsgTwin

type MsgTwin struct {
	Actual          *TwinValue    `json:"actual,omitempty"`
	Expected        *TwinValue    `json:"expected,omitempty"`
	Optional        *bool         `json:"optional,omitempty"`
	Metadata        *TypeMetadata `json:"metadata,omitempty"`
	ExpectedVersion *TwinValue    `json:"expected_version,omitempty"`
	ActualVersion   *TwinVersion  `json:"actual_version,omitempty"`
}

MsgTwin the structe of device twin

type Token

type Token interface {
	Wait() bool
	WaitTimeout(time.Duration) bool
	Error() error
}

type TwinValue

type TwinValue struct {
	Value    *string        `json:"value,omitempty"`
	Metadata *ValueMetadata `json:"metadata,omitempty"`
}

TwinValue the struct of twin value

type TwinVersion

type TwinVersion struct {
	CloudVersion int64 `json:"cloud"`
	EdgeVersion  int64 `json:"edge"`
}

TwinVersion twin version

type TypeMetadata

type TypeMetadata struct {
	Type string `json:"type,omitempty"`
}

TypeMetadata the meta of value type

type ValueMetadata

type ValueMetadata struct {
	Timestamp int64 `json:"timestamp,omitempty"`
}

ValueMetadata the meta of value

Jump to

Keyboard shortcuts

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