Code Monkey home page Code Monkey logo

Comments (19)

geremyCohen avatar geremyCohen commented on July 30, 2024

hmm.. looks pretty boilerplate. how often do you get this, and how fast are you publishing ?

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

@geremyCohen I've isolated the issue a bit more. Check out the updated code above.

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

Are you using any other EM-based code that may be stopping/restarting the reactor ? And please tell me how often it occurs, how fast you are publishing?

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

ok, thanks, I didnt get the page update until just now.

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

This is strange. Seems like some sort of scoping issue on the callback.

# This works

      @@pn.here_now(
          :channel => 'stacks',
          :callback => method(:puts)
      )

but

# This does not work

      @@pn.here_now(
          :channel => 'stacks',
          :callback => method(:callback)
      )

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

wait, thats not it. still researching...

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

@geremyCohen thanks... I can't seem to figure it out. Do you have a hack that would work in the interim?

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

I see the issue, and I will see if I can find a workaround or fix for you...

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

Does your app require EM anywhere else?

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

Not in any of my files. Here are my gem's

Gems included by the bundle:
  * activesupport (4.0.0)
  * addressable (2.3.5)
  * ansi (1.4.3)
  * atomic (1.1.10)
  * aws-sdk (1.11.3)
  * builder (3.2.2)
  * bundler (1.3.5)
  * commander (4.1.3)
  * cookiejar (0.3.0)
  * em-http-request (1.1.0)
  * em-socksify (0.3.0)
  * eventmachine (1.0.3)
  * factory_girl (4.2.0)
  * hashie (2.0.5)
  * highline (1.6.19)
  * hoe (3.6.3)
  * http_parser.rb (0.6.0.beta.2)
  * i18n (0.6.4)
  * json (1.8.0)
  * macaddr (1.6.1)
  * minitest (4.7.5)
  * minitest-reporters (0.14.20)
  * multi_json (1.7.7)
  * nokogiri (1.5.10)
  * powerbar (1.0.11)
  * promise (0.3.0)
  * pubnub (3.3.0.7)
  * rack (1.5.2)
  * rack-protection (1.5.0)
  * rack-test (0.6.2)
  * rake (10.1.0)
  * shotgun (0.9)
  * simple_mock (0.0.2)
  * sinatra (1.4.3)
  * systemu (2.5.2)
  * terminal-table (1.4.5)
  * test-unit (1.2.3)
  * thread_safe (0.1.0)
  * tilt (1.4.1)
  * tzinfo (0.3.37)
  * uuid (2.3.7)
  * uuidtools (2.1.4)
  * yajl-ruby (1.1.0)

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

My Gemfile is probably more helpful:

source 'https://rubygems.org'

gem 'aws-sdk', '~> 1.0'
gem "pubnub", "~> 3.3.0.7"
gem 'sinatra'
gem 'shotgun'
gem 'commander'
gem 'terminal-table'
gem 'promise'

group :test do
    gem "test-unit", "1.2.3"
    gem "rack-test"
    gem "simple_mock", "~> 0.0.2"
    gem "factory_girl", "~> 4.0"
    gem "minitest-reporters"
end

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

The issue occurs because we are chaining calls. This is an issue with this version of the gem. Our new gem is in closed beta that lets you chain stuff... let me know if you'd be interested in checking it out.

In the meantime, the easiest workaround for you is to use our blocking publish for your publish: https://github.com/pubnub/ruby/blob/master/3.3/app/models/blocking_pub.rb

This way, there is no race condition between the two operations.

But real solution is in new version, let me know if you are interested in checking it out.

geremy

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

@geremyCohen can I ask why callbacks are used at all? I don't really see the reason for non-blocking in the case of here_now or publish at least...

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

The new gem lets you choose whether or not to use callbacks or blocks, and whether to block or not in the response. :)

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

In general, if you are concerned about server response before continuing, you can block and wait for it and handle it as it happens. Otherwise, if you choose to be fully async and not block using callbacks, you can do that as well.

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

@geremyCohen eta on the new gem?

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

I can send it to you... contact us at support @ pubnub and we'll set you up (its a closed beta)

from ruby.

GoodWriteHQ avatar GoodWriteHQ commented on July 30, 2024

done.

from ruby.

geremyCohen avatar geremyCohen commented on July 30, 2024

cool. we also tested your code on it successfully. I'll followup shortly offline via email.

from ruby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.