diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-06-07 00:06:45 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-06-25 12:41:13 +0000 |
| commit | 0de98aeaa92080519ff0e194fc9246ddd79aca6d (patch) | |
| tree | 2f2b1842e30a8aef6d42c20f6d32de5c85f38f02 /internal/discovery/discovery.go | |
| parent | e12a9820895b48de6d1b8408364fec45958bc6c5 (diff) | |
Discovery: Return a fresh boolean
Diffstat (limited to 'internal/discovery/discovery.go')
| -rw-r--r-- | internal/discovery/discovery.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/internal/discovery/discovery.go b/internal/discovery/discovery.go index daa08e8..3994aba 100644 --- a/internal/discovery/discovery.go +++ b/internal/discovery/discovery.go @@ -285,10 +285,11 @@ func (discovery *Discovery) previousServers() (*Servers, error) { } // Organizations returns the discovery organizations +// The second return value is a boolean that indicates whether a fresh list was updated internally // If there was an error, a cached copy is returned if available. -func (discovery *Discovery) Organizations(ctx context.Context) (*Organizations, error) { +func (discovery *Discovery) Organizations(ctx context.Context) (*Organizations, bool, error) { if !discovery.DetermineOrganizationsUpdate() { - return &discovery.OrganizationList, nil + return &discovery.OrganizationList, false, nil } file := "organization_list.json" err := discovery.file(ctx, file, discovery.OrganizationList.Version, &discovery.OrganizationList) @@ -298,30 +299,30 @@ func (discovery *Discovery) Organizations(ctx context.Context) (*Organizations, if perr != nil { log.Logger.Warningf("failed to get previous discovery organizations: %v", perr) } - return orgs, err + return orgs, false, err } discovery.OrganizationList.Timestamp = time.Now() - return &discovery.OrganizationList, nil + return &discovery.OrganizationList, true, nil } // Servers returns the discovery servers +// The second return value is a boolean that indicates whether a fresh list was updated internally // If there was an error, a cached copy is returned if available. -func (discovery *Discovery) Servers(ctx context.Context) (*Servers, error) { +func (discovery *Discovery) Servers(ctx context.Context) (*Servers, bool, error) { if !discovery.DetermineServersUpdate() { - return &discovery.ServerList, nil + return &discovery.ServerList, false, nil } file := "server_list.json" err := discovery.file(ctx, file, discovery.ServerList.Version, &discovery.ServerList) if err != nil { // Return previous with an error - // TODO: Log here if we fail to get previous srvs, perr := discovery.previousServers() if perr != nil { log.Logger.Warningf("failed to get previous discovery servers: %v", perr) } - return srvs, err + return srvs, false, err } // Update servers timestamp discovery.ServerList.Timestamp = time.Now() - return &discovery.ServerList, nil + return &discovery.ServerList, true, nil } |
