Documentation ¶
Index ¶
- Constants
- Variables
- type HookClient
- type HookData
- type HookStore
- type JobStatsManager
- type Range
- type RedisJobStatsManager
- func (rjs *RedisJobStatsManager) AttachExecution(upstreamJobID string, executions ...string) error
- 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) GetExecutions(upstreamJobID string, ranges ...Range) ([]string, error)
- func (rjs *RedisJobStatsManager) GetHook(jobID string) (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, isCached bool) error
- func (rjs *RedisJobStatsManager) SetJobStatus(jobID string, status string)
- func (rjs *RedisJobStatsManager) Shutdown()
- func (rjs *RedisJobStatsManager) Start()
- func (rjs *RedisJobStatsManager) Update(jobID string, fieldAndValues ...interface{}) error
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) // Update the properties of the job stats // // jobID string : ID of the being retried job // fieldAndValues ...interface{} : One or more properties being updated // // Returns: // error if update failed Update(jobID string, fieldAndValues ...interface{}) 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 // isCached bool : to indicate if only cache the op command // // Returns: // error if it was not successfully sent SendCommand(jobID string, command string, isCached bool) 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 // Get hook returns the web hook url for the specified job if it is registered // // jobID string : ID of job // // Returns: // the web hook url if existing // non-nil error if meet any problems GetHook(jobID string) (string, error) // Mark the periodic job stats expired // // jobID string : ID of job // // Returns: // error if meet any problems ExpirePeriodicJobStats(jobID string) error // Persist the links between upstream job and the executions. // // upstreamJobID string: ID of the upstream job // executions ...string: IDs of the execution jobs // // Returns: // error if meet any issues AttachExecution(upstreamJobID string, executions ...string) error // Get all the executions (IDs) fro the specified upstream Job. // // upstreamJobID string: ID of the upstream job // ranges ...Range: Define the start and end for the list, e.g: // 0, 10 means [0:10] // 10 means [10:] // empty means [0:-1]==all // Returns: // the ID list of the executions if no error occurred // or a non-nil error is returned GetExecutions(upstreamJobID string, ranges ...Range) ([]string, error) }
JobStatsManager defines the methods to handle stats of job.
func NewRedisJobStatsManager ¶
func NewRedisJobStatsManager(ctx context.Context, namespace string, redisPool *redis.Pool) JobStatsManager
NewRedisJobStatsManager is constructor of RedisJobStatsManager
type RedisJobStatsManager ¶
type RedisJobStatsManager struct {
// contains filtered or unexported fields
}
RedisJobStatsManager implements JobStatsManager based on redis.
func (*RedisJobStatsManager) AttachExecution ¶ added in v1.7.0
func (rjs *RedisJobStatsManager) AttachExecution(upstreamJobID string, executions ...string) error
AttachExecution persist the links between upstream jobs and the related executions (jobs).
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) GetExecutions ¶ added in v1.7.0
func (rjs *RedisJobStatsManager) GetExecutions(upstreamJobID string, ranges ...Range) ([]string, error)
GetExecutions returns the existing executions (IDs) for the specified job.
func (*RedisJobStatsManager) GetHook ¶ added in v1.7.0
func (rjs *RedisJobStatsManager) GetHook(jobID string) (string, error)
GetHook returns the status web hook url for the specified job if existing
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, isCached bool) 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.
func (*RedisJobStatsManager) Update ¶ added in v1.7.0
func (rjs *RedisJobStatsManager) Update(jobID string, fieldAndValues ...interface{}) error
Update the properties of job stats