ExtensionType API incomplete
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 32/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- julia
- Domain
- backend-api-design
Research direction
Start with the MsgPack.ExtensionType documentation and the existing test suite, then trace the msgpack_type, to_msgpack, and from_msgpack entry points used in the example. Reproduce the failing unpack test with the provided extension bytes and determine what API behavior is needed for them to produce a Dates.Date rather than MsgPack.Extension.
Written by the indexing model from the issue text.
Description
Is the API for supporting MsgPack extensions complete?
(So as not to waste anyone's time, note that this is an adaptation of a question on Discourse.)
I am trying to write the Julia end of an RPC-over-RabbitMQ relationship. The other side (written in Ruby) uses a MsgPack extension for dates. I receive this:
MsgPack.Extension(1, UInt8[0x07, 0xe6, 0x02, 0x1c])
I can make my end send this with pack, but I can’t make my end convert this to a Date with unpack. This is what I have so far, based on the documentation for MsgPack.ExtensionType:
module test_msg_pack_ext
using Dates
using MsgPack
using Test
function pack_date(date::Date)::MsgPack.Extension
year_u16 = convert(UInt16, year(date))
year_hi = UInt8(year_u16 >> 8)
year_lo = UInt8(year_u16 << 8 >> 8)
return MsgPack.Extension(0x01, UInt8[year_hi, year_lo, month(date), day(date)])
end
function unpack_date(ext::MsgPack.Extension)::Date
year = ext.data[1] << 8 | ext.data[2]
return Date(year, ext.data[3], ext.data[4])
end
MsgPack.msgpack_type(::Type{Dates.Date}) = MsgPack.ExtensionType()
MsgPack.to_msgpack(::MsgPack.ExtensionType, date::Dates.Date) = pack_date(date)
MsgPack.from_msgpack(::Type{Dates.Date}, ext::MsgPack.Extension) = unpack_date(ext)
@test pack(MsgPack.Extension(1, UInt8[0x07, 0xe6, 0x02, 0x1c])) == pack(Date(2022, 2, 28))
@test Date(2022, 2, 28) == unpack(UInt8[0xd6, 0x01, 0x07, 0xe6, 0x02, 0x1c])
end
# =>
engine/msg_pack_ext.jl: Test Failed at .../msg_pack_ext.jl:25
Expression: Date(2022, 2, 28) == unpack(UInt8[0xd6, 0x01, 0x07, 0xe6, 0x02, 0x1c])
Evaluated: Dates.Date("2022-02-28") == MsgPack.Extension(1, UInt8[0x07, 0xe6, 0x02, 0x1c])
That makes sense to me. I haven’t done anything to map extension type 1 to my code. But I can't see anything in the MsgPack code or test suite that lets me do this. The discussion in #7 makes it look like the contributor was satisfied with receiving a MsgPack.Extension and handling it themselves?
- Dominant language
- Julia
- Stars
- 68
- Forks
- 20
- Avg merge
- 13d 12h
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaIO/MsgPack.jl
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
JuliaIO/MsgPack.jl#68 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
JuliaIO/MsgPack.jl#57 · 1 comment · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
JuliaIO/MsgPack.jl#52 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
JuliaIO/MsgPack.jl#48 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
JuliaIO/MsgPack.jl#46 ·
All issues in JuliaIO/MsgPack.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
question
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
brown-ccv/Chamber.jl#272 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JuliaAstro/SolarPosition.jl#143 ·
-
distributions
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
JuliaBayes/Wren.jl#404 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JuliaAI/MLJTransforms.jl#113 ·
Maintainers usually reply within 1 day