httphandler

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: 15 Imported by: 1

Documentation

Overview

Package httphandler implements an HTTP interface to the Archiver API at http://godoc.org/github.com/gtfierro/giles/archiver

Overview

This HTTP interface to the sMAP archiver presents most of the expected interface as described in the Archiver documentation at http://pythonhosted.org/Smap/en/2.0/archiver.html. With the exception of DELETE action and the /api/query interface, this interface matches what is expected.

For sample usage, look at https://github.com/gtfierro/giles/blob/master/giles/giles.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddReadingHandler

func AddReadingHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Handles POSTing of new data The HandleJSON method parses the message received from the sMAP drivers and delivers them as an array. Because metadata is delivered as k/v pairs representing a tree, we have a pre-loop that stores the metadata values at the higher levels of the tree. Then, when we loop through the data to add it to the leaves of the tree (the actual timeseries), we query the prefixes of the timeseries path to get all the 'trickle down' metadata from the higher parts of the metadata tree. That logic takes place in store.SavePathMetadata and store.SaveMetadata

An example of a valid sMAP object is

{
  "/sensor0" : {
    "Metadata" : {
      "SourceName" : "Test Source",
        "Location" : { "City" : "Berkeley" }
    },
      "Properties": {
        "Timezone": "America/Los_Angeles",
        "UnitofMeasure": "Watt",
        "ReadingType": "double"
      },
      "Readings" : [[1351043674000, 0], [1351043675000, 1]],
      "uuid" : "d24325e6-1d7d-11e2-ad69-a7c2fa8dba61"
  }
}

func Handle

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

func MetadataRepublishHandler

func MetadataRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

func Query2Handler

func Query2Handler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Resolves sMAP queries and returns results

func QueryHandler

func QueryHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Resolves sMAP queries and returns results

func QueryRepublishHandler

func QueryRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Receives POST request which contains metadata query. Subscribes the requester to readings from streams which match that metadata query

func RepublishHandler

func RepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Receives POST request which contains metadata query. Subscribes the requester to readings from streams which match that metadata query

func RepublishHandler2

func RepublishHandler2(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Receives POST request which contains metadata query. Subscribes the requester to readings from streams which match that metadata query

func StreamingQueryHandler

func StreamingQueryHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

func TagsHandler

func TagsHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

*

  • Returns metadata for a uuid. A limited GET alternative to the POST query handler

*

func UUIDRepublishHandler

func UUIDRepublishHandler(a *archiver.Archiver, rw http.ResponseWriter, req *http.Request, ps httprouter.Params)

Types

type HTTPSubscriber

type HTTPSubscriber struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Implements the archiver.Subscriber interface for the Republish mechanism

func NewHTTPSubscriber

func NewHTTPSubscriber(rw http.ResponseWriter) *HTTPSubscriber

func (*HTTPSubscriber) GetNotify

func (hs *HTTPSubscriber) GetNotify() <-chan bool

func (*HTTPSubscriber) Send

func (hs *HTTPSubscriber) Send(msg interface{})

called when we receive a new message

func (*HTTPSubscriber) SendError

func (hs *HTTPSubscriber) SendError(e error)

Jump to

Keyboard shortcuts

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