Documentation ¶
Overview ¶
Riak (http://riak.basho.com/) database client for the go programming language.
Basic Usage: package main import (
"bytes" "riak"
)
func main() { r := riak.NewRiak("localhost:8098") // Key, Value example value = d = riak.NewDocument("test", "foo", []byte("Foo")) // JSON Marshal example td := new(TestDocument) td.Foo = 1 td.Bar = "Test Document" doc := riak.NewDocument("test", docId, make([]byte, 0)) doc.JSONObject = td err := r.Put(doc) td2 := new(TestDocument) doc.JSONObject = td2 err = r.Get(doc) err = r.Delete(bucketName, "test_key") }
Index ¶
- Constants
- type AsyncRiak
- type Bucket
- type BucketProperties
- type ClosingBuffer
- type Document
- func (d *Document) AddBinIndex(name, value string)
- func (d *Document) AddIntIndex(name string, value int64)
- func (d *Document) GetBinIndex(name string) string
- func (d *Document) GetIntIndex(name string) int64
- func (d *Document) RemoveBinIndex(name string)
- func (d *Document) RemoveIntIndex(name string)
- type Link
- type MarshalCallback
- type Riak
- func (r *Riak) BucketKeys(bucketName string) ([]string, error)
- func (self *Riak) BucketURL(bucketName, path string) string
- func (self *Riak) BuildRequest(method, url_ string) *http.Request
- func (self *Riak) BuildURL(bucketName, path string) string
- func (self *Riak) CreateBucket(bucketName string) (*Bucket, error)
- func (self *Riak) Delete(bucketName, key string) error
- func (self *Riak) DeleteRW(bucketName, key string, rw int) error
- func (self *Riak) Get(doc *Document) error
- func (r *Riak) GetBucket(bucketName string) (*Bucket, error)
- func (self *Riak) GetR(doc *Document, r int) error
- func (self *Riak) MakeRequest(req *http.Request) (*http.Response, error)
- func (self *Riak) ProcessRequest(req *http.Request) ([]byte, error)
- func (self *Riak) Put(doc *Document) error
- func (self *Riak) PutWDWReturn(doc *Document, w, dw int, returnObject bool) error
- func (self *Riak) RemoveBucket(bucketName string) error
- func (r *Riak) SearchBin(bucketName, index, value string) ([]string, error)
- func (r *Riak) SearchBinRange(bucketName, index string, start, end string) ([]string, error)
- func (r *Riak) SearchIndex(bucketName, index, value string) ([]string, error)
- func (r *Riak) SearchInt(bucketName, index string, value int) ([]string, error)
- func (r *Riak) SearchIntRange(bucketName, index string, start, end int) ([]string, error)
- type RiakError
- type RiakResponse
- type StringCallback
- type URLBuilder
Constants ¶
const (
INDEX_PREFIX = "X-Riak-Index-"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncRiak ¶
type AsyncRiak struct { Host string ResponseChannel chan *RiakResponse RequestIndex int ResponseMap map[int]chan *RiakResponse }
Host is the host to connect to
func NewAsyncRiak ¶
func (*AsyncRiak) Get ¶
The idea it we run a Get request in the background and we will then call Wait once we have to wait for the response.
func (*AsyncRiak) MarshalGet ¶
func (ar *AsyncRiak) MarshalGet(doc *Document, mc MarshalCallback)
Normal async callback when the response is ready
func (*AsyncRiak) NextRequestId ¶
func (*AsyncRiak) Put ¶
The idea it we run a BackgroundPut request in the background and we will then call Wait once we have to wait for the response.
func (*AsyncRiak) Wait ¶
func (ar *AsyncRiak) Wait(requestId int) *RiakResponse
Wait until the request returns this repsonse
type Bucket ¶
type Bucket struct { Props BucketProperties Keys []string }
Returned json mapping of a bucket response
type BucketProperties ¶
type BucketProperties struct { Name string N_val int Allow_mult bool Last_write_wins bool Precommit []string Postcommit []string Chash_keyfun map[string]string Linkfun map[string]string Old_vclock int Young_vclock int Big_vclock int Small_vclock int Keys []string `json:"keys"` }
Mapping riak json bucket properties
type ClosingBuffer ¶
From: http://github.com/c141charlie/riak.go/blob/master/riak.go
func (*ClosingBuffer) Close ¶
func (cb *ClosingBuffer) Close() (err error)
type Document ¶
type Document struct { Bucket string Key string Value []byte Links []*Link BinIndexes map[string]string IntIndexes map[string]int64 ContentType string JSONObject interface{} }
Define a basic document to reduce API calls
func NewDocument ¶
func (*Document) AddBinIndex ¶
func (*Document) AddIntIndex ¶
func (*Document) GetBinIndex ¶
func (*Document) GetIntIndex ¶
func (*Document) RemoveBinIndex ¶
func (*Document) RemoveIntIndex ¶
type MarshalCallback ¶
type MarshalCallback interface {
Callback(interface{}, error)
}
Callback interface where the code automatically marshals the JSON
type Riak ¶
Basic riak datastructure
func (*Riak) BucketKeys ¶
XXX: BROKEN place holder for fixing!!!
func (*Riak) BuildRequest ¶
Helper to wrap creating an http.Request
func (*Riak) CreateBucket ¶
Wrapper around get since get will create the bucket
func (*Riak) GetBucket ¶
Actually gets the bucket from the server and marshals the Bucket from the json that is returned
func (*Riak) ProcessRequest ¶
Does all the network IO ops Consider using panic / recover http://blog.golang.org/2010/08/defer-panic-and-recover.html
func (*Riak) PutWDWReturn ¶
Add/update an object to a bucket
func (*Riak) RemoveBucket ¶
Removes a bucket from the server.
func (*Riak) SearchBinRange ¶
Helper function to abstract away from details of syntax
func (*Riak) SearchIndex ¶
Secondary index searching
type RiakResponse ¶
Channel that responses will be returned on
type StringCallback ¶
Callback which just returns the JSON as a string useful
type URLBuilder ¶
Datastucture to make building url easier
func NewURLBuilder ¶
func NewURLBuilder(baseUrl string) *URLBuilder
Create and return an instance of URLBuilder