Files
job-search/internal/config/conf_sources.go
T
bwilliams 5cb3601e1f Added fetch service and a mock Find a Tender server
Fetching:
- Add `fetch service`, which runs a worker per enabled source until
  SIGINT/SIGTERM (internal/fetcher)
- Add util.Worker: runs a task on an interval with a since-checkpoint
  that only advances on success, and a shutdown timeout for in-flight
  work; plus AwaitTask/AwaitTaskE for calls that ignore cancellation
- Add fts_mock and sleeper sources
- Sleeper: sleeps periodically to emulate work being done. Can be
  instructed to block the shutdown signal or handle it cleanly

Mock FTS server (cmd/mock-fts, internal/mock/findATender):
- Serves GET /api/1.0/ocdsReleasePackages with FTS paging, query
  validation, UK local time handling and per-client rate limiting
- Generates fictional releases from an embedded catalog, moving
  procedures through planning, tender and award, and keeps them in a
  JSON Lines store that survives restarts
- Add logging.AccessLog for combined/common access logs
2026-10-09 18:02:32 +01:00

70 lines
1.7 KiB
Go

package config
import (
"reflect"
"time"
)
const JSCKSources string = "sources"
// Each field's cfg tag must match the section's JSCK* constant.
type JobSearchConfigSources struct {
FindATender JobSearchConfigSourceFindATender `cfg:"find_a_tender"`
FTSMock JobSearchConfigSourceFTSMock `cfg:"fts_mock"`
Sleeper JobSearchConfigSourceSleeper `cfg:"sleeper"`
}
/*
* General section functions
* See related methods in section.go
*/
func (c JobSearchConfigSources) Map() map[string]any { return mapOf(c) }
func (c JobSearchConfigSources) Flatten() map[string]any {
return flattenOf(JSCKSources, c)
}
func (c JobSearchConfigSources) TypeOf(key string) (reflect.Kind, error) {
return typeOf(c, key)
}
func (c JobSearchConfigSources) ValueOf(key string) (any, error) {
return valueOf(c, key)
}
func (c *JobSearchConfigSources) SetValue(key string, value any) error {
return setValue(c, key, value)
}
/*
*** Generic source definition, embedded in each source ***
*/
type JobSearchConfigSource struct {
Enabled bool `cfg:"enabled"`
Interval time.Duration `cfg:"interval" default:"10m"`
}
/*
* General section functions
* See related methods in section.go
*/
func (c *JobSearchConfigSource) Keys() []string { return keysOf(c) }
func (c JobSearchConfigSource) Map() map[string]any { return mapOf(c) }
func (c JobSearchConfigSource) Flatten() map[string]any {
return flattenOf("", c)
}
func (c JobSearchConfigSource) TypeOf(key string) (reflect.Kind, error) {
return typeOf(c, key)
}
func (c JobSearchConfigSource) ValueOf(key string) (any, error) {
return valueOf(c, key)
}
func (c *JobSearchConfigSource) SetValue(key string, value any) error {
return setValue(c, key, value)
}