feat: move task creation into separate method
This commit is contained in:
parent
1bbbda5385
commit
4eb11030b8
14
sati.go
14
sati.go
@ -28,9 +28,19 @@ type Api struct {
|
|||||||
socket *socket
|
socket *socket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Api) CreateTask(task AnyTask) (*CreateTaskResult, error) {
|
||||||
|
result := &CreateTaskResult{}
|
||||||
|
|
||||||
|
if err := a.socket.call("createTask", task.serialize(), result); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Api) Solve(task AnyTask, result any) (*TaskEntity, error) {
|
func (a *Api) Solve(task AnyTask, result any) (*TaskEntity, error) {
|
||||||
createdTask := CreateTaskResult{}
|
createdTask, err := a.CreateTask(task)
|
||||||
if err := a.socket.call("createTask", task.serialize(), &createdTask); err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user