github.com/wfusion/gofusion@v1.1.14/test/cron/cases/types.go (about)

     1  package cases
     2  
     3  import (
     4  	"context"
     5  	"reflect"
     6  
     7  	"github.com/spf13/cast"
     8  
     9  	"github.com/wfusion/gofusion/cron"
    10  	"github.com/wfusion/gofusion/log"
    11  )
    12  
    13  var (
    14  	handleWithCallbackType = reflect.TypeOf(handleWithCallback)
    15  )
    16  
    17  const (
    18  	nameDefault     = "default"
    19  	nameDefaultDup  = "default_dup"
    20  	nameWithLock    = "with_lock"
    21  	nameWithLockDup = "with_lock_dup"
    22  )
    23  
    24  func handleWithCallback(ctx context.Context, task cron.Task) (err error) {
    25  	log.Info(ctx, "we get task: %s", task.Name())
    26  	return
    27  }
    28  
    29  type args struct {
    30  	Msg *string `json:"msg"`
    31  }
    32  
    33  func handleWithArgsFunc(id string) func(ctx context.Context, arg *args) error {
    34  	return func(ctx context.Context, arg *args) (err error) {
    35  		log.Info(ctx, "we get %s arg.msg: %s", id, cast.ToString(arg.Msg))
    36  		return
    37  	}
    38  }