Skip to content

Commit 279fefc

Browse files
committed
use cache settings and workflow owner for response cache key
1 parent ac1c152 commit 279fefc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/types/gateway/action.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ type OutboundHTTPRequest struct {
3333
// Maximum number of bytes to read from the response body. If the gateway max response size is smaller than this value, the gateway max response size will be used.
3434
MaxResponseBytes uint32 `json:"maxBytes,omitempty"`
3535
WorkflowID string `json:"workflowId"`
36+
WorkflowOwner string `json:"workflowOwner"`
3637
}
3738

39+
// Hash generates a hash of the request for caching purposes.
40+
// WorkflowID is not included in the hash because cached responses can be used across workflows
3841
func (req OutboundHTTPRequest) Hash() string {
3942
s := sha256.New()
4043
sep := []byte("/")
4144

42-
s.Write([]byte(req.WorkflowID))
45+
s.Write([]byte(req.WorkflowOwner))
4346
s.Write(sep)
4447
s.Write([]byte(req.URL))
4548
s.Write(sep)
@@ -62,6 +65,10 @@ func (req OutboundHTTPRequest) Hash() string {
6265
}
6366

6467
s.Write([]byte(strconv.FormatUint(uint64(req.MaxResponseBytes), 10)))
68+
s.Write(sep)
69+
s.Write([]byte(strconv.FormatInt(int64(req.CacheSettings.MaxAgeMs), 10)))
70+
s.Write(sep)
71+
s.Write([]byte(strconv.FormatBool(req.CacheSettings.Store)))
6572

6673
return hex.EncodeToString(s.Sum(nil))
6774
}

0 commit comments

Comments
 (0)