Go - job.submit()

Jobs may be submitted from Nitric services or other batches using the submit method on the job reference. When submitting a job you can provide a payload that will be passed to the job handler function.

import (
	"context"
	"fmt"

	"github.com/nitrictech/go-sdk/nitric"
)

func main() {
	analyse, err := nitric.NewJob("analyse").Allow(nitric.JobSubmit)
	if err != nil {
		fmt.Println(err)
	}

	analyse.Submit(context.TODO(), map[string]interface{}{
		"message": "message contents",
	})

	if err := nitric.Run(); err != nil {
		fmt.Println(err)
	}
}

Parameters

  • Name
    message
    Required
    Required
    Type
    map[string]interface{}
    Description

    The data that will be sent to the submit

Examples

Submit a job request

import (
	"context"
	"fmt"

	"github.com/nitrictech/go-sdk/nitric"
)

func main() {
	analyse, err := nitric.NewJob("analyse").Allow(nitric.JobSubmit)
	if err != nil {
		fmt.Println(err)
	}

	analyse.Submit(context.TODO(), map[string]interface{}{
		"message": "message contents",
	})

	if err := nitric.Run(); err != nil {
		fmt.Println(err)
	}
}