| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | package depimport (	"kpt-pasture/config"	"kpt-pasture/module/crontab"	"go.uber.org/dig"	"gitee.com/xuyiping_admin/pkg/cron"	prom "github.com/prometheus/client_golang/prometheus")var DataCenterCrontabCounterVec = prom.NewCounterVec(	prom.CounterOpts{		Namespace: "kpt-pasture",		Subsystem: "crontab",		Name:      "crontab",	},	[]string{"name"},)func DICrontabService() (out *cron.Crontab) {	container := DI()	if err := container.Provide(EntryCrontab); err != nil {		panic(err)	}	if err := container.Invoke(func(c *cron.Crontab) { out = c }); err != nil {		panic(err)	}	return}// CrontabDependency 依赖注入结构体type CrontabDependency struct {	dig.In	CrontabHub crontab.Crontab // 定时任务}func EntryCrontab(dependency CrontabDependency) *cron.Crontab {	cfg := config.Options()	cs := cfg.CronSetting	newCrontab := cron.NewCrontab(DataCenterCrontabCounterVec)	err := newCrontab.Bind("UpdateCowInfo", cs.UpdateCowInfo, dependency.CrontabHub.UpdateCowInfo)	if err != nil {		panic(err)	}	err = newCrontab.Bind("GenerateWorkOrder", cs.GenerateWorkOrder, dependency.CrontabHub.GenerateAsynqWorkOrder)	if err != nil {		panic(err)	}	err = newCrontab.Bind("ImmunizationPlan", cs.ImmunizationPlan, dependency.CrontabHub.ImmunizationPlan)	if err != nil {		panic(err)	}	err = newCrontab.Bind("SameTimePlan", cs.SameTimePlan, dependency.CrontabHub.SameTimePlan)	if err != nil {		panic(err)	}	err = newCrontab.Bind("UpdateSameTime", cs.UpdateSameTime, dependency.CrontabHub.UpdateSameTime)	if err != nil {		panic(err)	}	return newCrontab}
 |