-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a2fb83
commit 59f626c
Showing
44 changed files
with
3,148 additions
and
2,538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package apis | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/samuelncui/yatm/entity" | ||
) | ||
|
||
func (api *API) JobEditState(ctx context.Context, req *entity.JobEditStateRequest) (*entity.JobEditStateReply, error) { | ||
job, err := api.exe.GetJob(ctx, req.Id) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if job == nil { | ||
return nil, fmt.Errorf("job not found, id= %d", req.Id) | ||
} | ||
|
||
if job.Status == entity.JobStatus_PROCESSING { | ||
return nil, fmt.Errorf("job status 'PROCESSING' is unexpected") | ||
} | ||
if req.Status != nil { | ||
if *req.Status == entity.JobStatus_PROCESSING { | ||
return nil, fmt.Errorf("job target status 'PROCESSING' is unexpected") | ||
} | ||
job.Status = *req.Status | ||
} | ||
|
||
job.State = req.State | ||
if _, err := api.exe.SaveJob(ctx, job); err != nil { | ||
return nil, fmt.Errorf("save job fail, %w", err) | ||
} | ||
|
||
executor, err := api.exe.GetJobExecutor(ctx, job.ID) | ||
if err != nil { | ||
return nil, fmt.Errorf("get job executor fail, %w", err) | ||
} | ||
|
||
if err := executor.Close(ctx); err != nil { | ||
return nil, fmt.Errorf("close job executor fail, %w", err) | ||
} | ||
|
||
return &entity.JobEditStateReply{}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.