changes required to convert to Echo v5 #7

Merged
amy merged 5 commits from echo5-update into main 2026-05-03 14:59:50 -06:00
3 changed files with 20 additions and 8 deletions
Showing only changes of commit 53ee2281bc - Show all commits
+8 -3
View File
@@ -167,7 +167,12 @@ type AmConfig struct {
} `yaml:"posting"` } `yaml:"posting"`
Tuning struct { Tuning struct {
WorkerTasks int `yaml:"workerTasks"` WorkerTasks int `yaml:"workerTasks"`
Queues struct { Timeouts struct {
HttpRead int `yaml:"httpRead"`
HttpWrite int `yaml:"httpWrite"`
HttpIdle int `yaml:"httpIdle"`
} `yaml:"timeouts"`
Queues struct {
AuditWrites int `yaml:"auditWrites"` AuditWrites int `yaml:"auditWrites"`
ContextRecycle int `yaml:"contextRecycle"` ContextRecycle int `yaml:"contextRecycle"`
EmailRecycle int `yaml:"emailRecycle"` EmailRecycle int `yaml:"emailRecycle"`
@@ -200,7 +205,7 @@ func (c *AmConfig) ExPath(path string) string {
return filepath.Join(c.baseDir, path) return filepath.Join(c.baseDir, path)
} }
// AmConfigComputed is the configuration values which are "computed" based only on values in AmConfig. // AmConfigComputed is the configuration values which are "computed" based only on values in AmConfig and CommandLine.
type AmConfigComputed struct { type AmConfigComputed struct {
DebugMode bool // are we in debug mode? DebugMode bool // are we in debug mode?
LogLevel string // the logging level LogLevel string // the logging level
@@ -321,7 +326,7 @@ func overlayStructValue(dest, loaded, defaults reflect.Value) {
} }
} else { } else {
// if we see this message, this function needs more work // if we see this message, this function needs more work
log.Errorf("*** unable to deal with field %s of type %s", structField.Name, typ.Name()) log.Fatalf("*** unable to deal with field %s of type %s", structField.Name, typ.Name())
} }
} }
} }
+4
View File
@@ -91,6 +91,10 @@ posting:
- "image/png" - "image/png"
tuning: tuning:
workerTasks: 4 workerTasks: 4
timeouts:
httpRead: 30
httpWrite: 30
httpIdle: 120
queues: queues:
auditWrites: 16 auditWrites: 16
contextRecycle: 16 contextRecycle: 16
+8 -5
View File
@@ -37,6 +37,9 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
// READ_HEADER_TIMEOUT is the timeout value for reading headers in seconds. (Deliberately NOT configurable because this is a security issue)
const READ_HEADER_TIMEOUT = 2
// GetAndPost is used to have functions that respond to both GET and POST on a URI. // GetAndPost is used to have functions that respond to both GET and POST on a URI.
var GetAndPost = []string{http.MethodGet, http.MethodPost} var GetAndPost = []string{http.MethodGet, http.MethodPost}
@@ -214,7 +217,7 @@ func setupEcho() *echo.Echo {
// ampool is the worker pool for one-shot background tasks. // ampool is the worker pool for one-shot background tasks.
var ampool *util.WorkerPool var ampool *util.WorkerPool
// SystemStartTime records the time since the system was started. // SystemStartTime records the time the system was started.
var SystemStartTime time.Time var SystemStartTime time.Time
// main is Ye Olde Main Function. // main is Ye Olde Main Function.
@@ -273,10 +276,10 @@ func main() {
log.Fatalf("error in shutting down the server: %v", err) log.Fatalf("error in shutting down the server: %v", err)
}, },
BeforeServeFunc: func(s *http.Server) error { BeforeServeFunc: func(s *http.Server) error {
s.ReadTimeout = 30 * time.Second s.ReadTimeout = time.Duration(config.GlobalConfig.Tuning.Timeouts.HttpRead) * time.Second
s.WriteTimeout = 30 * time.Second s.WriteTimeout = time.Duration(config.GlobalConfig.Tuning.Timeouts.HttpWrite) * time.Second
s.IdleTimeout = 120 * time.Second s.IdleTimeout = time.Duration(config.GlobalConfig.Tuning.Timeouts.HttpIdle) * time.Second
s.ReadHeaderTimeout = 2 * time.Second s.ReadHeaderTimeout = READ_HEADER_TIMEOUT * time.Second
return nil return nil
}, },
} }