Skip to content

Commit

Permalink
Feature: Add channel to receive flag
Browse files Browse the repository at this point in the history
Signed-off-by: JeffMboya <[email protected]>
  • Loading branch information
JeffMboya committed Jun 9, 2024
1 parent 1ab1b55 commit 8321521
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/sdk/go/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ type Config struct {

// / NewSDK returns new magistrala SDK instance.
func NewSDK(conf Config) SDK {
return &mgSDK{
sdk := &mgSDK{
bootstrapURL: conf.BootstrapURL,
certsURL: conf.CertsURL,
httpAdapterURL: conf.HTTPAdapterURL,
Expand All @@ -1213,8 +1213,18 @@ func NewSDK(conf Config) SDK {
},
},
curlFlag: conf.CurlFlag,
curlFlagChan: make(chan string),
curlFlagChan: make(chan string, 1),
}

if sdk.curlFlag {
go func() {
for curlCommand := range sdk.curlFlagChan {
fmt.Println(curlCommand)
}
}()
}

return sdk
}

// processRequest creates and send a new HTTP request, and checks for errors in the HTTP response.
Expand Down Expand Up @@ -1244,7 +1254,7 @@ func (sdk *mgSDK) processRequest(method, reqUrl, token string, data []byte, head
return nil, nil, nil
}
sdk.curlFlagChan <- curlCommand.String()
return nil, nil, nil
return make(http.Header), []byte("{}"), nil
}

resp, err := sdk.client.Do(req)
Expand Down

0 comments on commit 8321521

Please sign in to comment.