{"action":"created","issue":{"url":"https://api.github.com/repos/socketry/async-redis/issues/3","repository_url":"https://api.github.com/repos/socketry/async-redis","labels_url":"https://api.github.com/repos/socketry/async-redis/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/socketry/async-redis/issues/3/comments","events_url":"https://api.github.com/repos/socketry/async-redis/issues/3/events","html_url":"https://github.com/socketry/async-redis/issues/3","id":395371186,"node_id":"MDU6SXNzdWUzOTUzNzExODY=","number":3,"title":"client.call should start reactor for console debugging workflows","user":{"login":"matti","id":3893,"node_id":"MDQ6VXNlcjM4OTM=","avatar_url":"https://avatars1.githubusercontent.com/u/3893?v=4","gravatar_id":"","url":"https://api.github.com/users/matti","html_url":"https://github.com/matti","followers_url":"https://api.github.com/users/matti/followers","following_url":"https://api.github.com/users/matti/following{/other_user}","gists_url":"https://api.github.com/users/matti/gists{/gist_id}","starred_url":"https://api.github.com/users/matti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matti/subscriptions","organizations_url":"https://api.github.com/users/matti/orgs","repos_url":"https://api.github.com/users/matti/repos","events_url":"https://api.github.com/users/matti/events{/privacy}","received_events_url":"https://api.github.com/users/matti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2019-01-02T20:33:00Z","updated_at":"2019-01-03T14:09:03Z","closed_at":null,"author_association":"NONE","body":"currently if you try to do what all the best programmers do - use repl and try things out until it works and then you copy/paste the code - you can't do it because:\r\n\r\n```\r\n[1] pry(main)> c = Async::Redis::Client.new(Async::IO::Endpoint.tcp(ENV['REDIS_HOST'], 6379))\r\n=> #<Async::Redis::Client:0x000055f0a598b3b8\r\n @endpoint=#<Async::IO::HostEndpoint:0x000055f0a598b458 @options={}, @specification=[\"redis\", 6379, nil, 1]>,\r\n @pool=#<Async::Redis::Pool:0x000055f0a598b340 @active=0, @available=#<Async::Notification:0x000055f0a598b2f0 @waiting=[]>, @constructor=#<Proc:0x000055f0a598b278@/usr/local/bundle/gems/async-redis-0.3.1/lib/async/redis/client.rb:109>, @limit=nil, @resources=[]>,\r\n @protocol=Async::Redis::Protocol::RESP>\r\n[2] pry(main)> c.call \"BLPOP\", \"SLEEP\", 1\r\nRuntimeError: No async task available!\r\nfrom /usr/local/bundle/gems/async-1.12.0/lib/async/task.rb:161:in `current'\r\n```\r\n\r\nSo what about changing this:\r\n```\r\ndef call(*arguments)\r\n  @pool.acquire do |connection|\r\n    connection.write_request(arguments)\r\n    return connection.read_response\r\n  end\r\nend\r\n```\r\nto:\r\n```\r\ndef call(*arguments)\r\n  Async.run do\r\n    @pool.acquire do |connection|\r\n      connection.write_request(arguments)\r\n      return connection.read_response\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nor even:\r\n```\r\ndef call(*arguments)\r\n  done = Async::Notification.new\r\n  Async.run do |t|\r\n    response = nil\r\n    @pool.acquire do |connection|\r\n      connection.write_request(arguments)\r\n      done.signal connection.read_response\r\n    end\r\n    return done.wait\r\n  end\r\nend\r\n```\r\n\r\n*note*: I didn't even monkeypatch that locally, but I think you get the idea?\r\n\r\nAlthough https://github.com/socketry/async#asyncreactorrun says\r\n\r\n>The cost of using Async::Reactor.run is minimal for initialization/server setup, but is not ideal for per-connection tasks.\r\n\r\nbut I think it would be ideal for programmer happiness?\r\n"},"comment":{"url":"https://api.github.com/repos/socketry/async-redis/issues/comments/451153078","html_url":"https://github.com/socketry/async-redis/issues/3#issuecomment-451153078","issue_url":"https://api.github.com/repos/socketry/async-redis/issues/3","id":451153078,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTE1MzA3OA==","user":{"login":"matti","id":3893,"node_id":"MDQ6VXNlcjM4OTM=","avatar_url":"https://avatars1.githubusercontent.com/u/3893?v=4","gravatar_id":"","url":"https://api.github.com/users/matti","html_url":"https://github.com/matti","followers_url":"https://api.github.com/users/matti/followers","following_url":"https://api.github.com/users/matti/following{/other_user}","gists_url":"https://api.github.com/users/matti/gists{/gist_id}","starred_url":"https://api.github.com/users/matti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matti/subscriptions","organizations_url":"https://api.github.com/users/matti/orgs","repos_url":"https://api.github.com/users/matti/repos","events_url":"https://api.github.com/users/matti/events{/privacy}","received_events_url":"https://api.github.com/users/matti/received_events","type":"User","site_admin":false},"created_at":"2019-01-03T14:09:03Z","updated_at":"2019-01-03T14:09:03Z","author_association":"NONE","body":"@huba \r\n\r\n\"With this suggestion we end up with an Async::Stop being raised.\" - why? I tried to write a test for this and I just get the actual exception, not `Async::Stop`.  That said, I have seen `Async::Stop` being raised, but I'm not able to write any code that raises `Async::Stop` here.\r\n"}}
{"actor":{"display_login":"matti"}}