Skip to content

v1.2.1

Latest
Compare
Choose a tag to compare
@tobiasbu tobiasbu released this 01 Apr 13:35
59bf908

What's Changed

  • Add support for Reds dialing options and general project updates by @tobiasbu in #4 (supports TLSConfig)
    • Update project setup
    • Update the deprecated Redis package to the new one
    • Adjust test to improve logs traceability

BREAKING CHANGES

  • The worker configuration options was cnanged from map[string]string to struct Options type. This way we can have better visibility over the worker options. Migrate example:
// v1 - Old way:
- workers.Configure(map[string]string{
-	"server":  "localhost:6379",
-	"database":  "0",
- 	"pool":    "30",
-	"process": "1",
- })

// v1.2.1 - Configuring the workers is now defined by the struct Options:
+ workers.Configure(workers.Options{
+	Address: "localhost:6379",
+	Database: "0",
+	PoolSize: 30, // Notice that the PoolSize is an integer now
+	ProcessID: "1",
+})

The same applies to EnqueueWithOptions function:

// v1 - old way
_, err := workers.EnqueueWithOptions(queueName, "operation", args, workers.EnqueueOptions{
	Retry: true,
-	ConnectionOptions: map[string]string{
-		"server":   fmt.Sprintf("%s:%s", redisHost, redisPort),
-		"password": redisPassword,
-		"database": redisDatabase,
-		"pool":     redisPool,
-	},
})

// v1.2.1
_, err := workers.EnqueueWithOptions(queueName, "operation", args, workers.EnqueueOptions{
	Retry: true,
+	ConnectionOptions: workers.Options{
+		Address:  fmt.Sprintf("%s:%s", redisHost, redisPort),
+		Password: redisPassword,
+		Database: redisDatabase,
+		PoolSize: redisPool,
+	},
})

Configuring TLSConfig example

To use TLSConfig create Redis dialing options:

dialOptions := []redis.DialOption{redis.DialConnectTimeout(redisConnectTimeout)}
if useTLS {
    dialOptions = append(dialOptions,
        redis.DialUseTLS(true),
        redis.DialTLSConfig(&tls.Config{InsecureSkipVerify: true}),
    )
}

Then add it to your workers.Options:

opts := workers.Options{
    Address:     fmt.Sprintf("%s:%s", redisHost, redisPort),
    Password:    redisPassword,
    Database:    redisDatabase,
    PoolSize:    redisPool,
+    DialOptions: dialOptions,
}

Do the same for EnqueueWithOptions:

_, err := workers.EnqueueWithOptions(queueRunner.Name, "operation", args, workers.EnqueueOptions{
    Retry: true,
    At: scheduledTime,
    ConnectionOptions:  workers.Options{
      Address:  fmt.Sprintf("%s:%s", redisHost, redisPort),
      Password: redisPassword,
      Database: redisDatabase,
      PoolSize: redisPool,
+     DialOptions: dialOptions,
  },
})

New Contributors

Full Changelog: v1.0.1...v2.0.0