Sha256: 755916b5716a191ce332fced3378cf82122d59c1d0b9d7f045c007d115227f8b

Contents?: true

Size: 1.49 KB

Versions: 25

Compression:

Stored size: 1.49 KB

Contents

module Dynflow
  module Dispatcher
    Request = Algebrick.type do
      Event = type do
        fields! execution_plan_id: String,
                step_id:           Fixnum,
                event:             Object
      end

      Execution = type do
        fields! execution_plan_id: String
      end

      Ping = type do
        fields! receiver_id: String
      end

      variants Event, Execution, Ping
    end

    Response = Algebrick.type do
      variants Accepted = atom,
               Failed   = type { fields! error: String },
               Done     = atom,
               Pong     = atom
    end

    Envelope = Algebrick.type do
      fields! request_id: Integer,
              sender_id: String,
              receiver_id: type { variants String, AnyExecutor = atom, UnknownWorld = atom },
              message: type { variants Request, Response }
    end

    module Envelope
      def build_response_envelope(response_message, sender)
        Envelope[self.request_id,
                 sender.id,
                 self.sender_id,
                 response_message]
      end
    end

    module Event
      def to_hash
        super.update event: Base64.strict_encode64(Marshal.dump(event))
      end

      def self.product_from_hash(hash)
        super(hash.merge 'event' => Marshal.load(Base64.strict_decode64(hash.fetch('event'))))
      end
    end
  end
end

require 'dynflow/dispatcher/abstract'
require 'dynflow/dispatcher/client_dispatcher'
require 'dynflow/dispatcher/executor_dispatcher'

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
dynflow-0.8.24 lib/dynflow/dispatcher.rb
dynflow-0.8.23 lib/dynflow/dispatcher.rb
dynflow-0.8.22 lib/dynflow/dispatcher.rb
dynflow-0.8.21 lib/dynflow/dispatcher.rb
dynflow-0.8.20 lib/dynflow/dispatcher.rb
dynflow-0.8.19 lib/dynflow/dispatcher.rb
dynflow-0.8.18 lib/dynflow/dispatcher.rb
dynflow-0.8.17 lib/dynflow/dispatcher.rb
dynflow-0.8.16 lib/dynflow/dispatcher.rb
dynflow-0.8.15 lib/dynflow/dispatcher.rb
dynflow-0.8.14 lib/dynflow/dispatcher.rb
dynflow-0.8.13 lib/dynflow/dispatcher.rb
dynflow-0.8.12 lib/dynflow/dispatcher.rb
dynflow-0.8.11 lib/dynflow/dispatcher.rb
dynflow-0.8.10 lib/dynflow/dispatcher.rb
dynflow-0.8.9 lib/dynflow/dispatcher.rb
dynflow-0.8.8 lib/dynflow/dispatcher.rb
dynflow-0.8.7 lib/dynflow/dispatcher.rb
dynflow-0.8.6 lib/dynflow/dispatcher.rb
dynflow-0.8.5 lib/dynflow/dispatcher.rb