Skip to content
Snippets Groups Projects
Commit 1a8ea0db authored by Yordan Kinkov's avatar Yordan Kinkov
Browse files

#1 Rename TTL variable to cacheTTL

parent 5dcd5e84
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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
}
......
......@@ -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
},
},
......
......@@ -15,7 +15,7 @@ type ExportConfiguration struct {
ExportName string
Contexts []string
Policies map[string]interface{}
TTL *int
CacheTTL *int
}
type Storage struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment