File: primary_socket.rb

package info (click to toggle)
ruby-mongo 2.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,020 kB
  • sloc: ruby: 110,810; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true
# rubocop:todo all

module PrimarySocket
  def self.included(base)
    base.class_eval do

      let(:primary_server) do
        client.cluster.next_primary
      end

      let(:primary_connection) do
        connection = primary_server.pool.check_out
        connection.connect!
        primary_server.pool.check_in(connection)
        connection
      end

      let(:primary_socket) do
        primary_connection.send(:socket)
      end
    end
  end
end