Skip to content

Commit

Permalink
Misc wordsmithing and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bruceadowns committed May 8, 2018
1 parent 7b143ee commit bcb60e1
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
37 changes: 24 additions & 13 deletions README.md
Expand Up @@ -57,15 +57,15 @@ First, you will need to define some tasks. Look at sample tasks in `example/task
Second, you will need to launch a worker process:

```sh
go run example/machinery.go worker
go run example/machinery.go -c example/config.yml worker
```

![Example worker][1]

Finally, once you have a worker running and waiting for tasks to consume, send some tasks:

```sh
go run example/machinery.go send
go run example/machinery.go -c example/config.yml send
```

You will be able to see the tasks being processed asynchronously by the worker:
Expand Down Expand Up @@ -117,7 +117,7 @@ redis+socket://[password@]/path/to/file.sock[:/db_num]

For example:

1. `redis://127.0.0.1:6379`, or with password `redis://password@127.0.0.1:6379`
1. `redis://localhost:6379`, or with password `redis://password@localhost:6379`
2. `redis+socket://password@/path/to/file.sock:/0`

##### AWS SQS
Expand Down Expand Up @@ -177,7 +177,7 @@ redis+socket://[password@]/path/to/file.sock[:/db_num]

For example:

1. `redis://127.0.0.1:6379`, or with password `redis://password@127.0.0.1:6379`
1. `redis://localhost:6379`, or with password `redis://password@localhost:6379`
2. `redis+socket://password@/path/to/file.sock:/0`

##### Memcache
Expand All @@ -190,7 +190,7 @@ memcache://host1[:port1][,host2[:port2],...[,hostN[:portN]]]

For example:

1. `memcache://127.0.0.1:11211` for a single instance, or
1. `memcache://localhost:11211` for a single instance, or
2. `memcache://10.0.0.1:11211,10.0.0.2:11211` for a cluster

##### AMQP
Expand All @@ -217,18 +217,18 @@ mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][

For example:

1. `mongodb://127.0.0.1:27017/taskresults`
1. `mongodb://localhost:27017/taskresults`

See [MongoDB docs](https://docs.mongodb.org/manual/reference/connection-string/) for more information.


#### ResultsExpireIn

How long to store task results for in seconds. Defaults to `3600` (1 hour).
How long to store task results for in seconds. Defaults to `3600000` (1 hour).

#### AMQP

RabbitMQ related configuration. Not neccessarry if you are using other broker/backend.
RabbitMQ related configuration. Not necessary if you are using other broker/backend.

* `Exchange`: exchange name, e.g. `machinery_exchange`
* `ExchangeType`: exchange type, e.g. `direct`
Expand All @@ -237,7 +237,7 @@ RabbitMQ related configuration. Not neccessarry if you are using other broker/ba
* `PrefetchCount`: How many tasks to prefetch (set to `1` if you have long running tasks)

#### Dynamodb
Dynamodb related configuration. Not neccessarry if you are using other backend.
Dynamodb related configuration. Not necessary if you are using other backend.
* `task_states_table`: Custom table name for saving task states. Default one is `task_states`, and make sure to create this table in your AWS admin first, using `TaskUUID` as table's primary key.
* `group_metas_table`: Custom table name for saving group metas. Default one is `group_metas`, and make sure to create this table in your AWS admin first, using `GroupUUID` as table's primary key.
For example:
Expand Down Expand Up @@ -891,7 +891,7 @@ for _, result := range results {
#### Requirements

* Go
* RabbitMQ
* RabbitMQ (optional)
* Redis (optional)
* Memcached (optional)
* MongoDB (optional)
Expand All @@ -906,6 +906,17 @@ brew install memcached
brew install mongodb
```

Or optionally use the corresponding [Docker](http://docker.io/) containers:

```
docker run -d -p 5672:5672 rabbitmq
docker run -d -p 6379:6379 redis
docker run -d -p 11211:11211 memcached
docker run -d -p 27017:27017 mongo
docker run -d -p 6831:6831/udp -p 16686:16686 jaegertracing/all-in-one:latest
```


#### Dependencies

According to [Go 1.5 Vendor experiment](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo), all dependencies are stored in the vendor directory. This approach is called `vendoring` and is the best practice for Go projects to lock versions of dependencies in order to achieve reproducible builds.
Expand Down Expand Up @@ -936,9 +947,9 @@ In order to enable integration tests, you will need to install all required serv

```sh
export AMQP_URL=amqp://guest:guest@localhost:5672/
export REDIS_URL=127.0.0.1:6379
export MEMCACHE_URL=127.0.0.1:11211
export MONGODB_URL=127.0.0.1:27017
export REDIS_URL=localhost:6379
export MEMCACHE_URL=localhost:11211
export MONGODB_URL=localhost:27017
```

To run integration tests against an SQS instance, you will need to create a "test_queue" in SQS and export these environment variables:
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/suite_test.go
Expand Up @@ -286,14 +286,14 @@ func testPanic(server *machinery.Server, t *testing.T) {

func testDelay(server *machinery.Server, t *testing.T) {
now := time.Now().UTC()
eta := now.Add(100 * (time.Millisecond))
eta := now.Add(100 * time.Millisecond)
task := newDelayTask(eta)
asyncResult, err := server.SendTask(task)
if err != nil {
t.Error(err)
}

results, err := asyncResult.Get(time.Duration(time.Millisecond * 5))
results, err := asyncResult.Get(time.Duration(5 * time.Millisecond))
if err != nil {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion v1/backends/dynamodb_test.go
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestNewDynamoDBBackend(t *testing.T) {
// should call t.Skip if not connected to internet
backend := backends.NewDynamoDBBackend(backends.TestCnf)
assert.IsType(t, &backends.DynamoDBBackend{}, backend)
}
Expand All @@ -28,7 +29,6 @@ func TestInitGroup(t *testing.T) {
}

func TestDynamoDBGroupCompleted(t *testing.T) {

task1 := map[string]*dynamodb.AttributeValue{
"Error": {
NULL: aws.Bool(true),
Expand Down
2 changes: 1 addition & 1 deletion v1/backends/redis.go
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/gomodule/redigo/redis"
)

// RedisBackend represents a Memcache result backend
// RedisBackend represents a Redis result backend
type RedisBackend struct {
Backend
host string
Expand Down
2 changes: 1 addition & 1 deletion v1/config/config.go
Expand Up @@ -68,7 +68,7 @@ type SQSConfig struct {
Client *sqs.SQS
WaitTimeSeconds int `yaml:"receive_wait_time_seconds" envconfig:"SQS_WAIT_TIME_SECONDS"`
// https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html
// visiblity timeout should default to nil to use the overall visibility timeout for the queue
// visibility timeout should default to nil to use the overall visibility timeout for the queue
VisibilityTimeout *int `yaml:"receive_visibility_timeout" envconfig:"SQS_VISIBILITY_TIMEOUT"`
}

Expand Down
1 change: 0 additions & 1 deletion v1/factories.go
Expand Up @@ -24,7 +24,6 @@ func BrokerFactory(cnf *config.Config) (brokers.Interface, error) {
}

if strings.HasPrefix(cnf.Broker, "redis://") {

parts := strings.Split(cnf.Broker, "redis://")
if len(parts) != 2 {
return nil, fmt.Errorf(
Expand Down
3 changes: 1 addition & 2 deletions v1/server.go
Expand Up @@ -46,8 +46,7 @@ func NewServer(cnf *config.Config) (*Server, error) {
// init for eager-mode
eager, ok := broker.(brokers.EagerMode)
if ok {
// we don't have to call worker.Lauch
// in eager mode
// we don't have to call worker.Launch in eager mode
eager.AssignWorker(srv.NewWorker("eager", 0))
}

Expand Down
2 changes: 1 addition & 1 deletion v1/worker.go
Expand Up @@ -40,7 +40,7 @@ func (worker *Worker) LaunchAsync(errorsChan chan<- error) {
cnf := worker.server.GetConfig()
broker := worker.server.GetBroker()

// Log some useful information about woorker configuration
// Log some useful information about worker configuration
log.INFO.Printf("Launching a worker with the following settings:")
log.INFO.Printf("- Broker: %s", cnf.Broker)
log.INFO.Printf("- DefaultQueue: %s", cnf.DefaultQueue)
Expand Down

0 comments on commit bcb60e1

Please sign in to comment.