suapapa / seer-golang

The golang client library for seer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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",
                []time.Time{
                        time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC),
                        time.Date(2016, 1, 1, 1, 0, 0, 0, time.UTC),
                        time.Date(2016, 1, 1, 2, 0, 0, 0, time.UTC),
                },
                []float64{10, 9, 6},
        )
        if err != nil {
                log.Fatal(err)
        }

        // Generate and display forecast
        f, err = c.GetForecast("myStream", 10)
        if err != nil {
                log.Fatal(err)
        }

        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).

About

The golang client library for seer

License:Apache License 2.0


Languages

Language:Go 100.0%