Skip to content

Commit

Permalink
Add debug mode for activity (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng authored Aug 18, 2023
1 parent 696223a commit 9a0f801
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ type (
)

const (
EnvNameDebugMode = "DEBUG_MODE"

DefaultContinueAsNewPageSizeInBytes = 1024 * 1024

// HttpStatusCodeSpecial4xxError is a special deprecated code for this because I can't find an official one for this case
Expand Down
10 changes: 10 additions & 0 deletions service/interpreter/activityImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/indeedeng/iwf/service/interpreter/env"
"io/ioutil"
"net/http"
"os"
)

// StateStart is Deprecated, will be removed in next release
Expand Down Expand Up @@ -39,6 +40,7 @@ func StateApiWaitUntil(ctx context.Context, backendType service.BackendType, inp

req := apiClient.DefaultApi.ApiV1WorkflowStateStartPost(ctx)
resp, httpResp, err := req.WorkflowStateStartRequest(input.Request).Execute()
printDebugMsg(logger, err, iwfWorkerBaseUrl)
if checkHttpError(err, httpResp) {
return nil, composeHttpError(provider, err, httpResp, string(iwfidl.STATE_API_FAIL_MAX_OUT_RETRY_ERROR_TYPE))
}
Expand Down Expand Up @@ -76,12 +78,20 @@ func StateApiExecute(ctx context.Context, backendType service.BackendType, input

req := apiClient.DefaultApi.ApiV1WorkflowStateDecidePost(ctx)
resp, httpResp, err := req.WorkflowStateDecideRequest(input.Request).Execute()
printDebugMsg(logger, err, iwfWorkerBaseUrl)
if checkHttpError(err, httpResp) {
return nil, composeHttpError(provider, err, httpResp, string(iwfidl.STATE_API_FAIL_MAX_OUT_RETRY_ERROR_TYPE))
}
return resp, nil
}

func printDebugMsg(logger UnifiedLogger, err error, url string) {
debugMode := os.Getenv(service.EnvNameDebugMode)
if debugMode != "" {
logger.Info("check error at http request", err, url)
}
}

func composeStartApiRespError(provider ActivityProvider, err error, resp *iwfidl.WorkflowStateStartResponse) error {
respStr, _ := resp.MarshalJSON()
return provider.NewApplicationError(string(iwfidl.STATE_API_FAIL_MAX_OUT_RETRY_ERROR_TYPE),
Expand Down

0 comments on commit 9a0f801

Please sign in to comment.