Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pkg/types/gateway/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const (

// CacheSettings defines cache control options for outbound HTTP requests.
type CacheSettings struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why do we have this struct when there's already one generated from the proto?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is used for communication between workflow node and gateway node in case it diverges from proto. turned out to be useful because we made a breaking change in proto but not in this struct by deprecating but not deleting ReadFromCache field

ReadFromCache bool `json:"readFromCache,omitempty"` // If true, attempt to read a cached response for the request
MaxAgeMs int32 `json:"maxAgeMs,omitempty"` // Maximum age of a cached response in milliseconds.
MaxAgeMs int32 `json:"maxAgeMs,omitempty"` // Maximum age of a cached response in milliseconds.
Store bool `json:"store,omitempty"` // If true, cache the response.
// Deprecated: positive MaxAgeMs implies ReadFromCache is true
ReadFromCache bool `json:"readFromCache,omitempty"` // If true, attempt to read a cached response for the request
}

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

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

s.Write([]byte(req.WorkflowID))
s.Write([]byte(req.WorkflowOwner))
s.Write(sep)
s.Write([]byte(req.URL))
s.Write(sep)
Expand Down
Loading