<FromGitter>
<asterite> you can do respose to_io and then probably from_io
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
Human_G33k has quit [Ping timeout: 258 seconds]
HumanG33k has joined #crystal-lang
ua has quit [Ping timeout: 246 seconds]
ua has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 260 seconds]
<FromGitter>
<j8r> `HTTP::Server::Response`?
<FromGitter>
<j8r> I don't see any `to_io` or `from_io`
<FromGitter>
<j8r> The framework can help, for example in Gripen the response is an object. Caching the response would be simply saving the object somewhere
<FromGitter>
<j8r> Why client response? I think he was talking about caching the server response?
<FromGitter>
<Blacksmoke16> didnt specify, just said `HTTP response`
<FromGitter>
<j8r> Maybe, then I don't see the point
<FromGitter>
<jwaldrip> I was, my use case is that I want to cache the response and reserve from cache in memory, redis, etc.
<FromGitter>
<Blacksmoke16> Wouldn't you be better off just storing the data then using etags
<FromGitter>
<Blacksmoke16> To determine if you need to update it
DTZUZU has joined #crystal-lang
<FromGitter>
<jwaldrip> I could, but I want caching to multiple clients
<FromGitter>
<jwaldrip> the use case is for CrystalShards.org. The data changes every few hours at the very most, I just want to cache the pages so that I dont have to keep hitting the DB for information. I could do some view caching in the controllers, but as a first pass, I was just hoping to make a handler
<FromGitter>
<Blacksmoke16> and in which case each page prob doesnt support the same caching mechanics so cant really use etags
<FromGitter>
<jwaldrip> right
<FromGitter>
<Blacksmoke16> so plan b, use the path as a key and the data is a value in redis with a ttl of an hour and call it a day?
<FromGitter>
<jwaldrip> correct
<FromGitter>
<Blacksmoke16> so whats the problem? that is totally doable
<FromGitter>
<jwaldrip> But since the response is all an IO, I need to be able to rewind the response output... and then gets_to_end to store the data right?
<FromGitter>
<jwaldrip> How can I just get a string oh whats been written to the response
<FromGitter>
<jwaldrip> without the headers and other stuff
<FromGitter>
<Blacksmoke16> we're talking about `HTTP::Server::Response` correct?
<FromGitter>
<Blacksmoke16> like what you get back if i curl'd your site
<FromGitter>
<jwaldrip> yes
<FromGitter>
<jwaldrip> the server response
<FromGitter>
<jwaldrip> This is what I have so far... but its grabbing the headers too
<FromGitter>
<Blacksmoke16> assuming you're streaming the response id imagine you would need to also stream the response to another IO to write to redis
<FromGitter>
<Blacksmoke16> otherwise if you're just writing in one go, could just copy it
<FromGitter>
<jwaldrip> can you IO copy the response
<FromGitter>
<Blacksmoke16> maybe?
<FromGitter>
<Blacksmoke16> or do something to wrap the actual response so that it can write the data to both things
<FromGitter>
<jwaldrip> Ill write a shard for it too
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<jwaldrip> I can simplify it too ;-)
<FromGitter>
<Blacksmoke16> 🎉
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
<FromGitter>
<mattrberry> Has there ever been talk about compiler warnings when creating a new instance variable outside of `initialize`? There have been a few times that I have misspelled an instance variable, which results in me creating a new instance variable rather than rebinding an existing one. For example, if I have the class ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I'd love it for crystal to warn me *at compile time*
<FromGitter>
... that I'm bringing a new instance variable into scope. It's all too often that the crystal vscode extension tab-completes a name in a way I didn't expect, and I end up in a situation like this [https://gitter.im/crystal-lang/crystal?at=5ee5415e7a7f8d2d63331cf9]
<FromGitter>
<codenoid> hi folks, how you doing, hope everything getting better
<FromGitter>
<Blacksmoke16> not that i know of, both have valid use caes
<FromGitter>
<Blacksmoke16> might be a case for ameba, `unused instance variable` or something
<FromGitter>
<mattrberry> Yeah, there's nothing inherently wrong with bringing a new instance variable into scope, but usually I'll still define all of my instance variables at the class level with their type, even if they're nilable
<FromGitter>
<mattrberry> This would have saved me a decent chunk of time a number of times
<FromGitter>
<Blacksmoke16> take an extra minute and read more carefully 😉
<FromGitter>
<Blacksmoke16> or id imagine unit tests would catch most of the issues
<FromGitter>
<mattrberry> Unit tests would likely catch most of those, but most of my code is generated automatically atm, and I don't have unit tests for everything :/
<FromGitter>
<Blacksmoke16> 😬 might not be a bad idea
<FromGitter>
<mattrberry> Don't currently have the patience to write unit tests for all 512 gameboy opcodes + weird instruction behavior + obscure hardware behavior :p
<FromGitter>
<Blacksmoke16> write the code that writes the tests ha
<FromGitter>
<mattrberry> ez.
coderobe has quit [Ping timeout: 256 seconds]
Human_G33k has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.8]
HumanG33k has quit [Ping timeout: 256 seconds]
<FromGitter>
<hanneskaeufler> Hey guys I'm lost right now trying to use the AST Visitor to visit all method definitions that have a return type of Nil. I can't figure out how to inspect the return type, and the compiler is giving me mixed signals. Code sample is here: https://play.crystal-lang.org/#/r/99gz
<FromGitter>
<Blacksmoke16> I'm not sure that's exactly a public API
<FromGitter>
<hanneskaeufler> Inspecting node.return_type.class says its a Crystal::Path, but using the `same?` method never returns true, and trying to access `.names` then says it's a `Crystal::Nop`, which I can't really follow ...
<FromGitter>
<hanneskaeufler> > I'm not sure that's exactly a public API ⏎ ⏎ Probably not, but still I'd like to make sense of it :D
coderobe has joined #crystal-lang
<FromGitter>
<Blacksmoke16> `Nop` means it doesnt have a return type restriction
<FromGitter>
<hanneskaeufler> mhm, so `Nop` and `nil` (nil literal`) both mean the same in that context?
<FromGitter>
<Blacksmoke16> no
<FromGitter>
<hanneskaeufler> Or why is `return_type` defined as `AstNode?`
<FromGitter>
<Blacksmoke16> first is `Nop`, 2nd is `Nil`, third is `Int32 | Nil`
<FromGitter>
<Blacksmoke16> do remember you're not dealing with normal types here
<FromGitter>
<Blacksmoke16> like that you use normally
<FromGitter>
<hanneskaeufler> but first one returns `nil` as `return_type`, doesn't it?
<FromGitter>
<Blacksmoke16> `Nil`
<FromGitter>
<Blacksmoke16> we're looking at the type of the return value, not the actual value, although in this case, yes it'll be `nil` itself
<FromGitter>
<Blacksmoke16> sec
<FromGitter>
<hanneskaeufler> I think what is confusing is trying to print debug this
<FromGitter>
<hanneskaeufler> yeah the type of return value is what interests me
<FromGitter>
<hanneskaeufler> the `nop` method's return type isn't `Nop` for me though
<FromGitter>
<Blacksmoke16> `Crystal::Nop`
<FromGitter>
<Blacksmoke16> er maybe not
<FromGitter>
<hanneskaeufler> ` pp! node.return_type.not_nil!` nil-exceptions for me :)
<FromGitter>
<hanneskaeufler> play.crystal.lang times our for me right now when executing, would demonstrate on there otherwise^^
<FromGitter>
<Blacksmoke16> is there an actual use case here? You could prob do something with macros maybe...
<FromGitter>
<hanneskaeufler> ah well, my mutation test framework again ... https://github.com/hanneskaeufler/crytic. I want to write a mutation that simply drops method calls. In order to make sure that the mutated code type-checks, I only want to drop calls inside methods that don't return anything for now ...
<FromGitter>
<hanneskaeufler> And to find all locations where I want to mutate, I visit the AST ...
<FromGitter>
<Blacksmoke16> hm
<FromGitter>
<hanneskaeufler> It seems like it should be possible but I can't figure out the condition for it :D
<FromGitter>
<Blacksmoke16> im assuming you know its only going to be methods that have a restriction AND is `Nil`
<FromGitter>
<hanneskaeufler> I figured, yes. Ideally I could get the type after the inference, but that's probably out of scope ...
<FromGitter>
<hanneskaeufler> or not possible with the AST visitors
<FromGitter>
<Blacksmoke16> something along those lines i guess
<FromGitter>
<Blacksmoke16> @fenicks anything specific you're trying to do?
<FromGitter>
<fenicks> @Blacksmoke16 yep I'm implementing test for Crystal RethinkDB driver and 1 of the tests need string to be encoded in binary to check the RethinkDB::binary call.