|
| 1 | +# Scout |
| 2 | + |
| 3 | +Scout is a daemon for listening to a set of SNS topics and enqueuing anything it |
| 4 | +finds into sidekiq jobs. It's meant to extract processing of SQS from the rails |
| 5 | +apps that increasingly need to do so. |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +``` |
| 10 | +NAME: |
| 11 | + scout - SQS Listener |
| 12 | +Poll SQS queues specified in a config and enqueue Sidekiq jobs with the queue items. |
| 13 | +It gracefully stops when sent SIGTERM. |
| 14 | +
|
| 15 | +USAGE: |
| 16 | + scout [global options] command [command options] [arguments...] |
| 17 | +
|
| 18 | +VERSION: |
| 19 | + 1.3 |
| 20 | +
|
| 21 | +COMMANDS: |
| 22 | + help, h Shows a list of commands or help for one command |
| 23 | +
|
| 24 | +GLOBAL OPTIONS: |
| 25 | + --config FILE, -c FILE Load config from FILE, required |
| 26 | + --freq N, -f N Poll SQS every N milliseconds (default: 100) |
| 27 | + --log-level value, -l value Sets log level. Accepts one of: debug, info, warn, error |
| 28 | + --json, -j Log in json format |
| 29 | + --help, -h show help |
| 30 | + --version, -v print the version |
| 31 | +``` |
| 32 | + |
| 33 | +## Configuration |
| 34 | + |
| 35 | +The configuration requires 3 distinct sets of information. It needs information |
| 36 | +about how to connect to redis to enqueue jobs, credentials to talk to AWS and |
| 37 | +read SQS, and a mapping from SNS topics to sidekiq worker classes in the |
| 38 | +application. The structure looks like this. |
| 39 | + |
| 40 | +```yaml |
| 41 | +redis: |
| 42 | + host: "localhost:9000" |
| 43 | + namespace: "test" |
| 44 | + queue: "background" |
| 45 | +aws: |
| 46 | + access_key: "super" |
| 47 | + secret_key: "secret" |
| 48 | + region: "us-best" |
| 49 | +queue: |
| 50 | + name: "myapp_queue" |
| 51 | + topics: |
| 52 | + foo-topic: "FooWorker" |
| 53 | + bar-topic: "BazWorker" |
| 54 | +``` |
| 55 | +
|
| 56 | +None of this information is actually an example of anything other than the |
| 57 | +strucure of the file, so if you copy paste it you'll probably be disappointed. |
| 58 | +
|
| 59 | +## Versioning |
| 60 | +
|
| 61 | +Scout uses tagged commits to be compatible with gopkg.in. To pin to version 1, |
| 62 | +you can import it as `gopkg.in/enova/scout.v1`. The "first" version is version |
| 63 | +1.3, since all other versions were before this project was made open source. |
| 64 | +Version 2 is possible at some point and may contain breaking changes, so pinning |
| 65 | +to version 1 is recommended unless you want to work with the bleeding edge. |
| 66 | + |
| 67 | +## Development |
| 68 | + |
| 69 | +To get set up make sure to run `go get -t -u ./...` to get all the dependencies. |
| 70 | + |
| 71 | +### Testing |
| 72 | + |
| 73 | +The normal test suite can be run as expected with go test. There are also two |
| 74 | +tagged files with expensive integration tests that require external services. |
| 75 | +They can be run as follows |
| 76 | + |
| 77 | +``` |
| 78 | + [FG-386] scout > go test -run=TestSQS -v -tags=sqsint |
| 79 | +=== RUN TestSQS_Init |
| 80 | +--- PASS: TestSQS_Init (3.84s) |
| 81 | +=== RUN TestSQS_FetchDelete |
| 82 | +--- PASS: TestSQS_FetchDelete (3.58s) |
| 83 | + PASS |
| 84 | +ok github.com/enova/scout 7.422s |
| 85 | + [FG-386] scout > go test -run=TestWorker -v -tags=redisint |
| 86 | +=== RUN TestWorker_Init |
| 87 | +--- PASS: TestWorker_Init (0.00s) |
| 88 | +=== RUN TestWorker_Push |
| 89 | +--- PASS: TestWorker_Push (0.00s) |
| 90 | +PASS |
| 91 | +ok github.com/enova/scout 0.013s |
| 92 | +``` |
| 93 | +
|
| 94 | +The tests themselves (found in `sqs_client_test.go` and `worker_client_test.go`) |
| 95 | +explain what is required to run them. In particular, the SQS integration tests |
| 96 | +require that you provide AWS credentials to run them. |
0 commit comments