lib_gc_runner

package
v0.0.0-...-e28984d Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner_I

type Runner_I interface {
	Start() error
	Shutdown() error
	WakeUpTask(Task_I, ...interface{}) error
	IsTaskRunning(int64) (bool, error)
	GetRunningTasksIDs() ([]int64, error)
	FinishTaskById(int64) error
}

func GetRunner

func GetRunner(tasks_checking_interval int64) (Runner_I, error)

Getting a runner instance Parameters :

tasks_checking_interval: Frequency in milliseconds of tasks checking done by the runner.

type RunningTask

type RunningTask struct {
	Task          Task_I
	Args          []interface{}
	FirstWakingUp time.Time
	RunningFrom   []time.Time
}

type TASK_IMPLEMENTATION

type TASK_IMPLEMENTATION func(chan struct{}, TaskManager_I, []interface{}) ([]interface{}, error)

Task implementation type. The first parameter is a chan to catch the END signal. When this channel closes, the implementation task must to finish The second parameters is a slice of input parameters for the task implementation function

type Task

type Task struct {
	Id             int64
	Duration       time.Duration
	Implementation TASK_IMPLEMENTATION

	Eot          chan struct{}
	Response     *TaskResponse
	ResponseChan chan *TaskResponse
	// contains filtered or unexported fields
}

func (*Task) Finalize

func (t *Task) Finalize() error

func (*Task) Finish

func (t *Task) Finish()

TaskImplmentation_I interface

func (*Task) Flush

func (t *Task) Flush()

func (*Task) GetDuration

func (t *Task) GetDuration() time.Duration

func (*Task) GetID

func (t *Task) GetID() int64

func (*Task) GetResponseChan

func (t *Task) GetResponseChan() chan *TaskResponse

func (*Task) IsFinished

func (t *Task) IsFinished() bool

func (*Task) IsRunning

func (t *Task) IsRunning() bool

func (*Task) Run

func (t *Task) Run(args []interface{}) error

type TaskManager_I

type TaskManager_I interface {
	Finish()
	Flush()
}

Task finisher

type TaskResponse

type TaskResponse struct {
	Result interface{}
	Err    error
}

type Task_I

type Task_I interface {
	GetID() int64
	GetDuration() time.Duration
	GetResponseChan() chan *TaskResponse
	Run(args []interface{}) error
	IsRunning() bool
	IsFinished() bool
	Finalize() error
	Flush()
}

Task

func GetTask

func GetTask(id int64, duration time.Duration, implementation TASK_IMPLEMENTATION) (Task_I, error)

taking a Task to be waked up by a runner instance Parameters:

		id: Task's identification. It must be unique per task
		duration: Maximum duration of the task. The task's implementation function is responsible for catching
				  the closing of the EOT channel and process these event as a finalization request. See the test
				  cases for more details about it.
               **special case**: 0 duration stands for infinite task
		implementation: Implementation function of the task. It my be complaint with the TASK_IMPLEMENTATION type

Jump to

Keyboard shortcuts

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