From 9275b22a304ccdafc8a628bc5fe4fbd72d0c4dd5 Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Tue, 20 Aug 2019 16:23:15 -0300 Subject: [PATCH] Add pool stats --- src/db/pool.cr | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/db/pool.cr b/src/db/pool.cr index 575c512..87aea91 100644 --- a/src/db/pool.cr +++ b/src/db/pool.cr @@ -28,6 +28,15 @@ module DB @available.clear end + record Stats, open_connections : Int32 + + # Returns stats of the pool + def stats + Stats.new( + open_connections: @total.size + ) + end + def checkout : T resource = if @available.empty? if can_increase_pool