Fixed lint issues and missing documentation
This commit is contained in:
1 parent
7fd321df97
commit
6e6dec68c0
34 files changed
+346
-156
No files matched your search
@@ -191,7 +191,7 @@ func (o *options) validate() error {
|
||||
}
|
||||
|
||||
// run starts the mock and blocks until ctx is cancelled or the server fails.
|
||||
func run(ctx context.Context, o *options) error {
|
||||
func run(ctx context.Context, o *options) (err error) {
|
||||
loc, err := time.LoadLocation(o.tz) // already validated
|
||||
if err != nil {
|
||||
return fmt.Errorf("--tz: %w", err)
|
||||
@@ -228,7 +228,7 @@ func run(ctx context.Context, o *options) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer store.Close()
|
||||
defer func() { err = errors.Join(err, store.Close()) }()
|
||||
|
||||
// ----- generator -----
|
||||
gen := mock.NewGenerator(cat, store, time.Now().UnixNano())
|
||||
@@ -261,7 +261,7 @@ func run(ctx context.Context, o *options) error {
|
||||
<-workerDone
|
||||
return fmt.Errorf("opening access log: %w", err)
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() { err = errors.Join(err, f.Close()) }()
|
||||
out = f
|
||||
}
|
||||
accessLogger := log.New(out, "", 0)
|
||||
@@ -279,11 +279,14 @@ func run(ctx context.Context, o *options) error {
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
// ctx is done by now; the shutdown gets its own deadline.
|
||||
shutdownCtx, cancelShutdown := context.WithTimeout(
|
||||
context.Background(), 5*time.Second,
|
||||
context.WithoutCancel(ctx), 5*time.Second,
|
||||
)
|
||||
defer cancelShutdown()
|
||||
httpSrv.Shutdown(shutdownCtx)
|
||||
if err := httpSrv.Shutdown(shutdownCtx); err != nil {
|
||||
log.Printf("shutdown: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Printf("FTS mock listening on %s%s (query times in %s)", o.addr, mock.BasePath, loc)
|
||||
|
||||
Reference in new issue
Block a user