Documentation ¶
Index ¶
- Constants
- Variables
- type HookClient
- type HookData
- type HookStore
- type JobStatsManager
- type RedisJobStatsManager
- func (rjs *RedisJobStatsManager) CheckIn(jobID string, message string)
- func (rjs *RedisJobStatsManager) CtlCommand(jobID string) (string, error)
- func (rjs *RedisJobStatsManager) DieAt(jobID string, dieAt int64)
- func (rjs *RedisJobStatsManager) ExpirePeriodicJobStats(jobID string) error
- func (rjs *RedisJobStatsManager) RegisterHook(jobID string, hookURL string, isCached bool) error
- func (rjs *RedisJobStatsManager) Retrieve(jobID string) (models.JobStats, error)
- func (rjs *RedisJobStatsManager) Save(jobStats models.JobStats)
- func (rjs *RedisJobStatsManager) SendCommand(jobID string, command string) error
- func (rjs *RedisJobStatsManager) SetJobStatus(jobID string, status string)
- func (rjs *RedisJobStatsManager) Shutdown()
- func (rjs *RedisJobStatsManager) Start()
Constants ¶
const ( // CtlCommandStop : command stop CtlCommandStop = "stop" // CtlCommandCancel : command cancel CtlCommandCancel = "cancel" // CtlCommandRetry : command retry CtlCommandRetry = "retry" // EventRegisterStatusHook is event name of registering hook EventRegisterStatusHook = "register_hook" )
const (
// EventFireCommand for firing command event
EventFireCommand = "fire_command"
)
Variables ¶
var DefaultHookClient = NewHookClient()
DefaultHookClient is for default use.
Functions ¶
This section is empty.
Types ¶
type HookClient ¶
type HookClient struct {
// contains filtered or unexported fields
}
HookClient is used to post the related data to the interested parties.
func NewHookClient ¶
func NewHookClient() *HookClient
NewHookClient return the ptr of the new HookClient
func (*HookClient) ReportStatus ¶
func (hc *HookClient) ReportStatus(hookURL string, status models.JobStatusChange) error
ReportStatus reports the status change info to the subscribed party. The status includes 'checkin' info with format 'check_in:<message>'
type HookStore ¶
type HookStore struct {
// contains filtered or unexported fields
}
HookStore is used to cache the hooks in memory. Use job ID as key to index
func NewHookStore ¶
func NewHookStore() *HookStore
NewHookStore is to create a ptr of new HookStore.
type JobStatsManager ¶
type JobStatsManager interface { // Start to serve Start() // Shutdown the manager Shutdown() // Save the job stats // Async method to retry and improve performance // // jobStats models.JobStats : the job stats to be saved Save(jobStats models.JobStats) // Get the job stats from backend store // Sync method as we need the data // // Returns: // models.JobStats : job stats data // error : error if meet any problems Retrieve(jobID string) (models.JobStats, error) // SetJobStatus will mark the status of job to the specified one // Async method to retry SetJobStatus(jobID string, status string) // Send command fro the specified job // // jobID string : ID of the being retried job // command string : the command applied to the job like stop/cancel // // Returns: // error if it was not successfully sent SendCommand(jobID string, command string) error // CtlCommand checks if control command is fired for the specified job. // // jobID string : ID of the job // // Returns: // the command if it was fired // error if it was not fired yet to meet some other problems CtlCommand(jobID string) (string, error) // CheckIn message for the specified job like detailed progress info. // // jobID string : ID of the job // message string : The message being checked in // CheckIn(jobID string, message string) // DieAt marks the failed jobs with the time they put into dead queue. // // jobID string : ID of the job // message string : The message being checked in // DieAt(jobID string, dieAt int64) // RegisterHook is used to save the hook url or cache the url in memory. // // jobID string : ID of job // hookURL string : the hook url being registered // isCached bool : to indicate if only cache the hook url // // Returns: // error if meet any problems RegisterHook(jobID string, hookURL string, isCached bool) error // Mark the periodic job stats expired // // jobID string : ID of job // // Returns: // error if meet any problems ExpirePeriodicJobStats(jobID string) error }
JobStatsManager defines the methods to handle stats of job.
type RedisJobStatsManager ¶
type RedisJobStatsManager struct {
// contains filtered or unexported fields
}
RedisJobStatsManager implements JobStatsManager based on redis.
func NewRedisJobStatsManager ¶
func NewRedisJobStatsManager(ctx context.Context, namespace string, redisPool *redis.Pool) *RedisJobStatsManager
NewRedisJobStatsManager is constructor of RedisJobStatsManager
func (*RedisJobStatsManager) CheckIn ¶
func (rjs *RedisJobStatsManager) CheckIn(jobID string, message string)
CheckIn mesage
func (*RedisJobStatsManager) CtlCommand ¶
func (rjs *RedisJobStatsManager) CtlCommand(jobID string) (string, error)
CtlCommand checks if control command is fired for the specified job.
func (*RedisJobStatsManager) DieAt ¶
func (rjs *RedisJobStatsManager) DieAt(jobID string, dieAt int64)
DieAt marks the failed jobs with the time they put into dead queue.
func (*RedisJobStatsManager) ExpirePeriodicJobStats ¶
func (rjs *RedisJobStatsManager) ExpirePeriodicJobStats(jobID string) error
ExpirePeriodicJobStats marks the periodic job stats expired
func (*RedisJobStatsManager) RegisterHook ¶
func (rjs *RedisJobStatsManager) RegisterHook(jobID string, hookURL string, isCached bool) error
RegisterHook is used to save the hook url or cache the url in memory.
func (*RedisJobStatsManager) Retrieve ¶
func (rjs *RedisJobStatsManager) Retrieve(jobID string) (models.JobStats, error)
Retrieve is implementation of same method in JobStatsManager interface. Sync method
func (*RedisJobStatsManager) Save ¶
func (rjs *RedisJobStatsManager) Save(jobStats models.JobStats)
Save is implementation of same method in JobStatsManager interface. Async method
func (*RedisJobStatsManager) SendCommand ¶
func (rjs *RedisJobStatsManager) SendCommand(jobID string, command string) error
SendCommand for the specified job
func (*RedisJobStatsManager) SetJobStatus ¶
func (rjs *RedisJobStatsManager) SetJobStatus(jobID string, status string)
SetJobStatus is implementation of same method in JobStatsManager interface. Async method
func (*RedisJobStatsManager) Shutdown ¶
func (rjs *RedisJobStatsManager) Shutdown()
Shutdown is implementation of same method in JobStatsManager interface.
func (*RedisJobStatsManager) Start ¶
func (rjs *RedisJobStatsManager) Start()
Start is implementation of same method in JobStatsManager interface.