File/package naming convention conforming better to go standards - as ugly as it is
This commit is contained in:
1 parent
be4770cbab
commit
d6688a6754
32 files changed
+36
-36
No files matched your search
@@ -108,7 +108,7 @@ See [internal/mock](internal/mock/README.md) for its options and behaviour.
|
|||||||
| `internal/config` | Configuration loading, validation and editing |
|
| `internal/config` | Configuration loading, validation and editing |
|
||||||
| `internal/fetcher` | Runs a worker per enabled source |
|
| `internal/fetcher` | Runs a worker per enabled source |
|
||||||
| `internal/store` | SQLite storage of opportunities, and its migrations (see [internal/store](internal/store/README.md)) |
|
| `internal/store` | SQLite storage of opportunities, and its migrations (see [internal/store](internal/store/README.md)) |
|
||||||
| `internal/findATender` | FTS API client and conversion from OCDS to JobSearch types |
|
| `internal/findatender` | FTS API client and conversion from OCDS to JobSearch types |
|
||||||
| `internal/types` | JobSearch's own opportunity types |
|
| `internal/types` | JobSearch's own opportunity types |
|
||||||
| `internal/util` | The periodic `Worker` used by the fetcher |
|
| `internal/util` | The periodic `Worker` used by the fetcher |
|
||||||
| `internal/logging` | slog setup and the HTTP access log |
|
| `internal/logging` | slog setup and the HTTP access log |
|
||||||
@@ -134,7 +134,7 @@ Tests don't need network access; HTTP calls go to local `httptest` servers.
|
|||||||
Using a source called `example` as an illustration:
|
Using a source called `example` as an illustration:
|
||||||
|
|
||||||
1. **Configuration section:** create `internal/config/conf_source_example.go`,
|
1. **Configuration section:** create `internal/config/conf_source_example.go`,
|
||||||
copying an existing source such as `conf_source_ftsMock.go`:
|
copying an existing source such as `conf_source_ftsmock.go`:
|
||||||
- Add a `JSCKSourceExample = "example"` constant.
|
- Add a `JSCKSourceExample = "example"` constant.
|
||||||
- Define `JobSearchConfigSourceExample`, embedding `JobSearchConfigSource`
|
- Define `JobSearchConfigSourceExample`, embedding `JobSearchConfigSource`
|
||||||
(for `enabled` and `interval`), plus any fields of its own with `cfg` and
|
(for `enabled` and `interval`), plus any fields of its own with `cfg` and
|
||||||
@@ -152,10 +152,10 @@ Using a source called `example` as an illustration:
|
|||||||
code.
|
code.
|
||||||
3. **Client package:** create a package that fetches from the source and
|
3. **Client package:** create a package that fetches from the source and
|
||||||
returns `[]*types.Opportunity` (see `internal/types`). If the source
|
returns `[]*types.Opportunity` (see `internal/types`). If the source
|
||||||
publishes OCDS, `internal/findATender` may already be suitable, as it is
|
publishes OCDS, `internal/findatender` may already be suitable, as it is
|
||||||
for `fts_mock`: create it with the source's own API root.
|
for `fts_mock`: create it with the source's own API root.
|
||||||
4. **Worker:** create `internal/fetcher/worker_example.go`, following
|
4. **Worker:** create `internal/fetcher/worker_example.go`, following
|
||||||
`worker_ftsMock.go`:
|
`worker_ftsmock.go`:
|
||||||
- `runExample(ctx, conf, since)` builds a `util.Worker` with the source's
|
- `runExample(ctx, conf, since)` builds a `util.Worker` with the source's
|
||||||
name, `conf.Sources.Example.Interval` and a task, then calls `Run`.
|
name, `conf.Sources.Example.Interval` and a task, then calls `Run`.
|
||||||
- The task fetches everything since its `since` argument. Wrap blocking
|
- The task fetches everything since its `since` argument. Wrap blocking
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import (
|
|||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/logging"
|
"git.avsdev.uk/Go/job-search/internal/logging"
|
||||||
mock "git.avsdev.uk/Go/job-search/internal/mock/findATender"
|
mock "git.avsdev.uk/Go/job-search/internal/mock/findatender"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ returned in UTC.
|
|||||||
|
|
||||||
Data: the catalog of buyers, suppliers, tender subjects, procurement methods
|
Data: the catalog of buyers, suppliers, tender subjects, procurement methods
|
||||||
and classifications that releases are generated from is embedded in the
|
and classifications that releases are generated from is embedded in the
|
||||||
build from internal/mock/findATender/data/catalog.json. The mock stops with an
|
build from internal/mock/findatender/data/catalog.json. The mock stops with an
|
||||||
error if it is invalid.
|
error if it is invalid.
|
||||||
|
|
||||||
Releases are generated from that catalog and appended to
|
Releases are generated from that catalog and appended to
|
||||||
|
|||||||
File renamed without changes.
@@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/cli"
|
"git.avsdev.uk/Go/job-search/internal/cli"
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender"
|
"git.avsdev.uk/Go/job-search/internal/findatender"
|
||||||
"git.avsdev.uk/Go/job-search/internal/types"
|
"git.avsdev.uk/Go/job-search/internal/types"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -70,7 +70,7 @@ func commandOnce(opts *cli.Options) *cobra.Command {
|
|||||||
return sinceErr
|
return sinceErr
|
||||||
}
|
}
|
||||||
|
|
||||||
ft := findATender.New(conf, conf.Sources.FindATender.APIRoot)
|
ft := findatender.New(conf, conf.Sources.FindATender.APIRoot)
|
||||||
defer ft.Shutdown()
|
defer ft.Shutdown()
|
||||||
|
|
||||||
ignoreRateLimit, _ := cmd.Flags().GetBool("ignore-rate-limit")
|
ignoreRateLimit, _ := cmd.Flags().GetBool("ignore-rate-limit")
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
@@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/config"
|
"git.avsdev.uk/Go/job-search/internal/config"
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender"
|
"git.avsdev.uk/Go/job-search/internal/findatender"
|
||||||
"git.avsdev.uk/Go/job-search/internal/types"
|
"git.avsdev.uk/Go/job-search/internal/types"
|
||||||
"git.avsdev.uk/Go/job-search/internal/util"
|
"git.avsdev.uk/Go/job-search/internal/util"
|
||||||
)
|
)
|
||||||
@@ -35,11 +35,11 @@ func fetchFindAOpportunity(
|
|||||||
ctx context.Context, conf *config.JobSearchConfig, since time.Time,
|
ctx context.Context, conf *config.JobSearchConfig, since time.Time,
|
||||||
) error {
|
) error {
|
||||||
opportunities, err := util.AwaitTask(ctx, func() ([]*types.Opportunity, error) {
|
opportunities, err := util.AwaitTask(ctx, func() ([]*types.Opportunity, error) {
|
||||||
ft := findATender.New(conf, conf.Sources.FindATender.APIRoot)
|
ft := findatender.New(conf, conf.Sources.FindATender.APIRoot)
|
||||||
defer ft.Shutdown()
|
defer ft.Shutdown()
|
||||||
return ft.With(ctx).FetchAll(since, true)
|
return ft.With(ctx).FetchAll(since, true)
|
||||||
})
|
})
|
||||||
if errors.Is(err, findATender.ErrNoReleases) {
|
if errors.Is(err, findatender.ErrNoReleases) {
|
||||||
return ErrNoNewReleases
|
return ErrNoNewReleases
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/config"
|
"git.avsdev.uk/Go/job-search/internal/config"
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender"
|
"git.avsdev.uk/Go/job-search/internal/findatender"
|
||||||
"git.avsdev.uk/Go/job-search/internal/types"
|
"git.avsdev.uk/Go/job-search/internal/types"
|
||||||
"git.avsdev.uk/Go/job-search/internal/util"
|
"git.avsdev.uk/Go/job-search/internal/util"
|
||||||
)
|
)
|
||||||
@@ -35,11 +35,11 @@ func fetchFTSMock(
|
|||||||
ctx context.Context, conf *config.JobSearchConfig, since time.Time,
|
ctx context.Context, conf *config.JobSearchConfig, since time.Time,
|
||||||
) error {
|
) error {
|
||||||
opportunities, err := util.AwaitTask(ctx, func() ([]*types.Opportunity, error) {
|
opportunities, err := util.AwaitTask(ctx, func() ([]*types.Opportunity, error) {
|
||||||
ft := findATender.New(conf, conf.Sources.FTSMock.APIRoot)
|
ft := findatender.New(conf, conf.Sources.FTSMock.APIRoot)
|
||||||
defer ft.Shutdown()
|
defer ft.Shutdown()
|
||||||
return ft.With(ctx).FetchAll(since, true)
|
return ft.With(ctx).FetchAll(since, true)
|
||||||
})
|
})
|
||||||
if errors.Is(err, findATender.ErrNoReleases) {
|
if errors.Is(err, findatender.ErrNoReleases) {
|
||||||
return ErrNoNewReleases
|
return ErrNoNewReleases
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
File renamed without changes.
@@ -1,4 +1,4 @@
|
|||||||
package findATender
|
package findatender
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/findatender/ocds"
|
||||||
"git.avsdev.uk/Go/job-search/internal/logging"
|
"git.avsdev.uk/Go/job-search/internal/logging"
|
||||||
resty "resty.dev/v3"
|
resty "resty.dev/v3"
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package findATender
|
package findatender
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/config"
|
"git.avsdev.uk/Go/job-search/internal/config"
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/findatender/ocds"
|
||||||
resty "resty.dev/v3"
|
resty "resty.dev/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package findATender
|
package findatender
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@@ -54,7 +54,7 @@ func (ft *FindATender) With(ctx context.Context) *FindATender {
|
|||||||
// logged, as there is nothing a caller could do about it.
|
// logged, as there is nothing a caller could do about it.
|
||||||
func (ft *FindATender) Shutdown() {
|
func (ft *FindATender) Shutdown() {
|
||||||
if err := ft.httpClient.Close(); err != nil {
|
if err := ft.httpClient.Close(); err != nil {
|
||||||
slog.Warn("findATender: closing HTTP client", "error", err)
|
slog.Warn("findatender: closing HTTP client", "error", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package findATender
|
package findatender
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
File renamed without changes.
File renamed without changes.
@@ -1,11 +1,11 @@
|
|||||||
package findATender
|
package findatender
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/findatender/ocds"
|
||||||
"git.avsdev.uk/Go/job-search/internal/types"
|
"git.avsdev.uk/Go/job-search/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package findATender
|
package findatender
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/findatender/ocds"
|
||||||
"git.avsdev.uk/Go/job-search/internal/types"
|
"git.avsdev.uk/Go/job-search/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -5,10 +5,10 @@ development and testing without hitting the real APIs or their rate limits.
|
|||||||
|
|
||||||
| Package | Mocks | Command |
|
| Package | Mocks | Command |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `findATender` | UK Government Find a Tender service (FTS) OCDS API | `cmd/mock-fts` |
|
| `findatender` | UK Government Find a Tender service (FTS) OCDS API | `cmd/mock-fts` |
|
||||||
|
|
||||||
|
|
||||||
## findATender
|
## findatender
|
||||||
A mock of the FTS release package endpoint:
|
A mock of the FTS release package endpoint:
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -81,7 +81,7 @@ Query parameters, as on the real service:
|
|||||||
|
|
||||||
|
|
||||||
### Generated data
|
### Generated data
|
||||||
- **Catalog** (`findATender/data/catalog.json`): the buyers, suppliers,
|
- **Catalog** (`findatender/data/catalog.json`): the buyers, suppliers,
|
||||||
tender subjects, procurement methods and classifications that releases are
|
tender subjects, procurement methods and classifications that releases are
|
||||||
drawn from. It's embedded in the binary, so rebuild after changing it.
|
drawn from. It's embedded in the binary, so rebuild after changing it.
|
||||||
Subjects refer to classifications by `{scheme}-{id}` keys (e.g.
|
Subjects refer to classifications by `{scheme}-{id}` keys (e.g.
|
||||||
@@ -111,5 +111,5 @@ Query parameters, as on the real service:
|
|||||||
| `ocds/` | Generated OCDS types (`ocds_gen.go`, from `ocdsgen`); don't edit by hand |
|
| `ocds/` | Generated OCDS types (`ocds_gen.go`, from `ocdsgen`); don't edit by hand |
|
||||||
| `testdata/` | A small catalog used by the tests |
|
| `testdata/` | A small catalog used by the tests |
|
||||||
|
|
||||||
The mock's `ocds` package is separate from `internal/findATender/ocds`, which
|
The mock's `ocds` package is separate from `internal/findatender/ocds`, which
|
||||||
the JobSearch client uses.
|
the JobSearch client uses.
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Method is a procurement method and its details, as published on a tender.
|
// Method is a procurement method and its details, as published on a tender.
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -9,7 +9,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ocidPrefix = "ocds-mock-"
|
const ocidPrefix = "ocds-mock-"
|
||||||
+1
-1
@@ -10,7 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
func quietLog(t *testing.T) {
|
func quietLog(t *testing.T) {
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUpdatedFromIsLocalTime(t *testing.T) {
|
func TestUpdatedFromIsLocalTime(t *testing.T) {
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -16,7 +16,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Store keeps every release in memory and appends each new one to a JSON Lines
|
// Store keeps every release in memory and appends each new one to a JSON Lines
|
||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.avsdev.uk/Go/job-search/internal/mock/findATender/ocds"
|
"git.avsdev.uk/Go/job-search/internal/mock/findatender/ocds"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStorePersistsAndGeneratorProgresses(t *testing.T) {
|
func TestStorePersistsAndGeneratorProgresses(t *testing.T) {
|
||||||
Vendored
File renamed without changes.
Reference in new issue
Block a user