Skip to content

Instantly share code, notes, and snippets.

@tmlbl
Created March 19, 2015 20:34
Show Gist options
  • Save tmlbl/d3457ebc52063b52b47a to your computer and use it in GitHub Desktop.
Save tmlbl/d3457ebc52063b52b47a to your computer and use it in GitHub Desktop.
Trying to use cockroachdb
package main
import (
"fmt"
"net/http"
"time"
"github.com/cockroachdb/cockroach/client"
"github.com/cockroachdb/cockroach/proto"
)
type Clock struct{}
func (c *Clock) Now() int64 {
return int64(time.Now().Nanosecond())
}
func main() {
tr := &http.Transport{
// TLSClientConfig: &tls.Config{RootCAs: pool},
DisableCompression: true,
}
kv := client.NewKV(client.NewHTTPSender("localhost:8080", tr), &Clock{})
getResp := &proto.GetResponse{}
err := kv.Call(proto.Get, proto.GetArgs(proto.Key("somekey")), getResp)
if err != nil {
fmt.Println(err)
}
fmt.Println("Get response:", getResp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment