Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alindeman/go-kestrel

Interact with kestrel using golang
https://github.com/alindeman/go-kestrel

Last synced: about 1 month ago
JSON representation

Interact with kestrel using golang

Awesome Lists containing this project

README

        

# go.kestrel

A simple wrapper over kestrel's thrift API. Includes support for multiple
servers and retries.

It's still early days, so dig into client.go for all the details of what
you can do.

## Basic Usage

```go
import (
"github.com/alindeman/go.kestrel"
"time"
)

// assuming the thrift port is 2229
client := kestrel.NewClient("localhost", 2229)

item := []byte("Hello World")
nitems, err := client.Put("queue1", [][]byte{item})

items, err := client.Get("queue1", 1, 0, 1*time.Minute)
```

## Cluster Usage

```go
import (
"github.com/alindeman/go.kestrel"
"time"
)

// assuming the thrift port is 2229
clients := []*kestrel.Client{
kestrel.NewClient("host1", 2229),
kestrel.NewClient("host2", 2229),
kestrel.NewClient("host3", 2229),
}
cluster := kestrel.NewClusterReader(clients)

ch := make(chan *kestrel.QueueItem, 10)
go cluster.ReadIntoChannel("queue1", ch)

item1 := <-ch
item2 := <-ch

cluster.Close()
```