Sha256: 744d342a7e805f6a6452ed73da673ef6e175ee9ef6ecae93c277fab5a0cfa422
Contents?: true
Size: 639 Bytes
Versions: 1
Compression:
Stored size: 639 Bytes
Contents
# frozen_string_literal: true require 'concurrent' module PgbConnectionReaperRb module Reaper def initialize(*args) super @connected_at = Concurrent.monotonic_time @pgb_ttl = self.class.type_cast_config_to_integer(@config.fetch(:pgb_ttl, nil)) end attr_reader :connected_at, :pgb_ttl def reconnect!(*args) super(*args) @connected_at = Concurrent.monotonic_time end def age Concurrent.monotonic_time - @connected_at end def eligible? pgb_ttl && age > pgb_ttl end def verify!(*args) super(*args) reconnect! if eligible? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pgb_connection_reaper_rb-0.1.0 | lib/pgb_connection_reaper_rb/reaper.rb |