2023-04-14 12:40:34 +00:00
|
|
|
package progress
|
2023-03-29 12:58:09 +00:00
|
|
|
|
|
|
|
import (
|
2023-04-18 12:40:45 +00:00
|
|
|
"fmt"
|
2023-03-29 12:58:09 +00:00
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/databricks/databricks-sdk-go/service/jobs"
|
|
|
|
)
|
|
|
|
|
|
|
|
type JobProgressEvent struct {
|
2023-04-18 12:40:45 +00:00
|
|
|
Timestamp time.Time `json:"timestamp"`
|
|
|
|
JobId int64 `json:"job_id"`
|
|
|
|
RunId int64 `json:"run_id"`
|
|
|
|
RunName string `json:"run_name"`
|
|
|
|
State jobs.RunState `json:"state"`
|
2023-03-29 12:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (event *JobProgressEvent) String() string {
|
|
|
|
result := strings.Builder{}
|
2023-04-18 12:40:45 +00:00
|
|
|
result.WriteString(event.Timestamp.Format("2006-01-02 15:04:05") + " ")
|
|
|
|
result.WriteString(fmt.Sprintf(`"%s"`, event.RunName) + " ")
|
|
|
|
result.WriteString(event.State.LifeCycleState.String() + " ")
|
2023-03-29 12:58:09 +00:00
|
|
|
if event.State.ResultState.String() != "" {
|
2023-04-18 12:40:45 +00:00
|
|
|
result.WriteString(event.State.ResultState.String() + " ")
|
2023-03-29 12:58:09 +00:00
|
|
|
}
|
|
|
|
result.WriteString(event.State.StateMessage)
|
|
|
|
return result.String()
|
|
|
|
}
|
2023-04-18 12:20:35 +00:00
|
|
|
|
|
|
|
func (event *JobProgressEvent) IsInplaceSupported() bool {
|
|
|
|
return true
|
|
|
|
}
|