hod

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2018 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Overview

This package provide a couple simple HodDB clients HTTP Client:

package main

import (
	"fmt"
	"github.com/gtfierro/hod/clients/go"
)

func main() {
	c := hod.NewHTTPClient("http://ciee.cal-sdb.org/api/query")

	query := `SELECT ?x ?r WHERE {
    ?x rdf:type/rdfs:subClassOf* brick:Temperature_Sensor .
    ?x bf:isLocatedIn ?r .
  };`

	res, err := c.DoQuery(query, nil)
	fmt.Println(err)
	fmt.Printf("%+v", res)

}

BOSSWAVE client

   package main

   import (
   	"fmt"
   	"github.com/gtfierro/hod/clients/go"
	    bw2 "gopkg.in/immesys/bw2bind.v5"
   )

   func main() {

	    client := bw2.ConnectOrExit("")
	    client.OverrideAutoChainTo(true)
	    client.SetEntityFromEnvironOrExit()
	    bc, err := hod.NewBW2Client(client, "ciee/hod")
	    if err != nil {
         panic(err)
     }

   	query := `SELECT ?x ?r WHERE {
       ?x rdf:type/rdfs:subClassOf* brick:Temperature_Sensor .
       ?x bf:isLocatedIn ?r .
     };`

	    res, err := bc.DoQuery(query, nil)
	    fmt.Println(err)
	    fmt.Printf("%+v", res)

   }

Index

Constants

View Source
const RESULT_PONUM = `2.0.10.2/32`

Variables

View Source
var ErrNoResponse = errors.New("No response from archiver")
View Source
var QUERY_PONUM = bw2.FromDotForm(`2.0.10.1`)

Functions

This section is empty.

Types

type BW2Result

type BW2Result struct {
	Nonce string `msgpack:"Nonce"`
	Error error  `msgpack:-`

	Rows    []ResultMap   `msgpack:"Rows"`
	Count   int           `msgpack:"Count"`
	Elapsed time.Duration `msgpack:-`
	// contains filtered or unexported fields
}

type HodClientBW2

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

func NewBW2Client

func NewBW2Client(client *bw2.BW2Client, uri string) (*HodClientBW2, error)

func (*HodClientBW2) DoQuery

func (bc *HodClientBW2) DoQuery(query string, opts *Options) (res BW2Result, err error)

type HodClientHTTP

type HodClientHTTP struct {
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient(url string) *HodClientHTTP

func (*HodClientHTTP) DoQuery

func (c *HodClientHTTP) DoQuery(query string, options *Options) (res Result, err error)

type Options

type Options struct {
	Timeout time.Duration
}

func DefaultOptions

func DefaultOptions() *Options

type Result

type Result struct {
	Rows    []ResultMap
	Count   int
	Elapsed time.Duration
}

type ResultMap

type ResultMap map[string]turtle.URI

Jump to

Keyboard shortcuts

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