From 0e6d567e796ae859fffefd023d68706e862c70e6 Mon Sep 17 00:00:00 2001 From: Seth Tucker Date: Thu, 26 Oct 2023 13:03:31 -0400 Subject: [PATCH] Changed connection period to use less memory & changed reader/writer to allow nil until being used --- src/granite/connection_management.cr | 6 +++--- src/granite/connections.cr | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/granite/connection_management.cr b/src/granite/connection_management.cr index 928ee1c3..6cfe03b4 100644 --- a/src/granite/connection_management.cr +++ b/src/granite/connection_management.cr @@ -4,12 +4,12 @@ module Granite::ConnectionManagement # database connection for read operations # all models use this value. Change it # to change it in all Granite::Base models. - class_property connection_switch_wait_period : Int64 = Granite::Connections.connection_switch_wait_period + class_property connection_switch_wait_period : Int32 = Granite::Connections.connection_switch_wait_period @@last_write_time = Time.monotonic class_property current_adapter : Granite::Adapter::Base? - class_property reader_adapter : Granite::Adapter::Base = Granite::Connections.first_reader - class_property writer_adapter : Granite::Adapter::Base = Granite::Connections.first_writer + class_property reader_adapter : Granite::Adapter::Base? + class_property writer_adapter : Granite::Adapter::Base? def self.last_write_time @@last_write_time diff --git a/src/granite/connections.cr b/src/granite/connections.cr index 134ab3b2..c7953202 100644 --- a/src/granite/connections.cr +++ b/src/granite/connections.cr @@ -1,6 +1,6 @@ module Granite class Connections - class_property connection_switch_wait_period : Int64 = 2000 + class_property connection_switch_wait_period : Int32 = 2000 class_getter registered_connections = [] of {writer: Granite::Adapter::Base, reader: Granite::Adapter::Base} # Registers the given *adapter*. Raises if an adapter with the same name has already been registered.