Sha256: c46114c83e681f12cd8176dc76833a7c70e4f935c8265d5c6d57246210fb68fd

Contents?: true

Size: 1.82 KB

Versions: 3

Compression:

Stored size: 1.82 KB

Contents

# typed: strict
# frozen_string_literal: true

module Workato
  module Connector
    module Sdk
      module Dsl
        class StreamPackage
          extend T::Sig

          sig { params(streams: Streams, connection: Connection).void }
          def initialize(streams:, connection:)
            @streams = streams
            @connection = connection
          end

          sig do
            params(
              stream: T.any(Stream::Proxy, String, T::Hash[T.untyped, T.untyped]),
              from: T.nilable(Integer),
              frame_size: T.nilable(Integer),
              blk: SorbetTypes::StreamInProc
            ).returns(T.untyped)
          end
          def in(stream, from: nil, frame_size: nil, &blk)
            if stream.is_a?(Hash) && stream[:__stream__] && stream[:chunks].nil?
              stream = out(stream[:name], stream[:input] || {})
            end

            Stream.each_chunk(stream: stream, from: from, frame_size: frame_size, &blk)
          end

          sig { params(stream_name: String, input: SorbetTypes::StreamInputHash).returns(Stream::Proxy) }
          def out(stream_name, input = {})
            Stream::Proxy.new(input: Request.response!(input), name: stream_name, stream: streams[stream_name])
          end

          private

          T::Sig::WithoutRuntime.sig { params(symbol: T.any(String, Symbol), _args: T.untyped).void }
          def method_missing(symbol, *_args)
            raise UndefinedStdLibMethodError.new(symbol.to_s, 'workato.stream')
          end

          T::Sig::WithoutRuntime.sig { params(_args: T.untyped).returns(T::Boolean) }
          def respond_to_missing?(*_args)
            false
          end

          sig { returns(Connection) }
          attr_reader :connection

          sig { returns(Streams) }
          attr_reader :streams
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workato-connector-sdk-1.3.13 lib/workato/connector/sdk/dsl/stream_package.rb
workato-connector-sdk-1.3.12 lib/workato/connector/sdk/dsl/stream_package.rb
workato-connector-sdk-1.3.11 lib/workato/connector/sdk/dsl/stream_package.rb