Add ParseRedisURI helper function

This commit is contained in:
Ken Hibino
2020-03-26 07:31:08 -07:00
parent 789a9fd711
commit eb8ced6bdd
4 changed files with 200 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
package asynq_test
import (
"fmt"
"log"
"os"
"os/signal"
@@ -76,3 +77,19 @@ func ExampleServer_Quiet() {
srv.Stop()
}
func ExampleParseRedisURI() {
rconn, err := asynq.ParseRedisURI("redis://localhost:6379/10")
if err != nil {
log.Fatal(err)
}
r, ok := rconn.(asynq.RedisClientOpt)
if !ok {
log.Fatal("unexpected type")
}
fmt.Println(r.Addr)
fmt.Println(r.DB)
// Output:
// localhost:6379
// 10
}