MCPcopy
hub / github.com/wavetermdev/waveterm / GetBlockJobStatus

Function GetBlockJobStatus

pkg/jobcontroller/jobcontroller.go:171–218  ·  view source on GitHub ↗
(ctx context.Context, blockId string)

Source from the content-addressed store, hash-verified

169}
170
171func GetBlockJobStatus(ctx context.Context, blockId string) (*wshrpc.BlockJobStatusData, error) {
172 block, err := wstore.DBGet[*waveobj.Block](ctx, blockId)
173 if err != nil {
174 return nil, fmt.Errorf("failed to get block: %w", err)
175 }
176 if block == nil {
177 return nil, fmt.Errorf("block not found: %s", blockId)
178 }
179
180 data := &wshrpc.BlockJobStatusData{
181 BlockId: blockId,
182 VersionTs: blockJobStatusVersion.GetVersionTs(),
183 }
184
185 if block.JobId == "" {
186 return data, nil
187 }
188
189 job, err := wstore.DBGet[*waveobj.Job](ctx, block.JobId)
190 if err != nil {
191 return nil, fmt.Errorf("failed to get job: %w", err)
192 }
193 if job == nil {
194 return data, nil
195 }
196
197 data.JobId = job.OID
198 data.DoneReason = job.JobManagerDoneReason
199 data.StartupError = job.JobManagerStartupError
200 data.CmdExitTs = job.CmdExitTs
201 data.CmdExitCode = job.CmdExitCode
202 data.CmdExitSignal = job.CmdExitSignal
203
204 if job.JobManagerStatus == JobManagerStatus_Init {
205 data.Status = "init"
206 } else if job.JobManagerStatus == JobManagerStatus_Done {
207 data.Status = "done"
208 } else if job.JobManagerStatus == JobManagerStatus_Running {
209 connStatus := GetJobConnStatus(job.OID)
210 if connStatus == JobConnStatus_Connected {
211 data.Status = "connected"
212 } else {
213 data.Status = "disconnected"
214 }
215 }
216
217 return data, nil
218}
219
220func SendBlockJobStatusEvent(ctx context.Context, blockId string) {
221 data, err := GetBlockJobStatus(ctx, blockId)

Callers 2

BlockJobStatusCommandMethod · 0.92
SendBlockJobStatusEventFunction · 0.85

Calls 3

DBGetFunction · 0.92
GetJobConnStatusFunction · 0.85
GetVersionTsMethod · 0.80

Tested by

no test coverage detected