Sha256: 86afeebee49e69bc01c73a0f267b0b26d8173694fdc25dcc83828a4dd80e8d07

Contents?: true

Size: 782 Bytes

Versions: 28

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module AnyCable
  module Middlewares
    # Checks that RPC client version is compatible with
    # the current RPC proto version
    class CheckVersion < AnyCable::Middleware
      attr_reader :version

      def initialize(version)
        @version = version
      end

      def call(_method, _request, meta)
        check_version(meta) do
          yield
        end
      end

      private

      def check_version(metadata)
        supported_versions = metadata["protov"]&.split(",")
        return yield if supported_versions&.include?(version)

        raise "Incompatible AnyCable RPC client.\nCurrent server version: #{version}.\n" \
              "Client supported versions: #{metadata["protov"] || "unknown"}."
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
anycable-core-1.6.0.rc.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.5.2 lib/anycable/middlewares/check_version.rb
anycable-core-1.5.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.5.0 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.4 lib/anycable/middlewares/check_version.rb
anycable-core-1.5.0.rc.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.3 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.2 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.0 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.0.rc.3 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.0.rc.2 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.0.rc.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.4.0.pre.rc.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.3.1 lib/anycable/middlewares/check_version.rb
anycable-core-1.3.0 lib/anycable/middlewares/check_version.rb
anycable-core-1.2.5 lib/anycable/middlewares/check_version.rb
anycable-core-1.2.4 lib/anycable/middlewares/check_version.rb
anycable-core-1.2.3 lib/anycable/middlewares/check_version.rb
anycable-core-1.2.2 lib/anycable/middlewares/check_version.rb