Documentation
¶
Index ¶
- type HookTimer
- type MutationHookTimer
- func (t *MutationHookTimer) AddTask(ctx context.Context, param def.TaskUpdateParam)
- func (t *MutationHookTimer) Cancel(ctx context.Context, id string)
- func (t *MutationHookTimer) LastTimerUpdateError() error
- func (t *MutationHookTimer) MarkAsDispatched(ctx context.Context, id string)
- func (t *MutationHookTimer) NextScheduled() (time.Time, bool)
- func (t *MutationHookTimer) SetRepository(core def.Repository)
- func (t *MutationHookTimer) StartTimer(ctx context.Context)
- func (t *MutationHookTimer) StopTimer()
- func (t *MutationHookTimer) TimerChannel() <-chan time.Time
- func (t *MutationHookTimer) UpdateById(ctx context.Context, id string, param def.TaskUpdateParam)
- type Repository
- func (r *Repository) AddTask(ctx context.Context, param def.TaskUpdateParam) (def.Task, error)
- func (r *Repository) Cancel(ctx context.Context, id string) error
- func (r *Repository) Close() error
- func (r *Repository) Find(ctx context.Context, matcher def.TaskQueryParam, offset, limit int) ([]def.Task, error)
- func (r *Repository) GetById(ctx context.Context, id string) (def.Task, error)
- func (r *Repository) GetNext(ctx context.Context) (def.Task, error)
- func (r *Repository) LastTimerUpdateError() error
- func (r *Repository) MarkAsDispatched(ctx context.Context, id string) error
- func (r *Repository) MarkAsDone(ctx context.Context, id string, err error) error
- func (r *Repository) NextScheduled() (time.Time, bool)
- func (r *Repository) StartTimer(ctx context.Context)
- func (r *Repository) StopTimer()
- func (r *Repository) TimerChannel() <-chan time.Time
- func (r *Repository) UpdateById(ctx context.Context, id string, param def.TaskUpdateParam) error
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) 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) LastTimerUpdateError ¶
func (r *Repository) LastTimerUpdateError() error
func (*Repository) MarkAsDispatched ¶
func (r *Repository) MarkAsDispatched(ctx context.Context, id string) error
func (*Repository) MarkAsDone ¶
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
Click to show internal directories.
Click to hide internal directories.