This repository has been archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19b4d6c
commit f036189
Showing
3 changed files
with
75 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,50 @@ | ||
# pusred [![Build Status](https://travis-ci.org/lukasmartinelli/pusred.svg)](https://travis-ci.org/lukasmartinelli/pusred) | ||
# redis-pipe [![Build Status](https://travis-ci.org/lukasmartinelli/pusred.svg)](https://travis-ci.org/lukasmartinelli/pusred) | ||
|
||
A simple Redis client that connects stdin and stdout with `LPUSH` and `LPOP`. | ||
**redis-pipe** allows you to treat [Redis Lists](http://redis.io/topics/data-types#lists) | ||
as if they were [Unix pipes](https://en.wikipedia.org/wiki/Pipeline_%28Unix%29). | ||
It basically connects `stdin` and `stdout` with `LPUSH` and `LPOP`. | ||
|
||
## Examples | ||
## Build | ||
|
||
Add value to list | ||
Install dependencies | ||
|
||
``` | ||
echo "Hello" | ./pusred lpush greetings | ||
go get github.com/andrew-d/go-termutil | ||
go get github.com/docopt/docopt-go | ||
go get menteslibres.net/gosexy/redis | ||
``` | ||
|
||
Pipe syslog to Redis | ||
Build binary | ||
|
||
``` | ||
tail -f /var/log/syslog | ./pusred lpush logs | ||
go build redis-pipe.go | ||
``` | ||
|
||
Read all values from list | ||
## How it works | ||
|
||
### Writing from stdin to Redis List | ||
|
||
**redis-pipe** takes your values and generates `RPUSH` commands | ||
(generating a valid [Redis protocol](http://redis.io/topics/protocol)) | ||
that are then piped into `redis-cli --pipe` ([Redis Mass Insertion](http://redis.io/topics/mass-insert)) | ||
|
||
### Reading from Redis List to stdout | ||
|
||
`LPOP` all the values from the list and write them to `stdout`. | ||
|
||
## Examples | ||
|
||
### Centralized Logging | ||
|
||
In this sample we pipe the syslog to a Redis List called `log`. | ||
|
||
``` | ||
./pusred lpop greetings | ||
tail -f /var/log/syslog | ./redis-pipe logs | ||
``` | ||
|
||
## Usage | ||
You can now easily collect all the syslogs of your machines | ||
on a single server. | ||
|
||
``` | ||
Usage: | ||
pusred lpop <list> [--host=<host>] [--port=<port>] | ||
pusred lpush <list> [--host=<host>] [--port=<port>] | ||
pusred (-h | --help) | ||
Options: | ||
-h --help Show this screen | ||
--host=<host> Redis host [default: localhost] | ||
--port=<port> Redis port [default: 6379] | ||
./redis-pipe logs > logs.txt | ||
``` | ||
|
||
You can also set the environment variables `RQ_HOST` and `RQ_PORT` to | ||
define the Redis connection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters