Skip to content

Commit

Permalink
ai-cache update body buffer limit size
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlanni committed Jan 6, 2025
1 parent 187a7b5 commit 2551bc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions plugins/wasm-go/extensions/ai-cache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
STREAM_CONTEXT_KEY = "stream"
SKIP_CACHE_HEADER = "x-higress-skip-ai-cache"
ERROR_PARTIAL_MESSAGE_KEY = "errorPartialMessage"

DEFAULT_MAX_BODY_BYTES uint32 = 10 * 1024 * 1024
)

func main() {
Expand Down Expand Up @@ -69,6 +71,7 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, c config.PluginConfig, log wr
ctx.DontReadRequestBody()
return types.ActionContinue
}
ctx.SetRequestBodyBufferLimit(DEFAULT_MAX_BODY_BYTES)
_ = proxywasm.RemoveHttpRequestHeader("Accept-Encoding")
// The request has a body and requires delaying the header transmission until a cache miss occurs,
// at which point the header should be sent.
Expand Down
4 changes: 2 additions & 2 deletions plugins/wasm-go/pkg/wrapper/plugin_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ type HttpContext interface {
// You need to call this before making any header modification operations.
DisableReroute()
// Note that this parameter affects the gateway's memory usage!Support setting a maximum buffer size for each request body individually in request phase.
SetRequestBodyBufferLimit(size uint32)
SetRequestBodyBufferLimit(byteSize uint32)
// Note that this parameter affects the gateway's memory usage! Support setting a maximum buffer size for each response body individually in response phase.
SetResponseBodyBufferLimit(size uint32)
SetResponseBodyBufferLimit(byteSize uint32)
}

type ParseConfigFunc[PluginConfig any] func(json gjson.Result, config *PluginConfig, log Log) error
Expand Down

0 comments on commit 2551bc2

Please sign in to comment.