Skip to content
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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

v1r3n
Copy link
Member

@v1r3n v1r3n commented Oct 20, 2024

No description provided.

Copy link

@shaileshpadave shaileshpadave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added few suggestions

sdk/log/logger.go Outdated Show resolved Hide resolved
sdk/main/main.go Outdated Show resolved Hide resolved
sdk/main/main.go Outdated Show resolved Hide resolved
Comment on lines +124 to +154
////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)

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 ?

Comment on lines +60 to +71
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
}

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

Suggested change
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 != "" {

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

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"

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)

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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused struct

v1r3n and others added 3 commits December 17, 2024 21:17
Co-authored-by: Shailesh Padave <shaileshpadave49@gmail.com>
Co-authored-by: Shailesh Padave <shaileshpadave49@gmail.com>
Co-authored-by: Shailesh Padave <shaileshpadave49@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants