Releases: yosiat/panko_serializer
v0.4.4
Changes
- Rubocop fixes to all code
- Panko::Response enchantments - handling array and nice "DSL"
Panko::Response.create
Panko::Response
is a nice utility, but building nested objects with JSON values can be really ugly and fast.
Let's take this example (from specs):
Panko::Response.new([
data: Panko::Response.new(
json_data: Panko::JsonValue.from({ a: 1 }.to_json),
foos: Panko::ArraySerializer.new(Foo.all, each_serializer: FooSerializer),
foo: Panko::JsonValue.from(FooSerializer.new.serialize_to_json(Foo.first)),
)
])
Will be changed to:
Panko::Response.create do |t|
[
{
data: t.value(
json_data: t.json({ a: 1 }.to_json),
foos: t.array_serializer(Foo.all, FooSerializer),
foo: t.serializer(Foo.first, FooSerializer)
)
}
]
end
v0.4.3
v0.4.2
v0.4.0
Changes
- Upgrade to Oj 3.6.0 from 3.3.0 - https://github.com/ohler55/oj/blob/master/CHANGELOG.md
- Support Rails 5.2.0
- Throw error when invalid each_serializer passed to
Panko::ArraySerializer
- Support serializers inheritance
v0.3.9
v0.3.9
Fixed Bugs
- Methods under the serializer definition was added as an attributes, for example:
class UserSerializer < Panko::Serializer
attributes :id, :name
# will be included since it's attribute
def name
"#{object.first_name} #{object.last_name}"
end
# will be included because of the bug, shouldn't be included since there is no `attributes` definition
def age
21
end
end
v0.3.5
v0.3.5
This release includes new features!
Changes
- Serializing Plain Ruby Objects 🎉 - Pull Request
- Fix spelling mistake - Thanks @bradbajuz - Pull Request
filters_for
support in serializations - Issue
v0.3.4
v0.3.4
This release includes bugfix and a new feature.
Changes
- Removed
byebug
from SerializerResolver - Thanks @henrypoydar - Pull Request - Support ActiveRecord alias_attributes - Pull Request
v0.3.3
v0.3.3
This release includes the new documentation site (https://yosiat.github.io/panko_serializer) and new features.
News
- New documentation site - https://yosiat.github.io/panko_serializer
- New slack channel - join and ask questions and talk about panko! - Join slack!
- New Feature: Inference: detect serializer for associations - Docs, Issue, Pull Request
What to expect in the next release?
- Rails integration - No need to write
Panko::ArraySerializer
, justrender json: posts, each_serializer: PostSerializer
- Issue - Setting context globally - For example, pass the current_user to serializer in this controller - Issue
- Filtering keys at the serializer level - get the filters of your serializer closer to your serializer - Issue
v0.3.1
v0.3.1
This version is mostly performance improvements & refactoring of current codebase.
Features
- Panko::JsonValue - wrapper for json values to use Panko::Response
Performance Improvements
- Caching types in attributes - Instead of re-fetching the type of attribute every time, we cache it and invalid it based on the record class being serializer.
- Moving attributes & associations to be backend behind C structs - and saving the name of attribute/association string and symbol to avoid necessary conversions
- Type Casting of JSON - is now done using Oj instead of relying on AR type to do the deserialization
- Caching serializer between runs - In method attributes, we create serializer instance, now between runs we cache it so we don't need to re-create.
We can't talk about performance improvements without showing some numbers!
Real-world benchmark:
I used the infrastructure in work and popular endpoint that serializes 7,884 entries,
here is are different between v0.2.2 and this version -
Metric | v0.2.2 | v0.3.1 |
---|---|---|
Avg Response Time | 2.10s | 1.46s |
Max Response Time | 2.40s | 1.90s |
99th Response Time | 2.35s | 1.67s |
Requests Per Second | 0.47 | 0.68 |
Total Requests | 142 | 205 |
the tests were done on different environment for testing only with wrk - 5 minute
Thanks to Bringg (my employer) for providing the infrastructure & data for those benchmarks.
Benchmarks:
Benchmark | v0.2.2 ip/s | v0.3.1 ip/s |
---|---|---|
Panko_SimpleWithMethodCall_Posts_2300 | 82.47 | 92.63 |
Panko_SimpleWithMethodCall_Posts_50 | 4,480.92 | 5,097.98 |
Panko_HasOne_Posts_2300 | 46.86 | 60.8 |
Panko_HasOne_Posts_50 | 3,040.04 | 3,774.9 |
Panko_Simple_Posts_2300 | 89.57 | 132.99 |
Panko_Simple_Posts_50 | 5,605.79 | 6,619.94 |
ran using rake sanity
on my MacBook Pro (Retina, 15-inch, Mid 2015)