• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / auth / 11008788490
69%

Build:
DEFAULT BRANCH: master
Ran 24 Sep 2024 07:15AM UTC
Jobs 1
Files 128
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

24 Sep 2024 07:09AM UTC coverage: 57.716% (-0.2%) from 57.869%
11008788490

push

github

web-flow
feat: config reloading (#1771)

## What kind of change does this PR introduce?

File based configuration reloading using fsnotify. 

## What is the current behavior?

Currently the Auth config is loaded once from the environment or file
(-c flag) and persists until the service is restarted.

## What is the new behavior?

A new optional flag (long: `--watch-dir`, short: `-w`) has been added.
When present any files with a ".env" suffix will be loaded into the
environment before the `*GlobalConfiguration` is created, otherwise
existing behavior is preserved.

In addition when the watch-dir flag is present a goroutine will be
started in serve_cmd.go and begin blocking on a call to
`(*Reloader).Watch` with a callback function that accepts a
`*conf.GlobalConfiguration object`. Each time this function is called we
create a new `*api.API` object and store it within our `AtomicHandler`,
previously given as the root handler to the `*http.Server`.

The Reloader uses some simple heuristics to deal with a few edge cases,
an overview:

- At most 1 configuration reload may happen per 10 seconds with a +-1s
margin of error.
- After a file within `--watch-dir` has changed the 10 second grace
period begins. After that it will reload the config.
- Config reloads first sort each file by name then processes them in
sequence.
- Directories within `--watch-dir` are ignored during config reloading.
- Implementation quirk: directory changes can trigger a config reload,
as I don't stat fsnotify events. This and similar superfulous reloads
could be easily fixed by storing a snapshot of `os.Environ()` after
successful reloads to compare with the latest via `slices.Equal()`
before reloading.
  - Files that do not end with a `.env` suffix are ignored.
- It handles the removal or renaming of the `-watch-dir` during runtime,
but an error message will be printed every 10 seconds as long as it's
missing.
- The config file passed with -c is onl... (continued)

53 of 209 new or added lines in 6 files covered. (25.36%)

9204 of 15947 relevant lines covered (57.72%)

55.1 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
2
0.0
0.0% cmd/root_cmd.go
3
86.57
-0.98% internal/api/api.go
4
73.33
internal/reloader/handler.go
35
71.18
0.14% internal/conf/configuration.go
56
0.0
0.0% cmd/serve_cmd.go
56
26.32
internal/reloader/reloader.go
Jobs
ID Job ID Ran Files Coverage
1 11008788490.1 24 Sep 2024 07:14AM UTC 128
57.72
GitHub Action Run
Source Files on build 11008788490
  • Tree
  • List 128
  • Changed 9
  • Source Changed 0
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • 6ee00916 on github
  • Prev Build on master (#10930141826)
  • Next Build on master (#11008894926)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc