Sha256: 86e7f8afc7cbd78367bf770aed8bb2afca1f7355a6b8863b2ff2943af45ca5f7

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 KB

Contents

module Dynflow
  module Connectors
    class Abstract
      include Algebrick::TypeCheck
      include Algebrick::Matching

      def start_listening(world)
        raise NotImplementedError
      end

      def stop_receiving_new_work(_, timeout = nil)
        raise NotImplementedError
      end

      def stop_listening(world, timeout = nil)
        raise NotImplementedError
      end

      def terminate
        raise NotImplementedError
      end

      def send(envelope)
        raise NotImplementedError
      end

      # we need to pass the world, as the connector can be shared
      # between words: we need to know the one to send the message to
      def receive(world, envelope)
        Type! envelope, Dispatcher::Envelope
        Telemetry.with_instance { |t| t.increment_counter(:dynflow_connector_envelopes, 1, :world => world.id, :direction => 'incoming') }
        match(envelope.message,
              (on Dispatcher::Ping do
                 response_envelope = envelope.build_response_envelope(Dispatcher::Pong, world)
                 send(response_envelope)
               end),
              (on Dispatcher::Request do
                 world.executor_dispatcher.tell([:handle_request, envelope])
               end),
              (on Dispatcher::Response do
                 world.client_dispatcher.tell([:dispatch_response, envelope])
               end))
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
dynflow-1.3.0 lib/dynflow/connectors/abstract.rb
dynflow-1.2.3 lib/dynflow/connectors/abstract.rb
dynflow-1.2.2 lib/dynflow/connectors/abstract.rb
dynflow-1.2.1 lib/dynflow/connectors/abstract.rb
dynflow-1.2.0 lib/dynflow/connectors/abstract.rb
dynflow-1.2.0.pre1 lib/dynflow/connectors/abstract.rb
dynflow-1.1.6 lib/dynflow/connectors/abstract.rb
dynflow-1.1.5 lib/dynflow/connectors/abstract.rb
dynflow-1.1.4 lib/dynflow/connectors/abstract.rb
dynflow-1.1.3 lib/dynflow/connectors/abstract.rb
dynflow-1.1.2 lib/dynflow/connectors/abstract.rb
dynflow-1.1.1 lib/dynflow/connectors/abstract.rb