diff --git a/internal/clients/policy/client.go b/internal/clients/policy/client.go index c6b664a2e05b98fc383f4aee610fe1be5afe3025..651b31b95645d86759f0e8d8283c475644705cf1 100644 --- a/internal/clients/policy/client.go +++ b/internal/clients/policy/client.go @@ -40,7 +40,7 @@ func New(addr string, opts ...ClientOption) *Client { // The policy is expected as a string path uniquely identifying the // policy that has to be evaluated. For example, with policy = `gaiax/didResolve/1.0`, // the client will do HTTP request to http://policyhost/policy/gaiax/didResolve/1.0/evaluation. -func (c *Client) Evaluate(ctx context.Context, policy string, data interface{}, evaluationID string, ttl *int) ([]byte, error) { +func (c *Client) Evaluate(ctx context.Context, policy string, data interface{}, evaluationID string, cacheTTL *int) ([]byte, error) { uri := c.addr + "/policy/" + policy + "/evaluation" policyURL, err := url.ParseRequestURI(uri) if err != nil { @@ -61,8 +61,8 @@ func (c *Client) Evaluate(ctx context.Context, policy string, data interface{}, req.Header.Set(headerEvaluationID, evaluationID) } - if ttl != nil { - req.Header.Set(headerCacheTTL, strconv.Itoa(*ttl)) + if cacheTTL != nil { + req.Header.Set(headerCacheTTL, strconv.Itoa(*cacheTTL)) } resp, err := c.httpClient.Do(req.WithContext(ctx)) diff --git a/internal/service/infohub/service.go b/internal/service/infohub/service.go index 1c38b6a3499cd071aec71c97b618e003c2cd5b92..f21a0ef33629bcd0bf262ecb7c12fa1cae26dea4 100644 --- a/internal/service/infohub/service.go +++ b/internal/service/infohub/service.go @@ -3,7 +3,6 @@ package infohub import ( "context" "encoding/json" - "github.com/google/uuid" "github.com/hyperledger/aries-framework-go/pkg/doc/verifiable" "go.uber.org/zap" @@ -207,7 +206,7 @@ func (s *Service) triggerExport(ctx context.Context, exportCfg *storage.ExportCo s.logger.Info("export triggered", zap.String("exportName", exportCfg.ExportName)) for policy, input := range exportCfg.Policies { cacheKey := exportCacheKey(exportCfg.ExportName, policy) - _, err := s.policy.Evaluate(ctx, policy, input, cacheKey, exportCfg.TTL) + _, err := s.policy.Evaluate(ctx, policy, input, cacheKey, exportCfg.CacheTTL) if err != nil { return err } diff --git a/internal/service/infohub/service_test.go b/internal/service/infohub/service_test.go index 121971a89e0594f9fa2390d9a896353275bfa6b4..c585ea29797dd4d57b2bfa3c644085b5b16db801 100644 --- a/internal/service/infohub/service_test.go +++ b/internal/service/infohub/service_test.go @@ -86,7 +86,7 @@ func TestService_Export(t *testing.T) { ExportName: "testexport", Contexts: []string{"https://www.w3.org/2018/credentials/examples/v1"}, Policies: map[string]interface{}{"test/test/1.0": map[string]interface{}{"hello": "test world"}}, - TTL: ptr.Int(60), + CacheTTL: ptr.Int(60), }, nil }, }, @@ -136,7 +136,7 @@ func TestService_Export(t *testing.T) { ExportName: "testexport", Contexts: []string{"https://www.w3.org/2018/credentials/examples/v1"}, Policies: map[string]interface{}{"test/test/1.0": map[string]interface{}{"hello": "test world"}}, - TTL: ptr.Int(60), + CacheTTL: ptr.Int(60), }, nil }, }, diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 542a1144c7f1f6ce8d184599c5e0f77298fa0aa0..5c6072c86f0ccafe31c50dd33ae993b2d9975fdc 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -15,7 +15,7 @@ type ExportConfiguration struct { ExportName string Contexts []string Policies map[string]interface{} - TTL *int + CacheTTL *int } type Storage struct {