seer-golang

module
v0.0.0-...-87dfca5 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: Apache-2.0

README

Seer Golang Client

Build Status Coverage Status Go Report Card

The golang client for the seer forecasting server.

Installation

To install the seer client library, use go get

go get github.com/cshenton/seer-golang/seer

Usage

Since this is a client library, you'll need a server to communicate with. To get up and running just:

docker run -d -p 8080:8080 cshenton/seer

Check out the project repo over here

Then, to interact over localhost

package main

import (
        "log"
        "time"

        "github.com/cshenton/seer-golang/client"
)

func main() {
        // Create a client
        c, err := client.New("localhost:8080")
        if err != nil {
                log.Fatal(err)
        }

        // Create a stream
        _, err = c.CreateStream("myStream", 3600)
        if err != nil {
                log.Fatal(err)
        }

        // Add in data
        _, err = c.UpdateStream(
                "myStream",
                []float64{10, 9, 6},
                []time.Time{
                        time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC),
                        time.Date(2016, 1, 2, 0, 0, 0, 0, time.UTC),
                        time.Date(2016, 1, 3, 0, 0, 0, 0, time.UTC),
                },
        )
        if err != nil {
                log.Fatal(err)
        }

        // Generate and display forecast
        f, err = c.GetForecast("myStream", 10)
        fmt.Println(f)
}

(For Contributors) Generating gRPC Client stubs

protoc -I ../seer/seer --go_out=plugins=grpc:seer ../seer/seer/seer.proto

We then add //+build !test to the top of the file to exclude it from coverage statistics (since it has a tonne of redundant code, like the Get* methods and the server interfaces, which are not used, and therefore don't require testing).

Directories

Path Synopsis
Package seer is a generated protocol buffer package.
Package seer is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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