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

feat: put 30 seconds as default client time out #39

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TestClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
retryMaxElapsedTimeMinutes := 2

// validate inputs
errorsInInputs := utils.ValidateInputs(clientId, clientSecret, apiUrl, clientTimeOutInSeconds, &separator, verifyCa, zapLogger, certificate, certificateKey)
errorsInInputs := utils.ValidateInputs(clientId, clientSecret, apiUrl, clientTimeOutInSeconds, &separator, verifyCa, zapLogger, certificate, certificateKey, &retryMaxElapsedTimeMinutes)

if errorsInInputs != nil {
return
Expand Down
10 changes: 8 additions & 2 deletions api/utils/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ type UserInputValidaton struct {
ClientId string `validate:"required,min=36,max=36"`
ClientSecret string `validate:"required,min=36,max=64"`
ApiUrl string `validate:"required,http_url"`
ClientTimeOutinSeconds int `validate:"gte=1,lte=301"`
ClientTimeOutinSeconds int `validate:"gte=1,lte=300"`
Separator string `validate:"required,min=1,max=1"`
VerifyCa bool `validate:"required"`
}

var validate *validator.Validate

// ValidateInputs is responsible for validating end-user inputs.
func ValidateInputs(clientId string, clientSecret string, apiUrl string, clientTimeOutinSeconds int, separator *string, verifyCa bool, logger logging.Logger, certificate string, certificate_key string) error {
func ValidateInputs(clientId string, clientSecret string, apiUrl string, clientTimeOutinSeconds int, separator *string, verifyCa bool, logger logging.Logger, certificate string, certificate_key string, retryMaxElapsedTimeMinutes *int) error {

if clientTimeOutinSeconds == 0 {
clientTimeOutinSeconds = 30
*retryMaxElapsedTimeMinutes = 2
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to also check the retryMaxElapsedTimeMinutes

if retryMaxElapsedTimeMinutes == 0 {
retryMaxElapsedTimeMinutes = 2
{

Copy link
Contributor Author

Choose a reason for hiding this comment

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


}

validate = validator.New(validator.WithRequiredStructEnabled())

Expand Down
Loading