task

package
v2.3.79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export[T, C, N any](ctx context.Context, data []byte, emptyListError error, checkDataFn CheckDataFn[N], listFn ListFn[T, N], actionFn ExportActionFn[T, C]) (*model.Message, error)

func Import

func Import[T, C any, D string | int](ctx context.Context, data []byte, checkDataFn CheckDataFn[T], dataFn DataFn[T, C], actionFn ImportActionFn[T, C, D]) (*model.Message, error)

func MassDelete

func MassDelete[T any, C string | int](ctx context.Context, data []byte, notFoundError error, checkDataFn CheckDataFn[T], idsFn IdsFn[T, C], pluckIDsFn PluckIDsFn[C], actionFn DeleteActionFn[T, C]) (*model.Message, error)

func MassUpdate

func MassUpdate[T any, C string | int](ctx context.Context, data []byte, notFoundError error, checkDataFn CheckDataFn[T], idsFn IdsFn[T, C], pluckIDsFn PluckIDsFn[C], actionFn UpdateActionFn[T, C]) (*model.Message, error)

Types

type CheckDataFn added in v2.3.74

type CheckDataFn[T any] func(T) error

type Config

type Config struct {
	Debug       string
	DB          *gorm.DB
	Transaction mw.ITransaction
	Services    Consumers
	TokenString string
	SseSvc      sse.SSE
}

type Consumer

type Consumer interface {
	service.Consumer
}

type Consumers

type Consumers map[string]Consumer

type DataFn added in v2.3.74

type DataFn[T, C any] func(T) []C

type DeleteActionFn added in v2.3.74

type DeleteActionFn[T any, C string | int] func(context.Context, T, C) error

type ExportActionFn added in v2.3.74

type ExportActionFn[T, C any] func(T) (C, error)

type IdsFn added in v2.3.74

type IdsFn[T any, C string | int] func(T) []C

type ImportActionFn added in v2.3.74

type ImportActionFn[T, C any, D string | int] func(context.Context, T, C) (D, error, error)

type ListFn added in v2.3.74

type ListFn[T, N any] func(context.Context, N) ([]T, error)

type PluckIDsFn added in v2.3.74

type PluckIDsFn[C string | int] func(context.Context, []C) ([]C, error)

type Queue

type Queue interface {
	Run(data runner.Data)
	Stop(id int)
	TaskResults() chan runner.TaskResult
}

type Task

type Task struct {
	// contains filtered or unexported fields
}

func (*Task) ExportHandler

func (e *Task) ExportHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc

func (*Task) ImportHandler

func (e *Task) ImportHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc

func (*Task) InitHandler

func (e *Task) InitHandler(secured *gin.RouterGroup, unsecured *gin.RouterGroup)

func (*Task) MassDeleteHandler

func (e *Task) MassDeleteHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc

func (*Task) MassUpdateHandler

func (e *Task) MassUpdateHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc

func (*Task) NewTask

func (e *Task) NewTask(c *gin.Context, tp string, name string, data []byte) (*model.Task, error)

type Tasker

type Tasker interface {
	InitHandler(secured *gin.RouterGroup, unsecured *gin.RouterGroup)
	ExportHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc
	ImportHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc
	MassUpdateHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc
	MassDeleteHandler(name string, bind func(c *gin.Context) ([]byte, error)) gin.HandlerFunc
}

func NewTask

func NewTask(ctx context.Context, cfg Config) (Tasker, error)

type UpdateActionFn added in v2.3.74

type UpdateActionFn[T any, C string | int] func(context.Context, C, T) error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL