handler

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2016 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AMQPDownlinkQueue is the AMQP queue to use for downlink
	AMQPDownlinkQueue = "ttn-handler-downlink"
)
View Source
var ErrNotNeeded = errors.New("Further processing not needed")

ErrNotNeeded indicates that the processing of a message should be aborted

View Source
var MQTTBufferSize = 10

MQTTBufferSize indicates the size for uplink channel buffers

View Source
var MQTTTimeout = 2 * time.Second

MQTTTimeout indicates how long we should wait for an MQTT publish

View Source
var ResponseDeadline = 100 * time.Millisecond

ResponseDeadline indicates how long

Functions

This section is empty.

Types

type DownlinkFunctions

type DownlinkFunctions struct {
	// Encoder is a JavaScript function that accepts the payload as JSON and
	// returns an array of bytes
	Encoder string

	// Logger is the logger that will be used to store logs
	Logger functions.Logger
}

DownlinkFunctions encodes payload using JavaScript functions

func (*DownlinkFunctions) Encode

func (f *DownlinkFunctions) Encode(payload map[string]interface{}, port uint8) ([]byte, error)

Encode encodes the map into a byte slice using the encoder payload function If no encoder function is set, this function returns an array.

func (*DownlinkFunctions) Process

func (f *DownlinkFunctions) Process(payload map[string]interface{}, port uint8) ([]byte, bool, error)

Process encode the specified field, converts it into a valid payload

type DownlinkProcessor

type DownlinkProcessor func(ctx log.Interface, appDown *types.DownlinkMessage, ttnDown *pb_broker.DownlinkMessage) error

DownlinkProcessor processes an application-layer downlink message to a downlik protobuf

type Handler

type Handler interface {
	component.Interface
	component.ManagementInterface

	WithMQTT(username, password string, brokers ...string) Handler
	WithAMQP(username, password, host, exchange string) Handler

	HandleUplink(uplink *pb_broker.DeduplicatedUplinkMessage) error
	HandleActivationChallenge(challenge *pb_broker.ActivationChallengeRequest) (*pb_broker.ActivationChallengeResponse, error)
	HandleActivation(activation *pb_broker.DeduplicatedDeviceActivationRequest) (*pb.DeviceActivationResponse, error)
	EnqueueDownlink(appDownlink *types.DownlinkMessage) error
}

Handler component

func NewRedisHandler

func NewRedisHandler(client *redis.Client, ttnBrokerID string) Handler

NewRedisHandler creates a new Redis-backed Handler

type UplinkFunctions

type UplinkFunctions struct {
	// Decoder is a JavaScript function that accepts the payload as byte array and
	// returns an object containing the decoded values
	Decoder string
	// Converter is a JavaScript function that accepts the data as decoded by
	// Decoder and returns an object containing the converted values
	Converter string
	// Validator is a JavaScript function that validates the data is converted by
	// Converter and returns a boolean value indicating the validity of the data
	Validator string

	// Logger is the logger that will be used to store logs
	Logger functions.Logger
}

UplinkFunctions decodes, converts and validates payload using JavaScript functions

func (*UplinkFunctions) Convert

func (f *UplinkFunctions) Convert(fields map[string]interface{}, port uint8) (map[string]interface{}, error)

Convert converts the values in the specified map to a another map using the Converter function. If the Converter function is not set, this function returns the data as-is

func (*UplinkFunctions) Decode

func (f *UplinkFunctions) Decode(payload []byte, port uint8) (map[string]interface{}, error)

Decode decodes the payload using the Decoder function into a map

func (*UplinkFunctions) Process

func (f *UplinkFunctions) Process(payload []byte, port uint8) (map[string]interface{}, bool, error)

Process decodes the specified payload, converts it and test the validity

func (*UplinkFunctions) Validate

func (f *UplinkFunctions) Validate(fields map[string]interface{}, port uint8) (bool, error)

Validate validates the values in the specified map using the Validator function. If the Validator function is not set, this function returns true

type UplinkProcessor

type UplinkProcessor func(ctx log.Interface, ttnUp *pb_broker.DeduplicatedUplinkMessage, appUp *types.UplinkMessage) error

UplinkProcessor processes an uplink protobuf to an application-layer uplink message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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