Sha256: 8e1f3f6627a97a537e3e9fa12704fc7cc799311d9aafbf8a2b671bf7870d8988

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

module VagrantPlugins
  module CommandServe
    module Util
      module ClientSetup
        def self.prepended(klass)
          klass.extend(Connector)
          klass.class_eval do
            attr_reader :broker, :client, :proto
          end
        end

        def initialize(conn, proto, broker=nil)
          n = self.class.respond_to?(:sdk_alias) ? self.class.sdk_alias : self.class.name
          lookup = n.split("::")
          idx = lookup.index("Client")
          if idx
            lookup.slice!(0, idx+1)
          end

          srv = "#{lookup.join}Service"

          @broker = broker
          @proto = proto
          srv_klass = SDK.const_get(srv)&.const_get(:Stub)
          if !srv_klass
            raise NameError,
              "failed to locate required protobuf constant `SDK::#{srv}'"
          end
          @client = srv_klass.new(conn, :this_channel_is_insecure)
        end

        def to_proto
          @proto
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/commands/serve/util/client_setup.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/serve/util/client_setup.rb
vagrant-unbundled-2.3.3.0 plugins/commands/serve/util/client_setup.rb
vagrant-unbundled-2.3.2.0 plugins/commands/serve/util/client_setup.rb