Comments (7)
If I'm not mistaken this can be handled by setting the read timeout on the socket.
from msgpack-crystal.
I do not think a timeout on the read is the answer. What if the other end does not have anymore data to send for a while. A useless example would be a server periodically sending an integer say every 60s.
I think the lexer should not read from the IO until the unpacker actually asks for data.
from msgpack-crystal.
Is this what you meant?
from msgpack-crystal.
Wow that was fast :-) Yes it was something like that. I am not sure it solves it completely though. I hacked up this little example to illustrate. Maybe I got it wrong but it doesn't see the last int.
require "socket"
require "msgpack"
def process(client)
puts "client connected"
unpacker = MessagePack::Unpacker.new(client)
loop do
v = unpacker.read_value
puts "server received #{v}"
end
ensure
client.close
end
server = TCPServer.new "127.0.0.1", 9000
socket = TCPSocket.new "127.0.0.1", 9000
packer = MessagePack::Packer.new(socket)
(1..3).each do |i|
packer.write(i)
puts "client wrote #{i}"
end
loop { spawn process(server.accept) }
Output:
client wrote 1
client wrote 2
client wrote 3
client connected
server received 1
server received 2
from msgpack-crystal.
Right, the unpacker is doing the same as the lexer was. Adding this example as a test and then I will fix the unpacker.
from msgpack-crystal.
Excellent!
from msgpack-crystal.
I've created a new branch with the new spec that now passes, but for now I had to introduce a new parser to make the mapping work.
from msgpack-crystal.
Related Issues (20)
- Packing array of hashes HOT 11
- Failed giving version HOT 1
- not compiled with crystal 0.17
- Parsing an unknown data structure. HOT 1
- not correct handle union type in mapping
- Support for nested Hash HOT 2
- Crash in mapping HOT 3
- Error while building with Crystal 0.21 HOT 1
- Add support for type extension HOT 4
- Support tarantool serializable HOT 3
- Support for missing or optional HOT 1
- Bad process on nil HOT 2
- The fix of #49 doesn't cover type restriction. HOT 1
- Broken stream reading, when type mismatch
- Typo
- Can't infer the type of instance variable '@var_present' HOT 5
- Shall not include Time conversion by default HOT 11
- Missing Timestamp extension type HOT 2
- have Serializable override inspect? HOT 2
- Type discriminator HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msgpack-crystal.