libDatabox

package module
v0.0.0-...-1011cb8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2017 License: MIT Imports: 16 Imported by: 0

README

libDatabox

import "./"

Overview

A golang library for interfacing with Databox APIs.

Install using go get github.com/me-box/lib-go-databox

Examples can be found in the samples directory

Index

Package files

export.go store-json.go store-timeseries.go subscriptions.go utils.go

func ExportLongpoll

func ExportLongpoll(destination string, payload string) (string, error)

func GetDsIdFromDsHref

func GetDsIdFromDsHref(href string) (string, error)

GetDsIdFromDsHref extracts the base data source ID from the href provied in the DATASOURCE_[name] environment variable.

func GetHttpsCredentials

func GetHttpsCredentials() string

GetHttpsCredentials Returns a string containing the HTTPS credentials to pass to https server when offering an https server. These are read form /run/secrets/DATABOX.pem and are generated by the container-manger at run time.

func GetStoreURLFromDsHref

func GetStoreURLFromDsHref(href string) (string, error)

GetStoreURLFromDsHref extracts the base store url from the href provied in the DATASOURCE_[name] environment variable.

func JsonUnmarshal

func JsonUnmarshal(s string) (map[string]interface{}, error)

JsonUnmarshal is a helper function to translate JSON stringified environment variable to go map[string]

func RegisterDatasource

func RegisterDatasource(href string, metadata StoreMetadata) (string, error)

RegisterDatasource is used by apps and drivers to register datasource in stores they own.

func StoreJSONGetlatest

func StoreJSONGetlatest(href string) (string, error)

func StoreJSONGetrange

func StoreJSONGetrange(href string, startTimestamp float64, endTimestamp float64) (string, error)

func StoreJSONGetsince

func StoreJSONGetsince(href string, startTimestamp float64) (string, error)

func StoreJSONWriteKV

func StoreJSONWriteKV(href string, data string) error

func StoreJSONWriteTS

func StoreJSONWriteTS(href string, data string) error

func StoreJSONreadKV

func StoreJSONreadKV(href string, key string) (string, error)

func StoreTsLast

func StoreTsLast(href string, n int) (string, error)

func StoreTsLastNrange

func StoreTsLastNrange(href string, n int, startTimestamp int, endTimestamp int) (string, error)

func StoreTsLastNsince

func StoreTsLastNsince(href string, n int, startTimestamp int) (string, error)

func StoreTsLatest

func StoreTsLatest(href string) (string, error)

func StoreTsRange

func StoreTsRange(href string, startTimestamp int, endTimestamp int) (string, error)

func StoreTsSince

func StoreTsSince(href string, startTimestamp int) (string, error)

func StoreTsWrite

func StoreTsWrite(href string, data string) (string, error)

func WSConnect

func WSConnect(href string) (chan []byte, error)

WSConnect connects to a target store's notification service

Returns a chan []byte that recives data from every route the connecting container is subscribed to. Data is a JSON string.

func WSSubscribe

func WSSubscribe(href string, storeType string) (string, error)

WSSubscribe Subscribes the caller to write notifications for a given route.

func WSUnsubscribe

func WSUnsubscribe(href string, storeType string) (string, error)

WSUnsubscribe Unsubscribes the caller to write notifications for a given route

func WaitForStoreStatus

func WaitForStoreStatus(href string)

WaitForStoreStatus will wait for the store available at href to respond with an active status.

type StoreMetadata

type StoreMetadata struct {
    Description    string
    ContentType    string
    Vendor         string
    DataSourceType string
    DataSourceID   string
    StoreType      string
    IsActuator     bool
    Unit           string
    Location       string
}

Generated by godoc2md

Documentation

Overview

A golang library for interfacing with Databox APIs.

Install using go get github.com/me-box/lib-go-databox

Examples can be found in the samples directory

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportLongpoll

func ExportLongpoll(destination string, payload string) (string, error)

func GetDsIdFromDsHref

func GetDsIdFromDsHref(href string) (string, error)

GetDsIdFromDsHref extracts the base data source ID from the href provied in the DATASOURCE_[name] environment variable.

func GetHttpsCredentials

func GetHttpsCredentials() string

GetHttpsCredentials Returns a string containing the HTTPS credentials to pass to https server when offering an https server. These are read form /run/secrets/DATABOX.pem and are generated by the container-manger at run time.

func GetStoreURLFromDsHref

func GetStoreURLFromDsHref(href string) (string, error)

GetStoreURLFromDsHref extracts the base store url from the href provied in the DATASOURCE_[name] environment variable.

func JsonUnmarshal

func JsonUnmarshal(s string) (map[string]interface{}, error)

JsonUnmarshal is a helper function to translate JSON stringified environment variable to go map[string]

func RegisterDatasource

func RegisterDatasource(href string, metadata StoreMetadata) (string, error)

RegisterDatasource is used by apps and drivers to register datasource in stores they own.

func StoreJSONGetlatest

func StoreJSONGetlatest(href string) (string, error)

func StoreJSONGetrange

func StoreJSONGetrange(href string, startTimestamp float64, endTimestamp float64) (string, error)

func StoreJSONGetsince

func StoreJSONGetsince(href string, startTimestamp float64) (string, error)

func StoreJSONWriteKV

func StoreJSONWriteKV(href string, data string) error

func StoreJSONWriteTS

func StoreJSONWriteTS(href string, data string) error

func StoreJSONreadKV

func StoreJSONreadKV(href string, key string) (string, error)

func StoreTsLast

func StoreTsLast(href string, n int) (string, error)

func StoreTsLastNrange

func StoreTsLastNrange(href string, n int, startTimestamp int, endTimestamp int) (string, error)

func StoreTsLastNsince

func StoreTsLastNsince(href string, n int, startTimestamp int) (string, error)

func StoreTsLatest

func StoreTsLatest(href string) (string, error)

func StoreTsRange

func StoreTsRange(href string, startTimestamp int, endTimestamp int) (string, error)

func StoreTsSince

func StoreTsSince(href string, startTimestamp int) (string, error)

func StoreTsWrite

func StoreTsWrite(href string, data string) (string, error)

func WSConnect

func WSConnect(href string) (chan []byte, error)

WSConnect connects to a target store's notification service

Returns a chan []byte that recives data from every route the connecting container is subscribed to. Data is a JSON string.

func WSSubscribe

func WSSubscribe(href string, storeType string) (string, error)

WSSubscribe Subscribes the caller to write notifications for a given route.

func WSUnsubscribe

func WSUnsubscribe(href string, storeType string) (string, error)

WSUnsubscribe Unsubscribes the caller to write notifications for a given route

func WaitForStoreStatus

func WaitForStoreStatus(href string)

WaitForStoreStatus will wait for the store available at href to respond with an active status.

Types

type StoreMetadata

type StoreMetadata struct {
	Description    string
	ContentType    string
	Vendor         string
	DataSourceType string
	DataSourceID   string
	StoreType      string
	IsActuator     bool
	Unit           string
	Location       string
}

Directories

Path Synopsis
samples

Jump to

Keyboard shortcuts

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