package api import ( "time" "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/api/errs" ) type DebugStage struct { DebugEvent `json:",inline"` Events []*DebugEvent `json:"events"` } type DebugEvent struct { ID string `json:"id"` Type string `json:"type"` Status string `json:"status"` Created int64 `json:"created"` Error *errs.Error `json:"error"` Data interface{} `json:"data"` } type DebugTaks struct { ID string `json:"id"` Status string `json:"status"` Created int64 `json:"created"` Stages []*DebugStage `json:"stages"` CurrentStage *DebugStage `json:"-"` } func NewDebugTaks() *DebugTaks { return &DebugTaks{ Stages: []*DebugStage{}, CurrentStage: &DebugStage{}, } } func (debug *DebugTaks) Stage(id string) *DebugStage { stage := &DebugStage{} stage.ID = id debug.CurrentStage = stage return stage } func (stage *DebugStage) PushEvent(event *DebugEvent) { stage.Events = append(stage.Events, event) } func (debug *DebugTaks) Event(eventType, eventId string) *DebugEvent { event := &DebugEvent{ ID: eventId, Type: eventType, Created: time.Now().Unix(), } debug.CurrentStage.PushEvent(event) return event } func (debug *DebugTaks) Finalize() { return }