feat: expose timeout variables (#622)

* expose timeout variables

* formatting

Former-commit-id: eeae790fe4
This commit is contained in:
Hayden 2023-11-15 21:17:43 -06:00 committed by GitHub
parent e3ddc68eb2
commit 79be938531
7 changed files with 21 additions and 13 deletions

View file

@ -167,7 +167,6 @@ func (ctrl *V1Controller) HandleItemUpdate() errchain.HandlerFunc {
return adapters.ActionID("id", fn, http.StatusOK) return adapters.ActionID("id", fn, http.StatusOK)
} }
// HandleItemPatch godocs // HandleItemPatch godocs
// //
// @Summary Update Item // @Summary Update Item
@ -183,12 +182,12 @@ func (ctrl *V1Controller) HandleItemPatch() errchain.HandlerFunc {
auth := services.NewContext(r.Context()) auth := services.NewContext(r.Context())
body.ID = ID body.ID = ID
err := ctrl.repo.Items.Patch(auth, auth.GID, ID, body) err := ctrl.repo.Items.Patch(auth, auth.GID, ID, body)
if err != nil { if err != nil {
return repo.ItemOut{}, err return repo.ItemOut{}, err
} }
return ctrl.repo.Items.GetOneByGroup(auth, auth.GID, ID) return ctrl.repo.Items.GetOneByGroup(auth, auth.GID, ID)
} }
return adapters.ActionID("id", fn, http.StatusOK) return adapters.ActionID("id", fn, http.StatusOK)

View file

@ -146,6 +146,9 @@ func run(cfg *config.Config) error {
app.server = server.NewServer( app.server = server.NewServer(
server.WithHost(app.conf.Web.Host), server.WithHost(app.conf.Web.Host),
server.WithPort(app.conf.Web.Port), server.WithPort(app.conf.Web.Port),
server.WithReadTimeout(app.conf.Web.ReadTimeout),
server.WithWriteTimeout(app.conf.Web.WriteTimeout),
server.WithIdleTimeout(app.conf.Web.IdleTimeout),
) )
log.Info().Msgf("Starting HTTP Server on %s:%s", app.server.Host, app.server.Port) log.Info().Msgf("Starting HTTP Server on %s:%s", app.server.Host, app.server.Port)

View file

@ -51,7 +51,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
v1Ctrl := v1.NewControllerV1( v1Ctrl := v1.NewControllerV1(
a.services, a.services,
a.repos, a.repos,
a.bus, a.bus,
v1.WithMaxUploadSize(a.conf.Web.MaxUploadSize), v1.WithMaxUploadSize(a.conf.Web.MaxUploadSize),
v1.WithRegistration(a.conf.Options.AllowRegistration), v1.WithRegistration(a.conf.Options.AllowRegistration),
v1.WithDemoStatus(a.conf.Demo), // Disable Password Change in Demo Mode v1.WithDemoStatus(a.conf.Demo), // Disable Password Change in Demo Mode
@ -92,7 +92,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
r.Post(v1Base("/actions/ensure-asset-ids"), chain.ToHandlerFunc(v1Ctrl.HandleEnsureAssetID(), userMW...)) r.Post(v1Base("/actions/ensure-asset-ids"), chain.ToHandlerFunc(v1Ctrl.HandleEnsureAssetID(), userMW...))
r.Post(v1Base("/actions/zero-item-time-fields"), chain.ToHandlerFunc(v1Ctrl.HandleItemDateZeroOut(), userMW...)) r.Post(v1Base("/actions/zero-item-time-fields"), chain.ToHandlerFunc(v1Ctrl.HandleItemDateZeroOut(), userMW...))
r.Post(v1Base("/actions/ensure-import-refs"), chain.ToHandlerFunc(v1Ctrl.HandleEnsureImportRefs(), userMW...)) r.Post(v1Base("/actions/ensure-import-refs"), chain.ToHandlerFunc(v1Ctrl.HandleEnsureImportRefs(), userMW...))
r.Post(v1Base("/actions/set-primary-photos"), chain.ToHandlerFunc(v1Ctrl.HandleSetPrimaryPhotos(), userMW...)) r.Post(v1Base("/actions/set-primary-photos"), chain.ToHandlerFunc(v1Ctrl.HandleSetPrimaryPhotos(), userMW...))
r.Get(v1Base("/locations"), chain.ToHandlerFunc(v1Ctrl.HandleLocationGetAll(), userMW...)) r.Get(v1Base("/locations"), chain.ToHandlerFunc(v1Ctrl.HandleLocationGetAll(), userMW...))
r.Post(v1Base("/locations"), chain.ToHandlerFunc(v1Ctrl.HandleLocationCreate(), userMW...)) r.Post(v1Base("/locations"), chain.ToHandlerFunc(v1Ctrl.HandleLocationCreate(), userMW...))

View file

@ -38,7 +38,7 @@ func New() *EventBus {
subscribers: map[Event][]func(any){ subscribers: map[Event][]func(any){
EventLabelMutation: {}, EventLabelMutation: {},
EventLocationMutation: {}, EventLocationMutation: {},
EventItemMutation: {}, EventItemMutation: {},
}, },
} }
} }

View file

@ -13,8 +13,8 @@ import (
) )
var ( var (
fk = faker.NewFaker() fk = faker.NewFaker()
tbus = eventbus.New() tbus = eventbus.New()
tClient *ent.Client tClient *ent.Client
tRepos *AllRepos tRepos *AllRepos
@ -45,7 +45,7 @@ func TestMain(m *testing.M) {
log.Fatalf("failed opening connection to sqlite: %v", err) log.Fatalf("failed opening connection to sqlite: %v", err)
} }
go tbus.Run() go tbus.Run()
err = client.Schema.Create(context.Background()) err = client.Schema.Create(context.Background())
if err != nil { if err != nil {

View file

@ -36,9 +36,12 @@ type DebugConf struct {
} }
type WebConfig struct { type WebConfig struct {
Port string `yaml:"port" conf:"default:7745"` Port string `yaml:"port" conf:"default:7745"`
Host string `yaml:"host"` Host string `yaml:"host"`
MaxUploadSize int64 `yaml:"max_file_upload" conf:"default:10"` MaxUploadSize int64 `yaml:"max_file_upload" conf:"default:10"`
ReadTimeout int `yaml:"read_timeout" conf:"default:10"`
WriteTimeout int `yaml:"write_timeout" conf:"default:10"`
IdleTimeout int `yaml:"idle_timeout" conf:"default:30"`
} }
// New parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, the // New parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, the

View file

@ -62,6 +62,9 @@ volumes:
| HBOX_OPTIONS_ALLOW_REGISTRATION | true | allow users to register themselves | | HBOX_OPTIONS_ALLOW_REGISTRATION | true | allow users to register themselves |
| HBOX_OPTIONS_AUTO_INCREMENT_ASSET_ID | true | auto increments the asset_id field for new items | | HBOX_OPTIONS_AUTO_INCREMENT_ASSET_ID | true | auto increments the asset_id field for new items |
| HBOX_WEB_MAX_UPLOAD_SIZE | 10 | maximum file upload size supported in MB | | HBOX_WEB_MAX_UPLOAD_SIZE | 10 | maximum file upload size supported in MB |
| HBOX_WEB_READ_TIMEOUT | 10 | Read timeout of HTTP sever |
| HBOX_WEB_WRITE_TIMEOUT | 10 | Write timeout of HTTP server |
| HBOX_WEB_IDLE_TIMEOUT | 30 | Idle timeout of HTTP server |
| HBOX_STORAGE_DATA | /data/ | path to the data directory, do not change this if you're using docker | | HBOX_STORAGE_DATA | /data/ | path to the data directory, do not change this if you're using docker |
| HBOX_STORAGE_SQLITE_URL | /data/homebox.db?_fk=1 | sqlite database url, if you're using docker do not change this | | HBOX_STORAGE_SQLITE_URL | /data/homebox.db?_fk=1 | sqlite database url, if you're using docker do not change this |
| HBOX_LOG_LEVEL | info | log level to use, can be one of: trace, debug, info, warn, error, critical | | HBOX_LOG_LEVEL | info | log level to use, can be one of: trace, debug, info, warn, error, critical |