americanas-tech / restQL-golang

Microservice query language and platform
http://restql.b2w.io/
MIT License
17 stars 8 forks source link

Defer response body parsing #31

Closed caiorcferreira closed 4 years ago

caiorcferreira commented 4 years ago

This PR introduces an optimization on restQL's hot path.

By using a wrapper restql.ResponseBody it can avoid making the unmarshaling of HTTP response body if not needed.

In case the query demands the response values to be manipulated, like when using filters, aggregations, or chained values, the body will be parsed using the standard json.Unmarshal function.

After the body is used on computations, a new value can be set thought ResponseBody.SetValue, which accepts any value and will be used in place of the []byte read from the HTTP response.