make “in region” methods enqueue_args mandatory

refs AE-92

Ruby 2.7 will put the enqueue_args, in kwargs if there are no additional arguments provided, even if enqueue_args is provided as a hash.

```
def x(a, b={}, *args, **kwargs)
  puts a, b, *args, **kwargs
end

x(1, {'a': 'b'})

# 1
# {}
# {:a=>"b"}
```

In practice, this method is always sent enqueue_args anyway, so just make it mandatory.

Change-Id: I0e31e73bf9d4f7b20d4006ac2e34dd2f11bb1178
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/307827
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Aaron Ogata <aogata@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
Aaron Ogata 2022-12-21 05:37:30 -08:00
parent 9389fec337
commit c6f720cd2b
2 changed files with 3 additions and 3 deletions

View File

@ -251,7 +251,7 @@ Rails.configuration.after_initialize do
Delayed::Periodic.cron "AuthenticationProvider::SAML::#{federation.class_name}.refresh_providers", "45 0 * * *" do
DatabaseServer.send_in_each_region(federation,
:refresh_providers,
singleton: "AuthenticationProvider::SAML::#{federation.class_name}.refresh_providers")
{ singleton: "AuthenticationProvider::SAML::#{federation.class_name}.refresh_providers" })
end
end
end

View File

@ -197,7 +197,7 @@ Rails.application.config.after_initialize do
Setting.get("maintenance_window_weeks_of_month", "1,3").split(",").map(&:to_i)
end
def self.send_in_each_region(klass, method, enqueue_args = {}, *args, **kwargs)
def self.send_in_each_region(klass, method, enqueue_args, *args, **kwargs)
run_current_region_asynchronously = enqueue_args.delete(:run_current_region_asynchronously)
return klass.send(method, *args, **kwargs) if DatabaseServer.all.all? { |db| !db.config[:region] }
@ -219,7 +219,7 @@ Rails.application.config.after_initialize do
end
end
def self.send_in_region(region, klass, method, enqueue_args = {}, *args, **kwargs)
def self.send_in_region(region, klass, method, enqueue_args, *args, **kwargs)
return klass.delay(**enqueue_args).__send__(method, *args, **kwargs) if region.nil?
shard = nil