Sha256: 00c749b7298359805fe0948eaf15431157930482a0bd4f65d68b21a2a078728b

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

require 'eventmachine'
require 'bert'

TRACE = 5
DEBUG = 4
INFO  = 3
WARN  = 2
ERROR = 1
FATAL = 0

module Envoy

  module Protocol
    include EM::P::ObjectProtocol
    
    VERBOSITIES = %w"FATAL ERROR WARN\  INFO\  DEBUG TRACE"
    
    def verbosity
      @verbosity ||= [FATAL, [TRACE, @options[:verbosity] || 3].min].max
    end
      
    module Serializer
      def self.dump(object)
        BERT.encode(object)
      end
      def self.load(data)
        BERT.decode(data)
      end
    end
    
    def serializer
      Serializer
    end
    
    def send_object *args
      super(args.size > 1 ? BERT::Tuple[*args] : args[0])
    end
    
    def receive_object ((command, *args))
      __send__("receive_#{command}", *args)
    end
    
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
envoy-proxy-0.2.3 lib/envoy/protocol.rb
envoy-proxy-0.2.2 lib/envoy/protocol.rb