<Papierkorb>
If one's careful that thing doesn't even crash. Nice :P
<FromGitter>
<fridgerator> lol
<FromGitter>
<fridgerator> well I just released crecto v0.4.0, which includes Multi / Transactions
<Papierkorb>
fridgerator, neat!
fazibear has quit [Ping timeout: 240 seconds]
go|dfish has quit [Quit: SIGQUIT]
go|dfish has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
triangles has quit [Quit: Leaving]
<sija>
is there any way to install global exception handler?
<sija>
(other than redefining `raise` which feels hack-ish)
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
Raimondi has quit [Ping timeout: 268 seconds]
pawnbox has joined #crystal-lang
<FromGitter>
<schoening> @sija what are you working on, doesn't dependency injection work for your usecase?
<Yxhuvud>
sija: wrap the file you compile with begin .. rescue ..end?
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
marciogm has quit [Ping timeout: 240 seconds]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
akwiatkowski has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz has joined #crystal-lang
Raimondi has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
mark_66 has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
bjz has quit [Ping timeout: 240 seconds]
akwiatkowski has quit [Ping timeout: 260 seconds]
elia has joined #crystal-lang
bjz has joined #crystal-lang
unshadow has joined #crystal-lang
<unshadow>
How can I buffer a socket read ? lets say i got this: buffer_a=Bytes(10).new; socket.read(buffer_a_); now I want to move the data I got in the buffer to the "whole" package and buffer more data
fazibear has joined #crystal-lang
<unshadow>
Maybe I can ask it better, how can I join two or more Slice(UInt8) objects ?
fazibear has quit [Ping timeout: 268 seconds]
pawnbox has joined #crystal-lang
fazibear has joined #crystal-lang
Raimondii has joined #crystal-lang
fazibear has quit [Ping timeout: 240 seconds]
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
fazibear has joined #crystal-lang
elia has quit [Quit: (IRC Client: textualapp.com)]
gloscombe has joined #crystal-lang
fazibear has quit [Ping timeout: 260 seconds]
fazibear has joined #crystal-lang
A124 has joined #crystal-lang
fazibear has quit [Quit: leaving]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
akwiatkowski has joined #crystal-lang
sz0 has joined #crystal-lang
fazibear has joined #crystal-lang
<RX14>
unshadow, well first of all IOs tend to be buffered and peakable by default now
<RX14>
second you want to look at copy_from and move_from
fazibear has quit [Quit: leaving]
fedruantine has quit [Ping timeout: 240 seconds]
fazibear has joined #crystal-lang
fazibear has left #crystal-lang [#crystal-lang]
kubaxvx has quit [Ping timeout: 260 seconds]
<unshadow>
Thanks RX14
fedruantine has joined #crystal-lang
fazibear has joined #crystal-lang
kubaxvx has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
fazibear has quit [Client Quit]
fazibear has joined #crystal-lang
<RX14>
unshadow, typically you'd create one "large" slice then reuse that slice for moving bits of data around in it
<RX14>
it can get quite complex though
<RX14>
as IO#read doesn't have to return the number of bytes you ask for
<unshadow>
because the IO is non_blocking which means that Maybe I'll need more then one read
<RX14>
yeah thats what read_fully is for
<RX14>
if you know the exact amount of data you want
<unshadow>
but then it's blocking :)
<RX14>
what?
<unshadow>
I want a non_blocking buffer loop
<RX14>
what do you mean by "non_blocking"
<RX14>
what other work do you need to do
<RX14>
and why can't it be done in a fiber
<unshadow>
It can, my issue is that read_fully is blocking , I want to use non_blocking IO, but, non_blocking IO might return imidetally without reading X bytes, and this is why I want it to loop again to see if there is more data to be read
<RX14>
non_blocking = true/false has NO affect on the semantics of IO#read
<RX14>
they only affect the scheduler and how IO is handled internally
<RX14>
IO#read will block either way (but it can return only 1 byte)
Qchmqs has joined #crystal-lang
<RX14>
IO#read_fully will block but will read as much as possible
<RX14>
it will always return the amount of data you ask for
<RX14>
UNLESS you reach EOF
<unshadow>
A question then, socket has 50 redable bytes. if I use socket.read_fully(100), will that return with 50 bytes read or get stuck waiting for 50 more ?
<RX14>
it'll block
<RX14>
you're meant to block
fazibear has quit [Quit: leaving]
<RX14>
if you only had 50 bytes but you wanted 100, could you do anything with those 50 bytes?
<RX14>
if no, you definitely want read_fully
<unshadow>
yes, it will block, but, read, wont block. lets say I would have called buff = Slice(100).new; socket.read(slice), it will return imidiatly with 50 bytes out of the 100 filled with the new data
<RX14>
it's about whether you want data as soon as possible (usually because you don't know how much data you want, so you're waiting for a byte sequence)
fazibear has joined #crystal-lang
<RX14>
or whether you know exactly how much data you want to the byte, and just want a single method to get all of that data
<unshadow>
Yes, I don't know how much data is going to come in, but, I want also to make sure I read everything avilable (EOF), this is why a loop around read is what I want
<unshadow>
does it make sense ? or am I'm looking at it wrong ?
<RX14>
it doesn't make sense to me
<RX14>
the problem with "reading until the end" into a slice is you don't know how big the data is
<RX14>
so you could just get stuck in a loop of allocating larger slices
<RX14>
untiul you run out of ram
<RX14>
what, more generally, are you trying to do unshadow
<unshadow>
I'm doing a proxy, TCP proxy between two machines, as I dont know the protocol (tcp level) I just want to read from a and pass to b, read from b and pass back to a.
<RX14>
ok, so you don't know how much you want to read
<unshadow>
exactly
<unshadow>
but I want to make sure machine b got all it needed from a
<RX14>
isn't that as simple as read into slice, write (valid part of) slice to another IO