Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machinery throw an error #800

Open
HuckOps opened this issue Jan 31, 2024 · 2 comments
Open

Machinery throw an error #800

HuckOps opened this issue Jan 31, 2024 · 2 comments

Comments

@HuckOps
Copy link

HuckOps commented Jan 31, 2024

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

@HuckOps HuckOps changed the title Machinery throw redis error Machinery throw an error Jan 31, 2024
@dhairya-chai
Copy link

Any solution for this?

@phamvinhdat
Copy link

phamvinhdat commented Mar 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants