hatchet
hatchet copied to clipboard
Need help with transfer data between step
Hi i am just read about hatchet to day and i want to apply it to my current project in my project i have a api that will connect to theartconnect and get then call api of it to get data i try to make it in to 2 step with hatchet :
-
fist make the connection
-
call and get the list data but at the fist step i can seem to transfer my theartconnect connection struct to the secon step here my struct
type ThreatConnectService struct { client *http.Client baseURL string apiToken string }
and here how i transfer
{ Function: func(ctx worker.HatchetContext, event *types.TestEvent) (*types.StepResponse, error) {
threatConnectService := services.NewThreatConnectService(
"url ", "token")
fmt.Println("ThreatConnectService:", threatConnectService) // i see my data with full info
return &types.StepResponse{
Message: "connect to threat connect",
Data: map[string]interface{}{
"threatConnectService": threatConnectService,
"abc": "abc",
},
}, nil
},
Name: "first-step",
},
and here how i get in the next step :
{
Parents: []string{"second-step"},
Function: func(ctx worker.HatchetContext, event *types.TestEvent) (*types.StepResponse, error) {
// Get the result from the second step
var data types.StepResponse
err := ctx.StepOutput("second-step", &data)
// my data.Data["threatConnectService"] get change to empty map[string]interface{} it seem that work find with the
string but can not pass the stuct
fmt.Printf("Type of data.Data[\"threatConnectService\"]: %T\n", data.Data["threatConnectService"])
}
can any one know how to transfer struct and data between step or i did some thing wrong please help