Skip to content
Snippets Groups Projects
job.go 1.14 KiB
Newer Older
  • Learn to ignore specific revisions
  • package core
    
    import "io"
    
    // A single collection job. Defines as an interface as there are all
    // kinds of different collection jobs as the respective source
    // repository is different.
    type Job interface {
    	// Return the unique identifier of this job.
    	Id() JobId
    
    	// Return the current state of this job.
    	State() JobState
    
    	// When State is Failed, return the error that caused
    	// the failure. When State is not failed, this method
    	// always returns nil.
    	Error() error
    
    	// This is a synchronous operation that might take a long
    	// time. Instead of invoking Collect directly, you should
    	// create a Collector and Submit this job to it.
    	Collect(c *Collector) error
    
    	// Write to the log associated with this Job. The log message
    	// will be output with the standard logger as well as recorded
    	// to the buffer accessible with Job.Logs().
    	Log(v ...interface{})
    
    	// Write a formatted string to the log associated with this
    	// Job. The log message will be output with the standard
    	// logger as well as recorded to the buffer accessible with
    	// Job.Logs().
    	Logf(format string, v ...interface{})
    
    	// Return the log stream of this job.
    	Logs() io.Reader
    }