Documentation ¶
Index ¶
- Constants
- Variables
- func IntInSlice(num int, slice []int) bool
- func Notify(jt *JobTarget, jDB *JobDB) error
- func NotifyGorush(bu string, jt *JobTarget) error
- func SetTaskState(tID string, uID string, state string, validStates []string, ...) error
- func SetTokenExpired(db *sqlx.DB, uID string) error
- type AlertData
- type GinSchedMiddleware
- type GoRushLog
- type GoRushNotification
- type GoRushReq
- type GoRushResponse
- type Job
- func (j *Job) CreateTask(cID string, t *TaskData, jDB *JobDB) (string, error)
- func (j *Job) GetTargets(jDB *JobDB) []*JobTarget
- func (j *Job) GetWaitDuration() time.Duration
- func (j *Job) Run(jDB *JobDB)
- func (j *Job) Save(jDB *JobDB) error
- func (j *Job) ShouldRun() bool
- func (j *Job) ShouldWait() bool
- func (j *Job) WaitAndRun(jDB *JobDB)
- type JobDB
- type JobTarget
- type NotifyReq
- type Schedule
- type ScheduleDuration
- type Scheduler
- type TaskData
Constants ¶
const ISOUTCTimeLayout = "2006-01-02T15:04:05Z"
ISOUTCTimeLayout format string for ISO standard time
Variables ¶
var ErrAccessDenied = errors.New("access denied")
ErrAccessDenied not enough permissions
var ErrExpiredToken = errors.New("token is expired")
ErrExpiredToken not enough permissions
var ErrInconsistentState = errors.New("task already accepted")
ErrInconsistentState when you try to accept an already accepted task
var ErrTaskNotFound = errors.New("task not found")
ErrTaskNotFound could not find the referenced task
Functions ¶
func IntInSlice ¶
IntInSlice checks if a int is inside of a certain slice of ints
func NotifyGorush ¶
NotifyGorush tell gorush to notify clients
Types ¶
type AlertData ¶
type AlertData struct { ID string `json:"id"` Message string `json:"message" binding:"required"` Extra map[string]interface{} `json:"extra"` }
AlertData is the alert message
type GinSchedMiddleware ¶
type GinSchedMiddleware struct {
// contains filtered or unexported fields
}
GinSchedMiddleware a database aware middleware. It will set the DB property, that can be accessed via: db := c.MustGet("DB").(*sqlx.DB)
func InitSchedMiddleware ¶
func InitSchedMiddleware(db *sqlx.DB) (*GinSchedMiddleware, error)
InitSchedMiddleware create the middleware that injects the database
func (*GinSchedMiddleware) MiddlewareFunc ¶
func (mw *GinSchedMiddleware) MiddlewareFunc() gin.HandlerFunc
MiddlewareFunc this is what you register as the middleware
type GoRushLog ¶ added in v0.2.5
type GoRushLog struct { Type string `json:"type"` Platform string `json:"platform"` Token string `json:"token"` Message string `json:"message"` Error string `json:"error"` }
GoRushLog contains details about the failure. It is available when core->sync in the gorush settings (https://github.com/appleboy/gorush#features) is true. For expired tokens Error will be: * "Unregistered" or "BadDeviceToken" on iOS https://stackoverflow.com/questions/42511476/what-are-the-possible-reasons-to-get-apns-responses-baddevicetoken-or-unregister https://github.com/sideshow/apns2/blob/master/response.go#L85 * "NotRegistered" or "InvalidRegistration" on Android: See: https://github.com/appleboy/go-fcm/blob/master/response.go
type GoRushNotification ¶
type GoRushNotification struct { Tokens []string `json:"tokens"` Platform int `json:"platform"` Message string `json:"message"` Topic string `json:"topic"` To string `json:"to"` Data map[string]interface{} `json:"data"` ContentAvailable bool `json:"content_available"` Notification map[string]string `json:"notification"` }
GoRushNotification contains all the notification metadata for gorush
type GoRushReq ¶
type GoRushReq struct {
Notifications []*GoRushNotification `json:"notifications"`
}
GoRushReq is a wrapper for a gorush notification request
type GoRushResponse ¶ added in v0.2.5
type GoRushResponse struct { Counts int `json:"counts"` Success string `json:"success"` Logs []GoRushLog `json:"logs"` }
GoRushResponse is a response from gorush on /api/push
type Job ¶
type Job struct { ID string Schedule Schedule Delay int64 Comment string NextRunAt time.Time TimesRun int64 IsDone bool // contains filtered or unexported fields }
Job container
func (*Job) CreateTask ¶
CreateTask creates a new task and stores it in the JobDB
func (*Job) GetTargets ¶
GetTargets returns all the targets for the job
func (*Job) GetWaitDuration ¶
GetWaitDuration gets the amount of time to wait for the task to run next
func (*Job) ShouldWait ¶
ShouldWait returns true if the job is not done
func (*Job) WaitAndRun ¶
WaitAndRun will wait on the job and then run it when it's time
type JobDB ¶
type JobDB struct {
// contains filtered or unexported fields
}
JobDB keep track of the Job database
type JobTarget ¶
type JobTarget struct { ClientID string TaskID *string TaskData *TaskData AlertData *AlertData Token string Platform string }
JobTarget the target of a job
type NotifyReq ¶
type NotifyReq struct { ClientIDs []string `json:"client_ids"` Event map[string]interface{} `json:"event"` }
NotifyReq is the reuqest for sending this particular notification message XXX this is duplicated in proteus-notify
type Schedule ¶
type Schedule struct { Repeat int64 StartTime time.Time Duration ScheduleDuration }
Schedule metadata about a schedule
func ParseSchedule ¶
ParseSchedule parse a schedule string
type ScheduleDuration ¶
type ScheduleDuration struct { Years float64 Months float64 Weeks float64 Days float64 Hours float64 Minutes float64 Seconds float64 }
ScheduleDuration datastructure for scheduling information
func ParseDuration ¶
func ParseDuration(s string) (ScheduleDuration, error)
ParseDuration parses a duration string
func (*ScheduleDuration) ToDuration ¶
func (d *ScheduleDuration) ToDuration() time.Duration
ToDuration convert to a time.Duration
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler is the datastructure for the scheduler
func NewScheduler ¶
NewScheduler creates a new instance of the scheduler