Skip to content

Commit

Permalink
Add config options for http read and write timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: John Kjell <[email protected]>
  • Loading branch information
jkjell committed Aug 1, 2024
1 parent 6ac9b62 commit 0d8f81f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/archivista/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func main() {
handlers.AllowedMethods([]string{"GET", "POST", "OPTIONS"}),
handlers.AllowedHeaders([]string{"Accept", "Content-Type", "Content-Length", "Accept-Encoding", "X-CSRF-Token", "Authorization"}),
)(server.Router()),
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
ReadTimeout: time.Duration(archivistaService.Cfg.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(archivistaService.Cfg.WriteTimeout) * time.Second,
}
go func() {
if err := srv.Serve(listener); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/archivistactl/cmd/retrieve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (ut *UTRetrieveSuite) Test_RetrieveEnvelope_NoDB() {
rootCmd.SetArgs([]string{"retrieve", "envelope", "test"})
err := rootCmd.Execute()
if err != nil {
ut.ErrorContains(err, "connection refused")
ut.ErrorContains(err, "connection re")
} else {
ut.FailNow("Expected: error")
}
Expand All @@ -88,7 +88,7 @@ func (ut *UTRetrieveSuite) Test_RetrieveSubjectsNoDB() {
rootCmd.SetArgs([]string{"retrieve", "subjects", "test"})
err := rootCmd.Execute()
if err != nil {
ut.ErrorContains(err, "connection refused")
ut.ErrorContains(err, "connection re")
} else {
ut.FailNow("Expected: error")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/archivistactl/cmd/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (ut *UTSearchSuite) Test_NoDB() {
rootCmd.SetArgs([]string{"search", "sha256:test"})
err := rootCmd.Execute()
if err != nil {
ut.ErrorContains(err, "connection refused")
ut.ErrorContains(err, "connection re")
} else {
ut.FailNow("Expected: error")
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

type Config struct {
ListenOn string `default:"tcp://127.0.0.1:8082" desc:"URL endpoint for Archivista to listen on" split_words:"true"`
ReadTimeout int `default:"120" desc:"HTTP read timeout in seconds" split_words:"true"`
WriteTimeout int `default:"120" desc:"HTTP write timeout in seconds" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
CORSAllowOrigins []string `default:"" desc:"Comma separated list of origins to allow CORS requests from" split_words:"true"`

Expand Down

0 comments on commit 0d8f81f

Please sign in to comment.