model

package
v0.0.0-...-963fe7b Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Timers = make(map[int]*time.Timer)

Timers slice hold all current timers

Functions

func DeletePayload

func DeletePayload(assID int) bool

DeletePayload removes payload from db

func GetTimer

func GetTimer(timerID int) *time.Timer

GetTimer returns timer at timerID

func InitializeTimers

func InitializeTimers()

InitializeTimers fetches timers from database on startup

func NewTask

func NewTask(payload Payload) bool

NewTask registers a new Task in database and ships it off for scheduling

func ScheduleTask

func ScheduleTask(payload Payload) bool

ScheduleTask schedules a task based on its type

func StopTimer

func StopTimer(timerID int)

StopTimer stops a timer and removes it from map

func UpdateTimer

func UpdateTimer(newData json.RawMessage, newTime time.Time, payload Payload) bool

UpdateTimer should update the time of an existing timer (delete and create new timer)

Types

type Payload

type Payload struct {
	ID             int             `json:"id"`
	Authentication string          `json:"authentication"`
	ScheduledTime  time.Time       `json:"scheduled_time"`
	Task           string          `json:"task"`
	AssignmentID   int             `json:"assignment_id"`
	Data           json.RawMessage `json:"data"`
}

Payload struct https://stackoverflow.com/questions/28254102/how-to-unmarshal-json-into-interface-in-go

func GetPayload

func GetPayload(assID int) Payload

GetPayload from db

func GetPayloads

func GetPayloads() []Payload

GetPayloads from db

func (Payload) GetPeerTask

func (payload Payload) GetPeerTask() (PeerTask, error)

GetPeerTask withdraws a PeerTask object from the data column of a payload object

func (Payload) Save

func (payload Payload) Save() bool

Save stores the payload object to the database for redundancy

func (Payload) UpdatePayload

func (payload Payload) UpdatePayload() bool

UpdatePayload updates payload in db

type PeerTask

type PeerTask struct {
	Authentication string `json:"authentication"`
	AssignmentID   int    `json:"assignment_id"`
	Reviewers      int    `json:"reviewers"`
}

PeerTask struct

func (PeerTask) Delete

func (peer PeerTask) Delete() bool

Delete deletes a PeerTask from database

func (PeerTask) Schedule

func (peer PeerTask) Schedule(scheduledTime time.Time) bool

Schedule schedules a PeerTask for being triggered in the future

func (PeerTask) Trigger

func (peer PeerTask) Trigger()

Trigger runs tasks when their scheduled time expires

type Task

type Task interface {
	Schedule()
	Trigger()
	Delete() bool
}

Task interface

Jump to

Keyboard shortcuts

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