reckonercdp

package module
v0.0.0-...-473a4d3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: MIT Imports: 14 Imported by: 0

README

Reckoner CDP API Client Library for Go

Go Client Library for Reckoner CDP services.

With this gem, you can:

  • stream your data to Reckoner CDP databases.
  • run query.

Installation

$ go get github.com/3-shake/reckoner-cdp-go

Usage

Initialization

Initialize a client to your reckoner cdp database:

import "github.com/3-shake/reckoner-cdp-go"

client := reckonercdp.NewClient(&reckonercdp.ClientSettings{
	AccessKeyID:         "yourAccessKeyID",
	SecretAccessKey:     "yourSecretAccessKey",
})

You can get your Access Key ID and Secret Access Key from Management page on WEB UI.

Stream Your Data to Reckoner CDP Database

Stream Struct:

type Item struct {
	Bar string
	Foo string
}

item := &Item{
		    Bar: "bar",
		    Foo: "foo",
	    }
if err := client.Insert("database_name", "table_name", item); err != nil {
	fmt.Println(err)
}

Stream Slice:

type Item struct {
	Bar string
	Foo string
}

items := []interface{}{
	&Item{
		Bar: "bar1",
		Foo: "foo1",
	},
	&Item{
		Bar: "bar2",
		Foo: "foo2",
	},
}
if err := client.BulkInsert("database_name", "table_name", items); err != nil {
	fmt.Println(err)
}

Before streaming your data to reckoenr CDP, you need to create database and table which you stream your data to on reckoner CDP. you can create database and table from WEB UI.

Query
res, err := client.Query("SELECT * FROM `team.database_name`.`table_name` LIMIT 1")
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(res.Records)

Documentation

Index

Constants

View Source
const (
	UnauthorizedError = "UnauthorizedError"
	ServerError       = "ServerError"
	ClientError       = "ClientError"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AccessKeyID         string
	SecretAccessKey     string
	Host                string
	StreamingHost       string
	HttpScheme          string
	StreamingHttpScheme string
	HttpClient          *http.Client
}

func NewClient

func NewClient(settings *ClientSettings) *Client

func (*Client) BulkInsert

func (client *Client) BulkInsert(databaseName, tableName string, src interface{}) error

func (*Client) Insert

func (client *Client) Insert(databaseName, tableName string, src interface{}) error

func (*Client) Query

func (client *Client) Query(query string) (*QueryResponse, error)

type ClientSettings

type ClientSettings struct {
	AccessKeyID         string
	SecretAccessKey     string
	Host                string
	StreamingHost       string
	HttpScheme          string
	StreamingHttpScheme string
	Transport           http.RoundTripper
}

type QueryRequest

type QueryRequest struct {
	Query string `json:"query"`
}

type QueryResponse

type QueryResponse struct {
	HistoryID int           `json:"history_id"`
	UUID      string        `json:"uuid"`
	HasNext   bool          `json:"has_next"`
	Records   []interface{} `json:"records"`
}

type ReckonerCdpError

type ReckonerCdpError struct {
	Type     string
	Message  string
	Response *http.Response
}

func (*ReckonerCdpError) Error

func (e *ReckonerCdpError) Error() string

Jump to

Keyboard shortcuts

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