repository

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 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 HookTimer

type HookTimer interface {
	// SetRepository sets Repository. Calling this twice may cause a runtime panic.
	SetRepository(core def.Repository)
	AddTask(ctx context.Context, param def.TaskUpdateParam)
	UpdateById(ctx context.Context, id string, param def.TaskUpdateParam)
	Cancel(ctx context.Context, id string)
	MarkAsDispatched(ctx context.Context, id string)
	def.Observer
}

HookTimer watches repository mutation and resets its timer if necessary.

type MutationHookTimer

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

func NewMutationHookTimer

func NewMutationHookTimer() *MutationHookTimer

func (*MutationHookTimer) AddTask

func (t *MutationHookTimer) AddTask(ctx context.Context, param def.TaskUpdateParam)

func (*MutationHookTimer) Cancel

func (t *MutationHookTimer) Cancel(ctx context.Context, id string)

func (*MutationHookTimer) LastTimerUpdateError

func (t *MutationHookTimer) LastTimerUpdateError() error

func (*MutationHookTimer) MarkAsDispatched

func (t *MutationHookTimer) MarkAsDispatched(ctx context.Context, id string)

func (*MutationHookTimer) NextScheduled

func (t *MutationHookTimer) NextScheduled() (time.Time, bool)

func (*MutationHookTimer) SetRepository

func (t *MutationHookTimer) SetRepository(core def.Repository)

func (*MutationHookTimer) StartTimer

func (t *MutationHookTimer) StartTimer(ctx context.Context)

func (*MutationHookTimer) StopTimer

func (t *MutationHookTimer) StopTimer()

func (*MutationHookTimer) TimerChannel

func (t *MutationHookTimer) TimerChannel() <-chan time.Time

func (*MutationHookTimer) UpdateById

func (t *MutationHookTimer) UpdateById(ctx context.Context, id string, param def.TaskUpdateParam)

type Repository

type Repository struct {
	Repository def.Repository
	HookTimer  HookTimer
}

Repository is a thin wrapper that connects def.Repository and HookTimer. Every mutation is observed and that would update the timer if necessary.

func New

func New(core def.Repository, hookTimer HookTimer) *Repository

func (*Repository) AddTask

func (r *Repository) AddTask(ctx context.Context, param def.TaskUpdateParam) (def.Task, error)

func (*Repository) Cancel

func (r *Repository) Cancel(ctx context.Context, id string) error

func (*Repository) Close

func (r *Repository) Close() error

func (*Repository) Find

func (r *Repository) Find(
	ctx context.Context,
	matcher def.TaskQueryParam,
	offset, limit int,
) ([]def.Task, error)

func (*Repository) GetById

func (r *Repository) GetById(ctx context.Context, id string) (def.Task, error)

func (*Repository) GetNext

func (r *Repository) GetNext(ctx context.Context) (def.Task, error)

func (*Repository) LastTimerUpdateError

func (r *Repository) LastTimerUpdateError() error

func (*Repository) MarkAsDispatched

func (r *Repository) MarkAsDispatched(ctx context.Context, id string) error

func (*Repository) MarkAsDone

func (r *Repository) MarkAsDone(ctx context.Context, id string, err error) error

func (*Repository) NextScheduled

func (r *Repository) NextScheduled() (time.Time, bool)

func (*Repository) StartTimer

func (r *Repository) StartTimer(ctx context.Context)

func (*Repository) StopTimer

func (r *Repository) StopTimer()

func (*Repository) TimerChannel

func (r *Repository) TimerChannel() <-chan time.Time

func (*Repository) UpdateById

func (r *Repository) UpdateById(ctx context.Context, id string, param def.TaskUpdateParam) error

Directories

Path Synopsis
ent
gen

Jump to

Keyboard shortcuts

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