Added unit tests, documentation and function descriptions across the board. Increased cyclop complexity threshold to 15 which is a bit more sane than 10 and excluded _test.go files from linters.
This commit is contained in:
1 parent
005b335371
commit
7fd321df97
31 files changed
+4106
-1
No files matched your search
@@ -16,6 +16,8 @@ type FindATender struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// New returns a client for the OCDS API at apiRoot. Requests time out after
|
||||
// 60 seconds and are retried once. Call Shutdown when finished with it.
|
||||
func New(conf *config.JobSearchConfig, apiRoot string) *FindATender {
|
||||
ft := &FindATender{
|
||||
config: conf,
|
||||
@@ -27,10 +29,14 @@ func New(conf *config.JobSearchConfig, apiRoot string) *FindATender {
|
||||
return ft
|
||||
}
|
||||
|
||||
// ReloadConfig replaces the configuration the client reads, such as the log
|
||||
// level. The HTTP client and API root set by New are not changed.
|
||||
func (ft *FindATender) ReloadConfig(conf *config.JobSearchConfig) {
|
||||
ft.config = conf
|
||||
}
|
||||
|
||||
// With returns a copy of the client whose requests use ctx, so they stop
|
||||
// when it is cancelled. A nil ctx returns the client unchanged.
|
||||
func (ft *FindATender) With(ctx context.Context) *FindATender {
|
||||
if ctx == nil {
|
||||
return ft
|
||||
@@ -41,10 +47,14 @@ func (ft *FindATender) With(ctx context.Context) *FindATender {
|
||||
return &copied
|
||||
}
|
||||
|
||||
// Shutdown closes the client's HTTP connections.
|
||||
func (ft *FindATender) Shutdown() {
|
||||
ft.httpClient.Close()
|
||||
}
|
||||
|
||||
// FetchOnce fetches the first page of releases updated since since, and
|
||||
// converts them to opportunities. If allowRateLimit is true, a 429 response
|
||||
// is waited out and retried; otherwise it fails with ErrRateLimitExceeded.
|
||||
func (ft *FindATender) FetchOnce(
|
||||
since time.Time,
|
||||
allowRateLimit bool,
|
||||
@@ -59,6 +69,9 @@ func (ft *FindATender) FetchOnce(
|
||||
return Convert(releases), nil
|
||||
}
|
||||
|
||||
// FetchAll fetches every page of releases updated since since, following
|
||||
// each page's next link, and converts them to opportunities. allowRateLimit
|
||||
// behaves as for FetchOnce.
|
||||
func (ft *FindATender) FetchAll(
|
||||
since time.Time,
|
||||
allowRateLimit bool,
|
||||
|
||||
Reference in new issue
Block a user