RichardKnop / machinery

Machinery is an asynchronous task queue/job queue based on distributed message passing.
Mozilla Public License 2.0
7.57k stars 917 forks source link

Machinery throw an error #800

Open HuckOps opened 10 months ago

HuckOps commented 10 months ago

I`m using machinery with V2.0.11, when I try to install dependency through go mod tidy,that throw an error about:

go: kstart/machinery imports
        github.com/RichardKnop/machinery/v2/backends/redis imports
        github.com/go-redis/redis/v8 imports
        go.opentelemetry.io/otel/label: module go.opentelemetry.io/otel@latest found (v1.22.0), but does not contain package go.opentelemetry.io/otel/label
go: kstart/machinery imports
        github.com/RichardKnop/machinery/v2/backends/redis imports
        github.com/go-redis/redis/v8 imports
        github.com/go-redis/redis/v8/internal imports
        go.opentelemetry.io/otel/metric/global: module go.opentelemetry.io/otel/metric@latest found (v1.22.0), but does not contain package go.opentelemetry.io/otel/metric/global

My code like this:

import (
    "github.com/RichardKnop/machinery/v2"
    redisbackend "github.com/RichardKnop/machinery/v2/backends/redis"
    redisbroker "github.com/RichardKnop/machinery/v2/brokers/redis"
    "github.com/RichardKnop/machinery/v2/config"
    eagerlock "github.com/RichardKnop/machinery/v2/locks/eager"
    "golang.org/x/net/context"
)

var Server *MachineryServer

type MachineryServer struct {
    SRV     *machinery.Server
    Context context.Context
}

func InitMachinery() {
    cnf := &config.Config{
        DefaultQueue:    "machinery_tasks", // 默认队列名称
        ResultsExpireIn: 3600,
        Redis: &config.RedisConfig{
            MaxIdle:                3,    // 最大空闲连接数
            IdleTimeout:            240,  // 空闲连接超时(秒)
            ReadTimeout:            15,   // 读取超时(秒)
            WriteTimeout:           15,   // 写入超时(秒)
            ConnectTimeout:         15,   // 连接超时(秒)
            NormalTasksPollPeriod:  1000, // 正常任务轮询周期(毫秒)
            DelayedTasksPollPeriod: 20,   // 延迟任务轮询周期(毫秒)
        },
    }
    broker := redisbroker.NewGR(cnf, []string{"localhost:6379"}, 0)
    backend := redisbackend.NewGR(cnf, []string{"localhost:6379"}, 0)
    lock := eagerlock.New()
    server := machinery.NewServer(cnf, broker, backend, lock)

    Server = &MachineryServer{
        server,
        context.Background(),
    }
}

I tried in Windows, Mac, and Linux, and they threw the same error

dhairya-chai commented 9 months ago

Any solution for this?

phamvinhdat commented 8 months ago

fix by: go get github.com/RichardKnop/machinery@master