Skip to content

Commit 4c360bd

Browse files
authored
add store flag to cache settings struct (#1586)
* add store flag to cache settings struct * use cache settings and workflow owner for response cache key * remove cache settings from hash()
1 parent 598ab18 commit 4c360bd

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

pkg/types/gateway/action.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ const (
1515

1616
// CacheSettings defines cache control options for outbound HTTP requests.
1717
type CacheSettings struct {
18-
ReadFromCache bool `json:"readFromCache,omitempty"` // If true, attempt to read a cached response for the request
19-
MaxAgeMs int32 `json:"maxAgeMs,omitempty"` // Maximum age of a cached response in milliseconds.
18+
MaxAgeMs int32 `json:"maxAgeMs,omitempty"` // Maximum age of a cached response in milliseconds.
19+
Store bool `json:"store,omitempty"` // If true, cache the response.
20+
// Deprecated: positive MaxAgeMs implies ReadFromCache is true
21+
ReadFromCache bool `json:"readFromCache,omitempty"` // If true, attempt to read a cached response for the request
2022
}
2123

2224
// OutboundHTTPRequest represents an HTTP request to be sent from workflow node to the gateway.
@@ -31,13 +33,16 @@ type OutboundHTTPRequest struct {
3133
// 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.
3234
MaxResponseBytes uint32 `json:"maxBytes,omitempty"`
3335
WorkflowID string `json:"workflowId"`
36+
WorkflowOwner string `json:"workflowOwner"`
3437
}
3538

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
3641
func (req OutboundHTTPRequest) Hash() string {
3742
s := sha256.New()
3843
sep := []byte("/")
3944

40-
s.Write([]byte(req.WorkflowID))
45+
s.Write([]byte(req.WorkflowOwner))
4146
s.Write(sep)
4247
s.Write([]byte(req.URL))
4348
s.Write(sep)

0 commit comments

Comments
 (0)