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

无法接受到参数 #14

Open
shcw opened this issue May 15, 2022 · 0 comments
Open

无法接受到参数 #14

shcw opened this issue May 15, 2022 · 0 comments

Comments

@shcw
Copy link

shcw commented May 15, 2022

这是我的GO代码

package main

import (
	"context"
	"github.com/feixiaobo/go-xxl-job-client/v2"
	"github.com/feixiaobo/go-xxl-job-client/v2/option"
	"github.com/sirupsen/logrus"
)

func main() {
	client := xxl.NewXxlClient(
		option.WithAppName("go-example"),
		// option.WithAccessToken("edqedewfrqdrfrfr"),
		option.WithEnableHttp(true), // xxl_job v2.2之后的版本
		option.WithClientPort(8083),
		option.WithAdminAddress("http://127.0.0.1:9010/xxl-job-admin"),
	)
	client.SetLogger(&logrus.Entry{
		Logger: logrus.New(),
		Level:  logrus.InfoLevel,
	})
	client.RegisterJob("testJob", XxlJobTest)
	logrus.Info("run")
	client.Run() // 启动客户端
}

func XxlJobTest(ctx context.Context) error {
	logrus.Info(ctx, "golang job run success >>>>>>>>>>>>>>")
	val, _ := xxl.GetParam(ctx, "test")
	logrus.Info("job param:", val)
	param, _ := xxl.GetParam(ctx, "name") // 获取输入参数
	logrus.Info(ctx, "the input param:", param)
	shardingIdx, shardingTotal := xxl.GetSharding(ctx) // 获取分片参数
	logrus.Info(ctx, "the sharding param: idx:", shardingIdx, ", total:", shardingTotal)
	return nil
}

这是我的XXl-JOB-ADMIN v2.3.0
image

这是运行结果:
image

不知道是哪里除了问题,求助大佬~

@feixiaobo

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

1 participant