Skip to content

Commit

Permalink
chore: Add function GetEndpointNoCache
Browse files Browse the repository at this point in the history
This function bypasses the cache when retrieving the sidetree endpoint for the domain.

Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
  • Loading branch information
bstasyszyn committed Jun 8, 2023
1 parent b10de1a commit 1dc222d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/discovery/endpoint/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ func (cs *Client) GetEndpoint(domain string) (*models.Endpoint, error) {
return endpoint.(*models.Endpoint), nil //nolint:forcetypeassert
}

// GetEndpointNoCache fetches endpoints from domain bypassing the cache.
func (cs *Client) GetEndpointNoCache(domain string) (*models.Endpoint, error) {
return cs.getEndpoint(domain)
}

// GetEndpointFromAnchorOrigin fetches endpoints from anchor origin, caching the value.
func (cs *Client) GetEndpointFromAnchorOrigin(didURI string) (*models.Endpoint, error) {
return cs.getEndpointAnchorOrigin(didURI)
Expand Down
4 changes: 4 additions & 0 deletions pkg/discovery/endpoint/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ func TestConfigService_GetEndpoint(t *testing.T) { //nolint: gocyclo,gocognit,cy
endpoint, err := cs.GetEndpoint("d1")
require.NoError(t, err)

endpoint2, err := cs.GetEndpointNoCache("d1")
require.NoError(t, err)
require.Equal(t, endpoint, endpoint2)

require.Equal(t, endpoint.ResolutionEndpoints, []string{"https://localhost/resolve1", "https://localhost/resolve2"})
require.Equal(t, endpoint.OperationEndpoints, []string{"https://localhost/op1", "https://localhost/op2"})
require.Equal(t, endpoint.MinResolvers, 2)
Expand Down

0 comments on commit 1dc222d

Please sign in to comment.