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

better sharded DB support #96

Open
yaitskov opened this issue Sep 27, 2020 · 2 comments
Open

better sharded DB support #96

yaitskov opened this issue Sep 27, 2020 · 2 comments

Comments

@yaitskov
Copy link

Hi,

Groundhog doesn't supported sharded tables well. i.e the situation when DB has lots of tables with same structure. All these tables share a data type representing the tables,
which instantiates PersistentEntity class.

PersistentEntity has entitfyDef function. It already returns meta data including table name, but
there is not way to deliver table name to PersistentEntity in case of reading data from DB.
e.g.

   all :: [MyType] <- select CondEmpty

MyType represents multiple tables: my_type_1, my_type_2, ....

entityDef is pure function so it is not possible to benefit from ReaderT.
ThreadLocal feature is deprecated in Haskell.

@yaitskov
Copy link
Author

I have an idea to write a wrapper for backend, to modify table name there,
but I struggle with forwarding existed functions.

@lykahb
Copy link
Owner

lykahb commented Sep 30, 2020

The place where entityDef is used is at https://github.com/lykahb/groundhog/blob/master/groundhog/Database/Groundhog/Generic/PersistBackendHelpers.hs
Those functions are in the Action monad. You can change them to a more general monad that has connection.

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

No branches or pull requests

2 participants