Skip to content

Commit

Permalink
Changed connection period to use less memory & changed reader/writer …
Browse files Browse the repository at this point in the history
…to allow nil until being used (#497)
  • Loading branch information
crimson-knight authored Oct 26, 2023
1 parent 535ebbe commit a996473
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/granite/connection_management.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/granite/connections.cr
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit a996473

Please sign in to comment.