All Products
Search
Document Center

SchedulerX:Golang SDK integration

Last Updated:Jan 03, 2026

This topic describes how to use an SDK to quickly integrate a Golang application with SchedulerX.

Console configuration

  1. Create a common application as described in Create Application and generate configuration information as described in Step 2.

    endpoint=xxxx
    namespace=xxxx
    groupId=xxx
    appKey=xxx
  2. Create a Golang task as described in Task Management.

    image.png

Client integration

  1. Run the following command to pull the Go SDK.

    go get github.com/alibaba/schedulerx-worker-go@{latest_tag}
  2. Write your business code to implement the Processor interface.

    type Processor interface {
        Process(ctx *processor.JobContext) (*ProcessResult, error)
    }

    Example:

    package main
    
    import (
    	"fmt"
    	"github.com/alibaba/schedulerx-worker-go/processor"
    	"github.com/alibaba/schedulerx-worker-go/processor/jobcontext"
    	"time"
    )
    
    var _ processor.Processor = &HelloWorld{}
    
    type HelloWorld struct{}
    
    func (h *HelloWorld) Process(ctx *jobcontext.JobContext) (*processor.ProcessResult, error) {
    	fmt.Println("[Process] Start process my task: Hello world!")
    	// mock execute task
    	time.Sleep(3 * time.Second)
    	ret := new(processor.ProcessResult)
    	ret.SetStatus(processor.InstanceStatusSucceed)
    	fmt.Println("[Process] End process my task: Hello world!")
    	return ret, nil
    }
    
  3. Register the client and job. Ensure that the task name is the same as the one configured in the console.

    package main
    
    import (
    	"github.com/alibaba/schedulerx-worker-go"
    )
    
    func main() {
    	// This is just an example, the real configuration needs to be obtained from the platform
    	cfg := &schedulerx.Config{
    		Endpoint:  "acm.aliyun.com",
    		Namespace: "433d8b23-xxx-xxx-xxx-90d4d1b9a4af",
    		GroupId:   "xueren_sub",
    		AppKey:    "xxxxxx",
    	}
    	client, err := schedulerx.GetClient(cfg)
    	if err != nil {
    		panic(err)
    	}
    	task := &HelloWorld{}
    
    	// Name your task and register it with the client. The name must be the same as the one in the console.
    	client.RegisterTask("HelloWorld", task)
    	select {}
    }
    

Verify the result

  1. Publish the application to Alibaba Cloud after the application is connected to SchedulerX.

  2. Log on to the SchedulerX console.

  3. In the top navigation bar, select a region.

  4. In the left-side navigation pane, click Application Management.

  5. On the Application Management page, view Total number of instances.

    • If the Total number of instances column displays 0, the application is not connected to SchedulerX. In this case, check and modify the on-premises application.

    • If the Total number of instances column displays a number other than 0, the application is connected to SchedulerX. Click View instances in the Operation column to view the instances in the Connect to an instance panel.

What to do next

After the application is connected to SchedulerX, you can create jobs in the SchedulerX console. For more information, see the "Create a job" section of the Job management topic.

References

Golang tasks