mphandler

package
v0.0.0-...-87d254f Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2016 License: GPL-3.0 Imports: 6 Imported by: 2

Documentation

Overview

Package mphandler implements a MsgPack/TCP interface to the Archiver API at http://godoc.org/github.com/gtfierro/giles/archiver

Overview

The MsgPack format for sMAP is designed to look very similar to the JSON format, while also making it possible to handle different commands (e.g. not just reads) as well as permissions including an API key.

type MsgPackSmap struct {
	Path       string
	UUID       string `codec:"uuid"`
	Key        string `codec:"key"`
	Properties map[string]interface{}
	Metadata   map[string]interface{}
	Readings   [][2]interface{}
}

We need to augment this struct with some information in a simple packet header that gives us the ability to describe packet length and packet command.

Header:

+----------------------+----------------------+----
| packet len (2 bytes) | packet type (1 byte) | packet contents...
+----------------------+----------------------+----

Packet length is 2 bytes. Afterwards comes a single byte that contains the packet type (this will be a value from a predetermined Enum that will be described below. Following this header comes the actual packet contents

Index

Constants

View Source
const (
	DATA_WRITE = iota
	DATA_PREV
	DATA_NEXT
	DATA_RANGE
	TAG_GET
	TAG_SET
	QUERY
)
View Source
const (
	BUFFER_SIZE = 65536
)

Variables

This section is empty.

Functions

func AddReadings

func AddReadings(a *archiver.Archiver, md map[string]interface{})

TODO: check for malformed

func HandleTCP

func HandleTCP(a *archiver.Archiver, port int)

func HandleUDP

func HandleUDP(a *archiver.Archiver, port int)

Types

type MessageType

type MessageType uint

func ParseHeader

func ParseHeader(input *[]byte, offset int) (MessageType, int)

Given a reference to a byte slice (probably your incoming buffer) and an offset into that slice, decode the header and return the MessageType and the total packet length

Jump to

Keyboard shortcuts

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