Sha256: 84bc126aecd062cf1328c2a93574be4f7bc90885e4e05f2311ffd978377dbd71

Contents?: true

Size: 985 Bytes

Versions: 3

Compression:

Stored size: 985 Bytes

Contents

module Lanes
    module API

        class PubSub

            def self.publish(channel, data)
                MessageBus.publish channel, data #Oj.dump(data, mode: :compat)
            end

            def self.initialize(api)
                return unless Extensions.require_pub_sub?
                require "oj"
                require_relative "updates"
                require 'message_bus'
                api.use MessageBus::Rack::Middleware

                # Use OJ - it encodes dates properly as ISO 8601
                # https://github.com/moment/moment/issues/1407
                Oj.mimic_JSON()
                # # Requiring json here seems to stop conflicts when requiring json in other files.
                begin
                    require 'json'
                rescue Exception
                    # ignore
                end
                ::MessageBus.redis_config = Lanes.config.redis
                Updates.relay!
            end

        end

    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.1.2 lib/lanes/api/pub_sub.rb
lanes-0.1.0 lib/lanes/api/pub_sub.rb
lanes-0.0.8 lib/lanes/api/pub_sub.rb