<FromGitter>
<jwoertink> Aside from `Array#[]` is there another array method to take a slice of an array by passing an offset and a limit? Something similar to Ruby's `Array#slice`
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: Leaving]
That_Guy_Anon1 has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 245 seconds]
<jeromegn>
any way to get the file descriptor from an http request / response?
<FromGitter>
<bew> @jwoertink don't think so, are you missing sth?
rohitpaulk has joined #crystal-lang
<FromGitter>
<bew> jeromegn I don't get it.. a file descriptor is basically an identifier of an open file in a process, I don't think it makes any sense to get it from an http request. What are you trying to do? What's your usecase
<jeromegn>
I want the master process to fork processes and then dispatch sockets to those forks
<jeromegn>
depending on certain criteria
<jeromegn>
I created bindings for https://github.com/sharvil/flingfd (just 2 useful functions) and wanted to try it out with a simple example
<jeromegn>
but I guess maybe it's not well suited for http :D
<jeromegn>
there's no accessing the underlying socket for an http request. I could expose it some other way though
<FromGitter>
<faustinoaq> hehe, so funny XD
<FromGitter>
<bew> hmm I don't know, and don't have time right now to really think about it..
<jeromegn>
hehe all good
<FromGitter>
<bew> jeromegn you can always do the same basic example as in the readme
<FromGitter>
<bew> of flingfd
<jeromegn>
I'm assuming that works fine
<FromGitter>
<bew> But I'd suggest to implement this in Crystal, to have support for the crystal concurrency model. 'cause using this library will completely block the crystal process when you do `flingfd_simple_recv` and other fibers won't be able to run..
<jeromegn>
indeed
<jeromegn>
once I know it "can" work, I'll probably do that
<FromGitter>
<bew> @faustinoaq :D
<FromGitter>
<bew> then try the given example, you'll see if it 'can' work ;)
<FromGitter>
<jwoertink> @bew no. The `[a...b]` method works, but requires an additional calculation for paginating. Using `slice` would be cleaner
<FromGitter>
<bew> what do you mean 'paginating' ?
<FromGitter>
<jwoertink> where you take a collection and split it in to smaller collections that you can associate with a number
<FromGitter>
<jwoertink> being able to do `collection.slice(offset, limit)` would be nice
<FromGitter>
<bew> there is also `def (start : Int, count : Int)`, maybe that's less calculations?
<FromGitter>
<jwoertink> oh, interesting. Let me try that
<FromGitter>
<jwoertink> nice! Thanks @bew. That works
<FromGitter>
<bew> yw ;) actuall that's how `def (range : Range)` is implemented :P
<FromGitter>
<bew> checkout the stdlib sources from time to time, you'll learn a lot ;)
duane has joined #crystal-lang
<jeromegn>
@bew I made a TCPServer instead and copy pasted some code to process http requests headers and such. it works, I can pass sockets between process just fine :)
<wmoxam>
Am trying to compile crystal from git on OpenBSD using v0.24.2, am not sure what to look at next :P
duane has quit [Ping timeout: 245 seconds]
<wmoxam>
ah I bet this is a ulimit thing :p
sz0 has quit [Quit: Connection closed for inactivity]
pabs has quit [Ping timeout: 256 seconds]
pabs has joined #crystal-lang
<FromGitter>
<Grabli66> Hi! There is Future class in crystal. But why it's not documented? It's marked with # :nodoc: It's for internal use only? I think it's much better than "spawn" :)
alex`` has joined #crystal-lang
<FromGitter>
<bew> Why?
<FromGitter>
<Grabli66> Cause it has many useful things, like method "get", that blocks and wait for result. And it catches exceptions from fiber
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
notdaniel has quit [Quit: Leaving]
That_Guy_Anon1 has quit [Quit: Leaving]
mps has left #crystal-lang [#crystal-lang]
johndescs_ has joined #crystal-lang
johndescs_ is now known as johndescs
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 252 seconds]
Raimondii is now known as Raimondi
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
<FromGitter>
<straight-shoota> I don't know why it is undocumented, but it's probably going to be removed from stdlib.
<FromGitter>
<Grabli66> But why?
rohitpaulk has quit [Ping timeout: 245 seconds]
<crystal-gh>
[crystal] sdogruyol pushed 1 new commit to master: https://git.io/vhv5l
<FromGitter>
<girng> I'm using this as a server.cr https://paste.ee/p/y8GD2 and when I load up a bunch of connections, and close them. I'll get `Connections: 11` lingering around, or that value will be more. Dependent how many sockets I connect and close. And yes, I am terminating the connection from my clientside (I installed CurrPorts on windows), and all the sockets get closed. `netstat -ntu` will show 11 established connections
<FromGitter>
... as well. What causes these sockets to be lingering in the crystal app, is it an issue with an OpenVZ container? I should try this on KVM VPS maybe?
<FromGitter>
<bararchy> @girng you are closing them `only` on the client side?
<FromGitter>
<girng> Yes, and in server.cr
<FromGitter>
<bararchy> You just wait endlessly to the client.read
<FromGitter>
<bararchy> What is your read timeout ?
<FromGitter>
<girng> Not sure, never set it. I'll set it to something and try again
<FromGitter>
<bararchy> Do a reasonable read_timeout, something like a minute?
<FromGitter>
<bararchy> depends on your game
<FromGitter>
<bararchy> how much time does it makes sense to wait for a client to write info?
<FromGitter>
<girng> No idea, it depends on their action. I can add in a ping interval or something?
<FromGitter>
<bararchy> yeha
<FromGitter>
<bararchy> its a good idea
<FromGitter>
<bararchy> if they don't respond to ping in 30 sec kill the socket
<FromGitter>
<girng> @bararchy Thank you sir, fixed it
<FromGitter>
<bararchy> 👍 :)
<jeromegn>
is there a way to ensure something always runs in the root fiber? I think I'll probably need to use a channel, receiving from the root fiber, to run "tasks" sent from all over the place.
<FromGitter>
<faustinoaq> jeromegn, `Fiber.yield` or `sleep`
<jeromegn>
if I understand correctly, this would just tell the schedule to run a different fiber, but it wouldn't guarantee stuff ran in the root fiber
<FromGitter>
<girng> @bararchy Hey, well would you look at that! Now that the connections close, I loaded up tens of thousands of connections. Closed them all, and the memory usage went back down!
<FromGitter>
<bararchy> :)
<FromGitter>
<bararchy> happy to help
<FromGitter>
<bararchy> make sure you configuer ulinmit for the service
<FromGitter>
<girng> Hah, yeah.
<FromGitter>
<bew> @Grabli66 why would you want async/await when everything is already asynchronous?
<txdv>
file io is blocking
<FromGitter>
<Grabli66> Cause i think that futures and async/await is simple in usage than fibers and channels.
<FromGitter>
<bew> Not really, if it's going to block, the fiber is paused and another fiber will run until the file io unblock, so it doesn't block the whole thread, things can still happen
<FromGitter>
<bew> txdv when you say blocking, you meant on the thread level?
<FromGitter>
<bew> @Grabli66 do you know how to use fibers/channels? It looks quite simple to me
<FromGitter>
<Grabli66> Yes. And i think futures are better :) simpler. You can chain them, you can catch their exceptions, you can await of their execution.
<FromGitter>
<bew> You can go implement them in Crystal if you want, i'm sure you 'll help someone else ;)
<FromGitter>
<Grabli66> There is Future class in crystal
<FromGitter>
<bew> Not that you can use, but you can implement one, documented, that will stay for sure, and with more features! The one you saw is an implementation detail for some method, it's not to be used directly i guess
<FromGitter>
<Grabli66> Too hard :)
<txdv>
bew: not for file IO
<FromGitter>
<bew> Show me the code if you have time, i don't believe you.. Where is it not using evened IO?
<FromGitter>
<bew> evented*
<txdv>
:D
<txdv>
how can i prove something that does not exist bew?
<crystal-gh>
[crystal] sdogruyol opened pull request #6117: Update project status in README (master...update-readme) https://git.io/vhfBu
<FromGitter>
<ArtLinkov> hey guys, I have a situation where I have and array of array of array (etc..) for an unknown number of arrays within an arrays
<RX14>
bcardiff is back btw
<RX14>
i'm sure you noticed if you were looking at the issue tracker
tilpner has quit [Read error: Connection reset by peer]
tilpner has joined #crystal-lang
<FromGitter>
<bew> Oh nice ;) (didn't notice yet, it must be on my unsubscribed issues)
<FromGitter>
<sdogruyol> would love to have more input from the community
<FromGitter>
<bew> Yeah good idea!
<FromGitter>
<Grabli66> May be set 1.0 version to crystal? :) And say everyone that it's production ready.
<FromGitter>
<bew> Huh no?
<Vexatos>
sounds like a very good idea
<FromGitter>
<sdogruyol> @Grabli66 that'd be a really YOLO way of doing it :)
<FromGitter>
<yxhuvud> speaking of YOLO, my latest commit have these stats: 2066 files changed, 25978 insertions(+), 25933 deletions(-). Lets just say I wish ruby had `tool format`
<FromGitter>
<sdogruyol> I'd call that `brave`
<FromGitter>
<sdogruyol> :D
<FromGitter>
<epergo> mm maybe specify current version and a link to the changelog, list companies using it in production, add top 5 sponsors and say that crystal core team main objectives are parallelism and windows support (if these are the objectives ofc)