ruby-on-railsrubyopalrbhyperstack

Is there a way to disconnect console messaging from Hyperstack message queue?


In Hyperstack every state change enters a message queue through a websocket mechanism to inform every application client for model/app state changes. So if you update a model from my browser sessions, everyone else connected at the time can see it in their session (if there are the necessary permissions).

This is even done from console 'sessions'. You change a model from Rails console and changes automatically propagate to all connected web clients.

For this to be done the web application part has to be operational (i.e. rails server, must be up and running).

The problem is that there are two situations where you might not want console updates to propagate to the client:

  1. when rails server is not operational, for any reason and you want to interact with the application through it's console (until rails server is up again)

  2. You want to perform batch updates through console or rake tasks and you don't want the overhead of keeping clients informed.

Is there a way to to quickly turn of messaging from the console or some kind of toggle method for that purpose?


Solution

  • If the rails server is not up it will not try to send messages (however see note at end)

    But the case of a rake task that you want to run while the server IS up, is interesting. I don't think there is any published way to turn off the "remote process -> server" push, but this patch will accomplish the same:

    module Hyperstack 
      def self.send_to_server(*args) 
        # drop the message on the floor
      end
    end
    

    Just stick that in the rake task.

    Regarding the server "not being up" the one case that does not work is if the server is in fact "up" but simply never responds. See https://github.com/hyperstack-org/hyperstack/issues/144 for details. If you are trying to debug a server problem then the same patch above will help until that issue is fixed.