-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove logrus and add new interfaces for worker #155
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added few suggestions
////worker := worker.NewWorker("hello", ProcessBody) | ||
// | ||
////taskClient := client.NewTaskClient(apiClient) | ||
////workerFn, _ := worker.GetWorker(ProcessBody) | ||
////_ = taskRunner.StartWorker2("hello", workerFn, 1, 1) | ||
// | ||
//opts := &client.TaskResourceApiBatchPollOpts{} | ||
//tasks, _, err := taskClient.BatchPollTask(context.Background(), "hello", opts) | ||
////task := model.PolledTask{ | ||
//// TaskType: "abcd", | ||
//// InputData: "{}", | ||
//// OutputData: "{}", | ||
////} | ||
//if err != nil { | ||
// fmt.Println("Got error ", err.Error()) | ||
//} | ||
//fmt.Println("Got", len(tasks)) | ||
|
||
//for i := range tasks { | ||
// fmt.Println("Task.Id", tasks[i].TaskId) | ||
// res, err := te.Execute(&tasks[i]) | ||
// if err != nil { | ||
// fmt.Println("Error executing process body ", err.Error()) | ||
// } else { | ||
// fmt.Println("Response of process body", res) | ||
// } | ||
//} | ||
|
||
//data, _ := json.Marshal(task.InputData) | ||
//jsons := string(data) | ||
//fmt.Println(jsons) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this commented code ?
func (task *PolledTask) ToValue(newValue any) (interface{}, error) { | ||
|
||
bytes, err := task.InputData.MarshalJSON() | ||
if err != nil { | ||
return nil, err | ||
} | ||
err = json.Unmarshal(bytes, newValue) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return newValue, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly unmarshalling task.InputData into newValue
func (task *PolledTask) ToValue(newValue any) (interface{}, error) { | |
bytes, err := task.InputData.MarshalJSON() | |
if err != nil { | |
return nil, err | |
} | |
err = json.Unmarshal(bytes, newValue) | |
if err != nil { | |
return nil, err | |
} | |
return newValue, nil | |
} | |
func (task *PolledTask) ToValue(newValue interface{}) (interface{}, error) { | |
err := json.Unmarshal(task.InputData, newValue) | |
if err != nil { | |
return nil, err | |
} | |
return newValue, nil | |
} |
func authSettings() *settings.AuthenticationSettings { | ||
key := "api_key_user_03" | ||
secret := "api_key_user_03" | ||
if key != "" && secret != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we be replacing the key and secret somewhere, else can ignore the checks
sdk/main/main.go
Outdated
func ProcessBody(body *Data) (*Data, error) { | ||
if body == nil { | ||
fmt.Println("Body is nil") | ||
return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: error standardization maybe in some common file
@@ -17,6 +17,7 @@ import ( | |||
"encoding/xml" | |||
"errors" | |||
"fmt" | |||
"github.com/conductor-sdk/conductor-go/sdk/log" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: linters could be introduced.
} | ||
|
||
func ProcessBody2(task *model.Task) (interface{}, error) { | ||
fmt.Println("executing", task.TaskId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: usage of logs instead of print with the correct log level to help in debugging later
"github.com/conductor-sdk/conductor-go/sdk/worker" | ||
) | ||
|
||
type Restaurant struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused struct
Co-authored-by: Shailesh Padave <shaileshpadave49@gmail.com>
Co-authored-by: Shailesh Padave <shaileshpadave49@gmail.com>
Co-authored-by: Shailesh Padave <shaileshpadave49@gmail.com>
No description provided.