summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 23 insertions, 10 deletions
diff --git a/main.go b/main.go
index 81c69e4..a4192d9 100644
--- a/main.go
+++ b/main.go
@@ -18,15 +18,25 @@ func main() {
}
}
+type duration struct {
+ time.Duration
+}
+
+func (d *duration) UnmarshalText(text []byte) error {
+ var err error
+ d.Duration, err = time.ParseDuration(string(text))
+ return err
+}
+
type options struct {
- BindAddress string `toml:"bind_address"`
- CacheExpiry time.Duration `toml:"cache_expiry"`
- UpstreamTimeout time.Duration `toml:"upstream_timeout"`
- SourcehutUsername string `toml:"srht_username"`
- SourcehutToken string `toml:"srht_token"`
- GithubUsername string `toml:"github_username"`
- GithubToken string `toml:"github_token"`
- CanonicalPrefix string `toml:"canonical_prefix"`
+ BindAddress string `toml:"bind_address"`
+ CacheExpiry duration `toml:"cache_expiry"`
+ UpstreamTimeout duration `toml:"upstream_timeout"`
+ SourcehutUsername string `toml:"srht_username"`
+ SourcehutToken string `toml:"srht_token"`
+ GithubUsername string `toml:"github_username"`
+ GithubToken string `toml:"github_token"`
+ CanonicalPrefix string `toml:"canonical_prefix"`
}
func run() error {
@@ -43,10 +53,13 @@ func run() error {
return err
}
+ log.Printf("caches expire after %s", opts.CacheExpiry.Duration)
+ log.Printf("upstream reqs time out after %s", opts.UpstreamTimeout.Duration)
+
cache := &PackageCache{
CanonicalPrefix: opts.CanonicalPrefix,
- ExpireAfter: opts.CacheExpiry,
- UpstreamTimeout: opts.UpstreamTimeout,
+ ExpireAfter: opts.CacheExpiry.Duration,
+ UpstreamTimeout: opts.UpstreamTimeout.Duration,
Logger: log.New(os.Stdout, "", log.LstdFlags),
Hosts: []RepoHost{
Sourcehut{Username: opts.SourcehutUsername, Token: opts.SourcehutToken},