go-appbase: github.com/appbaseio/go-appbase Index | Examples | Files | Directories

package appbase

import "github.com/appbaseio/go-appbase"

go-appbase is a data streams library for Go,

compatible with Elasticsearch.

To use the data streaming facilities of the library, create an account at https://appbase.io/.

Checkout the examples to learn more.

Code:

// Importing the library as 'github.com/appbase/go-appbase'.
// Then instantiate the client with appbase.NewClient(url, username, password, appname).
client, _ = NewClient("https://scalr.api.appbase.io", "mj8IvN7DY", "c01fd88a-250e-4321-85bf-51574d5141dc", "go-test")

err := client.Ping()
if err != nil {
    log.Fatalln(err)
}

fmt.Println("Client created")

Output:

Client created

Index

Examples

Package Files

appbase.go doc.go

func NewWebhook Uses

func NewWebhook() *actions.Webhook

type Client Uses

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

func NewClient Uses

func NewClient(URL string, username string, password string, appname string) (*Client, error)

func (*Client) Delete Uses

func (c *Client) Delete() *actions.DeleteService

Delete returns a DeleteService which is used to delete a document

func (*Client) Get Uses

func (c *Client) Get() *actions.GetService

Get returns a GetService which is used to retrieve a document

func (*Client) GetStream Uses

func (c *Client) GetStream() *actions.GetStreamService

GetStream is used to start a stream of updates corresponding to a document

func (*Client) Index Uses

func (c *Client) Index() *actions.IndexService

Index returns an IndexService which is used to index a document

Code:

const testtype string = "tweet"
const tweet string = `{"user":"jack","message":"just setting up my twttr"}`
res, err := client.Index().Type(testtype).Id("3").Body(tweet).Do()
if err != nil {
    log.Fatalln(err)
    return
}

fmt.Println(res.Id)

Output:

3

func (*Client) Ping Uses

func (c *Client) Ping() error

func (*Client) Search Uses

func (c *Client) Search() *actions.SearchService

Search provides access to Elasticsearch's search functionality

func (*Client) SearchStream Uses

func (c *Client) SearchStream() *actions.SearchStreamService

SearchStream is used to get updates corresponding to a query

Code:

const testtype string = "tweet"
const matchAllQuery string = `{"query":{"match_all":{}}}`
const anotherTweet string = `{"user":"ev","message":"twttr's way better than odeo"}`
searchStreamResponse, err := client.SearchStream().Type(testtype).Body(matchAllQuery).Do()
if err != nil {
    log.Fatalln(err)
    return
}

_, err = client.Index().Type(testtype).Id("3").Body(anotherTweet).Do()
if err != nil {
    log.Fatalln(err)
    return
}

docResponse, err := searchStreamResponse.Next()
if err != nil {
    log.Fatalln(err)
    return
}

fmt.Println(docResponse.Id)

Output:

3

func (*Client) SearchStreamToURL Uses

func (c *Client) SearchStreamToURL() *actions.SearchStreamToURLService

SearchStream is used to send updates corresponding to a query to an URL

Code:

// Similar to NewClient, we will instiate a webhook instance with appbase.NewWebhook()
webhook := NewWebhook()
// Webhook instancess need to have a URL, method and body (which can be string or a JSON object)
webhook.URL = "https://www.mockbin.org/bin/cd6461ab-468f-42f5-865f-4eed22daae95"
webhook.Method = "POST"
webhook.Body = "hellowebhooks"
const testtype string = "tweet"
const matchAllQuery string = `{"query":{"match_all":{}}}`

searchStreamToURLResponse, err := client.SearchStreamToURL().Type(testtype).Query(matchAllQuery).AddWebhook(webhook).Do()
if err != nil {
    log.Fatalln(err)
    return
}

stopSearchStream, err := searchStreamToURLResponse.Stop()
if err != nil {
    log.Fatalln(err)
    return
}

fmt.Println(searchStreamToURLResponse.Id == stopSearchStream.Id)

Output:

true

func (*Client) Update Uses

func (c *Client) Update() *actions.UpdateService

Update returns an UpdateService which is used to update a document

Code:

const testtype string = "tweet"
const altTweet string = `{"user":"jack","message":"or just forget it, kate's yoga classes are more fun"}`
res, err := client.Update().Type(testtype).Id("3").Body(fmt.Sprintf(`{ "doc": %s }`, altTweet)).Do()
if err != nil {
    log.Fatalln(err)
    return
}

fmt.Println(res.Id)

Output:

3

Directories

PathSynopsis
actions
connection
error
Godeps/_workspace/src/github.com/spaolacci/murmur3Native (and fast) implementation of Austin Appleby's MurmurHash3.
Godeps/_workspace/src/gopkg.in/olivere/elastic.v3Package elastic provides an interface to the Elasticsearch server (http://www.elasticsearch.org/).
Godeps/_workspace/src/gopkg.in/olivere/elastic.v3/cluster-test
Godeps/_workspace/src/gopkg.in/olivere/elastic.v3/uritemplatesPackage uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).

Package appbase imports 2 packages (graph). Updated 2016-07-15. Refresh now. Tools for package owners.