Module: PgPipeline::Caps
- Defined in:
- lib/pg_pipeline/server_caps.rb
Class Method Summary collapse
- .assert_supported!(caps) ⇒ Object
- .fast_sync?(caps) ⇒ Boolean
- .from_connection(conn) ⇒ Object
- .pipeline_api?(conn) ⇒ Boolean
- .place_sync(caps, conn) ⇒ Object
- .supported?(caps) ⇒ Boolean
Class Method Details
.assert_supported!(caps) ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'lib/pg_pipeline/server_caps.rb', line 58 def assert_supported!(caps) return true if supported?(caps) raise UnsupportedServerError, "pg_pipeline requires libpq >= 14, PostgreSQL protocol v3, and " \ "ruby-pg pipeline bindings; libpq=#{caps.libpq_version}, " \ "protocol=#{caps.protocol_version}, pipeline_api=#{caps.pipeline_api}" end |
.fast_sync?(caps) ⇒ Boolean
67 68 69 |
# File 'lib/pg_pipeline/server_caps.rb', line 67 def fast_sync?(caps) caps.libpq_version >= ServerCaps::FAST_SYNC_LIBPQ_VERSION && caps.fast_sync_api end |
.from_connection(conn) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/pg_pipeline/server_caps.rb', line 35 def from_connection(conn) ServerCaps.new( libpq_version: PG.library_version, protocol_version: conn.protocol_version, pipeline_api: pipeline_api?(conn), fast_sync_api: conn.respond_to?(:send_pipeline_sync), raw_pipeline_sync_api: conn.respond_to?(:sync_pipeline_sync) ) end |
.pipeline_api?(conn) ⇒ Boolean
45 46 47 48 49 50 |
# File 'lib/pg_pipeline/server_caps.rb', line 45 def pipeline_api?(conn) conn.respond_to?(:enter_pipeline_mode) && conn.respond_to?(:exit_pipeline_mode) && conn.respond_to?(:pipeline_status) && (conn.respond_to?(:sync_pipeline_sync) || conn.respond_to?(:pipeline_sync)) end |
.place_sync(caps, conn) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/pg_pipeline/server_caps.rb', line 71 def place_sync(caps, conn) if fast_sync?(caps) conn.send_pipeline_sync elsif caps.raw_pipeline_sync_api conn.sync_pipeline_sync else conn.pipeline_sync end nil end |
.supported?(caps) ⇒ Boolean
52 53 54 55 56 |
# File 'lib/pg_pipeline/server_caps.rb', line 52 def supported?(caps) caps.libpq_version >= ServerCaps::REQUIRED_LIBPQ_VERSION && caps.protocol_version == ServerCaps::PROTOCOL_VERSION && caps.pipeline_api end |