Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all models not_sharded by default #170

Open
bogdan opened this issue Jan 31, 2018 · 3 comments
Open

Make all models not_sharded by default #170

bogdan opened this issue Jan 31, 2018 · 3 comments

Comments

@bogdan
Copy link
Contributor

bogdan commented Jan 31, 2018

I am trying to make all my models not sharded by default with.

But it results in a weird behavior. on_shard call doesn't establish connection to shard because connection_specification_name calls is_sharded? on ActiveRecord::Base which is false.

The following code results in AR::ConnectionNotEstablished:

ActiveRecord::Base.not_sharded
class Visitor < ActiveRecord::Base
  self.sharded = true
end

ActiveRecord::Base.on_shard(1) do
 Visitor.first
end

While the following would work:

Visitor.on_shard(1) do
 Visitor.first
end
@bquorning
Copy link
Member

I am trying to make all my models not sharded by default

We have been trying to implement exactly that in the v4 branch: https://github.com/zendesk/active_record_shards/tree/v4

Development has stagnated a bit, but if you’re interested, please give it a try and let us know how it went.

@kaspernj
Copy link

kaspernj commented Jan 2, 2019

I am also facing this annoyance with gems that create AR models that aren't sharded. It would be great to be able to reverse the behaviour. Possibly through a config option?

@bquorning
Copy link
Member

Possibly through a config option?

Nope, the necessary changes are too many to allow both options in the same library. I encourage you to experiment with the v4 beta versions. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants