Skip to content

Commit

Permalink
Merge pull request #30 from permitio/raz/per-8524-add-configurable-ti…
Browse files Browse the repository at this point in the history
…meout-to-golang-sdk-and-terraform

add WithTimeout to our config builder
  • Loading branch information
RazcoDev authored Dec 6, 2023
2 parents 6124a87 + 6f6138a commit a27d3d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/config/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewConfigBuilder(token string) *PermitBuilder {
debug: DefaultDebugMode,
Context: nil,
Logger: nil,
httpClient: &http.Client{Timeout: time.Second * 5},
httpClient: &http.Client{Timeout: DefaultTimeout},
},
}
}
Expand Down Expand Up @@ -54,6 +54,11 @@ func (c *PermitConfig) WithContext(context *PermitContext) *PermitConfig {
return c
}

func (c *PermitConfig) WithTimeout(timeout time.Duration) *PermitConfig {
c.httpClient.Timeout = timeout
return c
}

func (c *PermitConfig) WithLogger(logger *zap.Logger) *PermitConfig {
c.Logger = logger
return c
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/consts.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package config

import "time"

// Default Builder consts
const (
DefaultApiUrl = "https://api.permit.io"
DefaultDebugMode = false
DefaultPdpUrl = "http://localhost:7766"
DefaultOpaUrl = "http://localhost:8181"

DefaultTimeout = time.Second * 5
)

0 comments on commit a27d3d6

Please sign in to comment.