M worker/context.go => worker/context.go +2 -2
@@ 14,7 14,7 @@ import (
"strings"
"time"
- "github.com/go-redis/redis"
+ goredis "github.com/go-redis/redis/v8"
"github.com/google/shlex"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@@ 41,7 41,7 @@ var (
type WorkerContext struct {
Db *sql.DB
- Redis *redis.Client
+ Redis *goredis.Client
Conf func(section, key string) string
}
M worker/main.go => worker/main.go +5 -4
@@ 1,6 1,7 @@
package main
import (
+ "context"
"database/sql"
"flag"
"log"
@@ 9,7 10,7 @@ import (
"runtime"
"sync"
- "github.com/go-redis/redis"
+ goredis "github.com/go-redis/redis/v8"
"github.com/vaughan0/go-ini"
"git.sr.ht/~sircmpwn/core-go/crypto"
@@ 68,12 69,12 @@ func main() {
if !ok {
redisHost = "redis://localhost:6379"
}
- ropts, err := redis.ParseURL(redisHost)
+ ropts, err := goredis.ParseURL(redisHost)
if err != nil {
panic(err)
}
- localRedis := redis.NewClient(ropts)
- if _, err := localRedis.Ping().Result(); err != nil {
+ localRedis := goredis.NewClient(ropts)
+ if _, err := localRedis.Ping(context.Background()).Result(); err != nil {
panic(err)
}
M worker/tasks.go => worker/tasks.go +5 -5
@@ 19,7 19,7 @@ import (
"time"
"git.sr.ht/~sircmpwn/core-go/auth"
- "github.com/go-redis/redis"
+ goredis "github.com/go-redis/redis/v8"
"github.com/kr/pty"
"github.com/minio/minio-go/v6"
"github.com/pkg/errors"
@@ 39,12 39,12 @@ var (
}, []string{"image", "arch"})
)
-func (ctx *JobContext) Boot(r *redis.Client) func() {
- port, err := r.Incr("builds.sr.ht.ssh-port").Result()
+func (ctx *JobContext) Boot(r *goredis.Client) func() {
+ port, err := r.Incr(ctx.Context, "builds.sr.ht.ssh-port").Result()
if err == nil && port < 22000 {
- err = r.Set("builds.sr.ht.ssh-port", 22100, 0).Err()
+ err = r.Set(ctx.Context, "builds.sr.ht.ssh-port", 22100, 0).Err()
} else if err == nil && port >= 23000 {
- err = r.Set("builds.sr.ht.ssh-port", 22000, 0).Err()
+ err = r.Set(ctx.Context, "builds.sr.ht.ssh-port", 22000, 0).Err()
}
if err != nil {
panic(errors.Wrap(err, "assign port"))