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

Tenancy support #13

Closed
marinkobabic opened this issue Aug 25, 2015 · 11 comments
Closed

Tenancy support #13

marinkobabic opened this issue Aug 25, 2015 · 11 comments

Comments

@marinkobabic
Copy link

I seems that I do not understand the concept of the IConnectionFactory.

You have the SqlPersistenceEngine and there is a method Initialize which creates the database tables during the bootup of the application. How do you know for which tenant. IConnectionFactory is not able to figure this out without the bucketId. This can't be done during startup of the application. The IConnectionFactory.Open should get the bucketId passed like mentioned here #2

IConnectionFactory could also have a method IsInitialized(buckedId) which must be implemented by different providers so that you know if the tables should be created or not. Another option is that you cache the IDbConnnection.ConnectionString to figure out if the initialization is required.

@andreabalducci
Copy link
Member

Bucket is a partition that allow you to share the same StreamId on different contexts, non strictly a Tenant: you could use a bucket for a Tenant, for a Bounded Context, for Aggregate, etc

So bucket is only a logical partition, not a physical one => no additional tables per bucket.
If you want a database per tenant you should create an eventstore per tenant (we work this way with the mongo engine).

@marinkobabic
Copy link
Author

It's a possible way, but the effort is huge to change the existing logic. We actually use IConnectionFactory with connectionstrings. We don't want to maintain all the connection strings and therefore switch to dynamic connections. You started already to develop in this way, but it seems without a clear concept. To have all the tenants in one database is not an option.

@andreabalducci
Copy link
Member

NEventStore doesn't have the concept of Tenant, only the concept of EventStore mapping to one database from the very beginning (we work with NES from v3).
In V5 we added the Bucket to allow logical partitions, that's all.
Don't understand your "You started already to develop in this way, but it seems without a clear concept", the design has always been one EventStore per db.

@marinkobabic
Copy link
Author

What is the IConnectionFactory for?

@andreabalducci
Copy link
Member

to factory a IDbConnection to the db for commands and queries.
About buckets: NEventStore/NEventStore#219

@marinkobabic
Copy link
Author

Sorry, but I don't see the point actually. What are the scenarios where you would factory the IDbConnection for the db for command and query? Just trying to understand the whole concept, before I go and change the my application architecture 1 EventStore per Db.

@andreabalducci
Copy link
Member

The IDbConnection is implemented by a custom ConnectionScope (per thread).

@marinkobabic
Copy link
Author

So you are caching in this case the connection on the thread. The supported concept is to always to connect to the same database and not to switch to different databases?

@andreabalducci
Copy link
Member

yes, always on the same db. If you need to connect to another db you should factory a new evenstore instance.

@marinkobabic
Copy link
Author

Thanks and sorry for the statement "no clear concept" 😏

@andreabalducci
Copy link
Member

👍

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