Skip to content

Commit

Permalink
0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydwatkin committed Apr 9, 2024
1 parent 727f80b commit ff96f8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ Rails/Delegate:

Metrics/BlockLength:
Exclude:
- spec/**/*
- spec/**/*

Metrics/AbcSize:
Max: 22
15 changes: 5 additions & 10 deletions lib/active_record/connection_adapters/janus_mysql2_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ class JanusMysql2Adapter < ActiveRecord::ConnectionAdapters::Mysql2Adapter
SQL_SKIP_ALL_MATCHERS = [/\A\s*set\s+local\s/i].freeze

def initialize(*args)
args = parse_config(args)
args[0][:janus]['replica']['database'] = args[0][:database]
args[0][:janus]['primary']['database'] = args[0][:database]

@replica_config = args[0][:janus]['replica']
args[0] = args[0][:janus]['primary']
super(*args)
@connection_parameters ||= args[0]
update_config
Expand Down Expand Up @@ -79,15 +83,6 @@ def clear_cache!(...)

private

def parse_config(args)
args[0][:janus]['replica']['database'] = args[0][:database]
args[0][:janus]['primary']['database'] = args[0][:database]

@replica_config = args[0][:janus]['replica']
args[0] = args[0][:janus]['primary']
args
end

def should_send_to_all?(sql)
SQL_ALL_MATCHERS.any? { |matcher| sql =~ matcher } && SQL_SKIP_ALL_MATCHERS.none? { |matcher| sql =~ matcher }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/janus/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Janus
unless defined?(::Janus::VERSION)
module VERSION
MAJOR = 0
MINOR = 4
MINOR = 5
PATCH = 0
PRE = nil

Expand Down

0 comments on commit ff96f8d

Please sign in to comment.