Skip to content

Uber fx integration #146

Answered by reugn
7amou3 asked this question in Q&A
Discussion options

You must be logged in to vote

One of the options is to create a service to instantiate job details.

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/reugn/go-quartz/job"
	"github.com/reugn/go-quartz/quartz"
	"go.uber.org/fx"
)

type JobDetailService struct {
	Job quartz.Job
}

func (s *JobDetailService) NewJobDetail(jobKey *quartz.JobKey) *quartz.JobDetail {
	return quartz.NewJobDetail(s.Job, jobKey)
}

func NewJobDetailService(job quartz.Job) *JobDetailService {
	return &JobDetailService{Job: job}
}

func main() {
	app := fx.New(
		fx.Options(
			fx.Provide(func() quartz.Job {
				return job.NewFunctionJobWithDesc(
					"job1",
					func(ctx context.Context) (string, error) { return "ok", nil },
				)
		…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 7amou3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants