Skip to content

Commit

Permalink
WIP #459
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-r-west committed Aug 10, 2024
1 parent 3728462 commit e3eb73b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ func InitializeCmd() {
RootCmd.PersistentFlags().BoolVarP(&httpclient.Retry429, "retry-429", "", false, "Whether we should retry requests with HTTP 429 response code")
RootCmd.PersistentFlags().BoolVarP(&httpclient.RetryConnectionErrors, "retry-connection-errors", "", false, "Whether we should retry requests with connection errors")
RootCmd.PersistentFlags().UintVarP(&httpclient.RetryDelay, "retry-delay", "", 500, "When retrying how long should we delay")
RootCmd.PersistentFlags().BoolVarP(&httpclient.RetryAllErrors, "retry-all-errors", "", false, "When enable retries on all errors (i.e., the same as --retry-5xx --retry-429 and --retry-connection-errors")
RootCmd.PersistentFlags().BoolVarP(&httpclient.RetryAllErrors, "retry-all-errors", "", false, "When enable retries on all errors (i.e., the same as --retry-5xx, --retry-4xx and --retry-connection-errors")
RootCmd.PersistentFlags().BoolVarP(&httpclient.RetryTemporaryErrors, "retry-temporary-errors", "", false, "When enable retries on all errors (i.e., the same as --retry-5xx --retry-429 and --retry-connection-errors")

RootCmd.PersistentFlags().BoolVarP(&httpclient.DontLog2xxs, "silence-2xx", "", false, "Whether we should silence HTTP 2xx response code logging")

Expand Down
7 changes: 7 additions & 0 deletions external/httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ var Retry5xx = false
var RetryConnectionErrors = false

var RetryAllErrors = false
var RetryTemporaryErrors = false
var Retry422 = false

var RetryDelay uint = 500

var statsLock = &sync.Mutex{}
Expand Down Expand Up @@ -378,6 +381,10 @@ func doRequestInternal(ctx context.Context, method string, contentType string, p
displayLongFormRequestAndResponse = false
}

if resp.StatusCode == 422 && Retry422 {
displayLongFormRequestAndResponse = false
}

if resp.StatusCode >= 500 && Retry5xx {
displayLongFormRequestAndResponse = false
}
Expand Down
4 changes: 2 additions & 2 deletions external/runbooks/pxm-how-to.epcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ actions:
epcc create pcm-product-price name=Preferred_Pricing currencies.USD.amount 300000 currencies.USD.includes_tax false currencies.GBP.amount 250000 currencies.GBP.includes_tax false sku BE-Electric-Range-1a1a
epcc create pcm-product-price name=Preferred_Pricing currencies.USD.amount 350000 currencies.USD.includes_tax false currencies.GBP.amount 300000 currencies.GBP.includes_tax false sku BE-Gas-Range-2b2b
- epcc create pcm-catalog name "Ranges Catalog" description "Ranges Catalog" pricebook_id name=Preferred_Pricing hierarchy_ids[0] name=Major_Appliances
- epcc create pcm-catalog-release --save-as-alias pxm-how-to-create-catalog-and-publish-release name=Ranges_Catalog
- epcc create pcm-catalog-release --retry-while-jq '.errors[0].status == 422' --save-as-alias pxm-how-to-create-catalog-and-publish-release name=Ranges_Catalog
# Wait for Catalog to be Published
- epcc get pcm-catalog-release --retry-while-jq '.data.meta.release_status != "PUBLISHED"' name=Ranges_Catalog pxm-how-to-create-catalog-and-publish-release
create-catalog-rule:
Expand Down Expand Up @@ -105,7 +105,7 @@ actions:
- epcc create pcm-product attributes.name "SKU-less Bed and Ball Bundle" attributes.commodity_type "physical" status "live" components.dogbed.max 1 components.dogbed.min 1 components.dogbed.name "Dog Bed" components.dogbed.options[0].id alias/product/name=Fluffy_Bed/id components.dogbed.options[0].type "product" components.dogbed.options[0].quantity 1 components.dogball.max 1 components.dogball.min 1 components.dogball.name "Dog Ball" components.dogball.options[0].id alias/product/name=Squeaky_Ball/id components.dogball.options[0].type "product" components.dogball.options[0].quantity 1
- epcc create pcm-node-product name=Pet_Supplies name=Dog_Supplies data[0].type product data[0].id name=SKU-less_Bed_and_Ball_Bundle
- epcc create pcm-catalog name "Pet Supplies Catalog" description "Pet Supplies Catalog" pricebook_id name=VIP_Pricing hierarchy_ids[0] name=Pet_Supplies
- epcc create pcm-catalog-release name=Pet_Supplies_Catalog --save-as-alias pxm-how-to-publish-catalog-with-bundles-release
- epcc create pcm-catalog-release --retry-while-jq '.errors[0].status == 422' name=Pet_Supplies_Catalog --save-as-alias pxm-how-to-publish-catalog-with-bundles-release
# Wait for Catalog to be Published
- epcc get pcm-catalog-release --retry-while-jq '.data.meta.release_status != "PUBLISHED"' name=Pet_Supplies_Catalog pxm-how-to-publish-catalog-with-bundles-release

Expand Down

0 comments on commit e3eb73b

Please sign in to comment.