https://github.com/mtchavez/roxy
Riak Proxy in Go
https://github.com/mtchavez/roxy
go proxy riak riak-proxy
Last synced: 2 months ago
JSON representation
Riak Proxy in Go
- Host: GitHub
- URL: https://github.com/mtchavez/roxy
- Owner: mtchavez
- Created: 2013-05-14T22:16:25.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-30T01:06:31.000Z (almost 12 years ago)
- Last Synced: 2025-02-04T15:32:31.929Z (4 months ago)
- Topics: go, proxy, riak, riak-proxy
- Language: Go
- Homepage:
- Size: 310 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Roxy
#### A Riak Proxy
A proxy between your client and Riak. Harnesses Go routines and a pool of connections to
Riak to handle your queries to Riak.## Install
```
go get -u github.com/mtchavez/roxy
```## Usage
### Configuration
Roxy uses a [toml](https://github.com/mojombo/toml) config file for settings. Here is an example config:```
title = "Roxy configuration TOML"[roxy]
ip = "127.0.0.1"
port = 8088
p95 = 0.01
bg_procs = 10[riak]
ip = "127.0.0.1"
port = 8087
pool_size = 5[statsite]
enabled = false
ip = "0.0.0.0"
port = 8125
```#### [roxy]
* ```ip``` - IP you want Roxy to listen on
* ```port``` - Port you want for Roxy to listen on
* ```p95``` - Float number in milliseconds. Used to time out reads to Riak after
p95 time. Roxy will re-issue the read again and respond to the client.
* ```bg_procs``` - Threshold of total number of background PutReq that can run at one time. Otherwise runs normally.#### [riak]
* ```ip``` - IP to your Riak
* ```port``` - Protocol Buffer Port for Riak
* ```pool_size``` - Number of connections for Roxy to make to Riak for a connection pool#### [statsite]
* ```enabled``` - true to enable tracing stats via statsite or false to turn off
* ```ip``` - IP of statsite
* ```port``` - Port of statsite### Starting a server
Starting Roxy just takes a path to a toml config
```go
package mainimport "github.com/mtchavez/roxy"
func main() {
roxy.Setup("./path/to/my-config.toml")
roxy.RunProxy()
}
```This will setup a ```net.Listener``` on the supplied ip and port from your config for
Roxy to listen for new connections on.### Sending Requests
If you point your client to the Roxy ip and port you can now make regular Riak
requests as normal. A python example using the default Roxy ip and port would be:```python
from riak import RiakClient, RiakPbcTransport, RiakObject
import simplejsonhost = '127.0.0.1'
port = 8088
client = RiakClient(host=host, port=port, transport_class=RiakPbcTransport, transport_options={'timeout': 10, 'max_attempts': 3})bucket = client.bucket('sample_bucket')
for i in xrange(1, 10):
obj = RiakObject(client, bucket, 'user_%d' % i)
obj._encode_data = False
obj.set_content_type("application/json")
doc = {'name': 'John Smith', 'age': 28 + i, 'company': 'Mr. Startup!'}
obj.set_data(simplejson.dumps(doc))
obj.store(w=1)
```## Documentation
Docs can be found on [godoc](http://godoc.org/github.com/mtchavez/roxy/roxy) or
run ```go doc github.com/mtchavez/roxy``` locally## Test
You can run the tests using the Makefile with ```make test``` or
using ```go test``` in the roxy directory. This currently expects Riak to be running
and available on default pb port ```8087```## TODO
* p95 backup requests
- Currently turned off
- Need to figure out intermittent hanging when this is turned on## License
Written by ChavezReleased under the MIT License: http://www.opensource.org/licenses/mit-license.php