Sha256: c4f957880e6c4ae8a77b990cc37729e938752d6ab1038ccf28a0d8643c21a185

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

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

      Execution = type do
        fields! execution_plan_id: String
      end

      Ping = type do
        fields! receiver_id: String
      end

      Status = type do
        fields! receiver_id: String,
                execution_plan_id: type { variants String, NilClass }
      end

      variants Event, Execution, Ping, Status
    end

    Response = Algebrick.type do
      variants Accepted = atom,
               Failed   = type { fields! error: String },
               Done     = atom,
               Pong     = atom,
               ExecutionStatus = type { fields! execution_status: Hash }
    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

13 entries across 13 versions & 1 rubygems

Version Path
dynflow-1.0.5 lib/dynflow/dispatcher.rb
dynflow-1.0.4 lib/dynflow/dispatcher.rb
dynflow-1.0.3 lib/dynflow/dispatcher.rb
dynflow-1.0.2 lib/dynflow/dispatcher.rb
dynflow-1.0.1 lib/dynflow/dispatcher.rb
dynflow-1.0.0 lib/dynflow/dispatcher.rb
dynflow-0.8.37 lib/dynflow/dispatcher.rb
dynflow-0.8.36 lib/dynflow/dispatcher.rb
dynflow-0.8.35 lib/dynflow/dispatcher.rb
dynflow-0.8.34 lib/dynflow/dispatcher.rb
dynflow-0.8.33 lib/dynflow/dispatcher.rb
dynflow-0.8.32 lib/dynflow/dispatcher.rb
dynflow-0.8.31 lib/dynflow/dispatcher.rb