Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
readme improvements
Browse files Browse the repository at this point in the history
also fixes default behaviour when not specifying directory or file on
publishing
  • Loading branch information
stiangrindvoll committed Mar 15, 2018
1 parent 4f5faf3 commit 1a3b80a
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 21 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# exclude binary
rio
rabbitio

# exclude dirs
# exclude build and example files/dirs
data/
build/
vendor/
message*
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Meltwater

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION := $(shell git describe --tags)
BUILD_DIR?=$(shell pwd)/build
NAME=rio
NAME=rabbitio
DIRECTORIES=./ ./cmd ./rmq ./file

all: tools deps test
Expand Down
94 changes: 80 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,94 @@
# Rabbit IO - Work in Progress
This is a tool to support backup and restoring of RabbitMQ messages, currently work in progress and might not be functional
# Rabbit IO
This is a tool to support backup and restoring of RabbitMQ messages

## Requirements
## Installing

You will need following to build `rabbitio` locally:
#### Download binary
Pick your archtype from [Releases](https://github.com/meltwater/rabbitio/releases) and download, in addition you'll need to set the binary to be executable.

- [Golang](https://golang.org/dl/)
- [dep](https://github.com/golang/dep)
Example with `linux-amd64` and version `v0.5.1`:
```
wget https://github.com/meltwater/rabbitio/releases/download/v0.5.1/rio-v0.5.1-linux-amd64 -O rabbitio
chmod +755 rabbitio
```

## Getting started
#### Using `go get`
```
go get -u github.com/meltwater/rabbitio
```

If you plan to work on `rabbitio` you will need to:
## How to use RabbitIO

1. Create directories
After installing rabbitio, you can quickly test out `rabbitio` by using [docker-compose](https://docs.docker.com/compose/install/)

Included is a docker-compose file to set up local rabbitmq.
```
mkdir -p $GOPATH/src/github.com/meltwater
cd $GOPATH/src/github.com/meltwater
docker-compose up -d
```
Go to your now running [local rabbit](http://localhost:15672) and create example exchange: `rabbitio-exchange` and queue `rabbitio-queue`,
then bind the queue to the exchange.

#### Publish your first message
```
echo "My first message" > message && tar cfz message.tgz message # creates message.tgz
rabbitio in -e rabbitio -q rabbitio -f message.tgz
```
This will publish your first message into `rabbitio-exchange` and you'll see your message in the queue `rabbitio-queue`

#### Consume your first message
```
$ mkdir data
$ rabbitio out -e rabbitio-exchange -q rabbitio-queue -d data/
2018/03/15 15:37:35 RabbitMQ connected: amqp://guest:guest@localhost:5672/
2018/03/15 15:37:35 Bind to Exchange: "rabbitio-exchange" and Queue: "rabbitio-queue", Messaging waiting: 1
^C Interruption, saving last memory bits..
2018/03/15 15:37:45 Wrote 203 bytes to data/1_messages_1.tgz
2018/03/15 15:37:45 tarball writer closing
```
We interrupt when the queue is empty by directly using a combination of `CTRL + C` once. This will save the last bits and ack the message.


## Detailed Usage
```
$ rabbitio
Rabbit IO will help backup and restore your messages in RabbitMQ
Usage:
rabbitio [command]
Available Commands:
help Help about any command
in Publishes documents from tarballs into RabbitMQ exchange
out Consumes data out from RabbitMQ and stores to tarballs
version Prints the version of Rabbit IO
Flags:
-e, --exchange string Exchange to connect to
-h, --help help for rabbitio
-p, --prefetch int Prefetch for batches (default 100)
-q, --queue string Queue to connect to
-r, --routingkey string Routing Key, if specified will override tarball routing key configuration (default "#")
-t, --tag string AMQP Client Tag (default "Rabbit IO Connector ")
-u, --uri string AMQP URI, uri to for instance RabbitMQ (default "amqp://guest:guest@localhost:5672/")
Use "rabbitio [command] --help" for more information about a command.
2. Clone `rabbitio`:
```


## Contributing

If you plan to work on `rabbitio` you will need [Golang](https://golang.org/dl/). PRs are welcome as well as implementation discussions.

**Clone `rabbitio`**
```
mkdir -p $GOPATH/src/github.com/meltwater
cd $GOPATH/src/github.com/meltwater
git clone [email protected]:meltwater/rabbitio.git
```

3. Make:
#### Building
```
cd rabbitio
make && make build
Expand All @@ -35,6 +100,7 @@ For any bug reports or change requests, please create a Github issue or submit a

Also feel free to drop a line to the maintainers:

- Joel ([@vorce](https://github.com/vorce), [[email protected]](mailto:[email protected]))
- Stian ([@stiangrindvoll](https://github.com/stiangrindvoll), [[email protected]](mailto:[email protected]))
- Joel ([@vorce](https://github.com/vorce))
- Stian ([@stiangrindvoll](https://github.com/stiangrindvoll))
- Team Blacksmiths ([[email protected]](mailto:[email protected]))
2
9 changes: 7 additions & 2 deletions cmd/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package cmd

import (
"sync"
"errors"

"github.com/meltwater/rabbitio/file"
"github.com/meltwater/rabbitio/rmq"
Expand All @@ -31,8 +32,11 @@ var inCmd = &cobra.Command{
Use: "in",
Short: "Publishes documents from tarballs into RabbitMQ exchange",
Long: `Specify a directory or file and tarballs will be published.`,
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {

if fileInput == "" {
return errors.New("please specify a tarball or directory with tarballs using the -f flag")
}
channel := make(chan rmq.Message, prefetch)
var wg sync.WaitGroup

Expand All @@ -45,10 +49,11 @@ var inCmd = &cobra.Command{
go rabbit.Publish(channel, override)
path.Send(channel)
rabbit.Close()
return nil
},
}

func init() {
RootCmd.AddCommand(inCmd)
inCmd.Flags().StringVarP(&fileInput, "file", "f", ".", "File is specified as either file or directory to restore into RabbitMQ")
inCmd.Flags().StringVarP(&fileInput, "file", "f", "", "File is specified as either file or directory to restore into RabbitMQ")
}
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "rio",
Use: "rabbitio",
Short: "Rabbit IO will help backup and restore your messages in RabbitMQ",
// Uncomment the following line if your bare application
// has an action associated with it:
Expand Down

0 comments on commit 1a3b80a

Please sign in to comment.