yevhen / Streamstone

Event store for Azure Table Storage
Other
395 stars 64 forks source link

Multitenant concurrency? #13

Closed turowicz closed 9 years ago

turowicz commented 9 years ago

Will the following example throw concurrency exceptions for multitenant operations too?

https://github.com/yevhen/Streamstone/blob/master/Source/Example/Scenarios/S08_Concurrency_conflicts.cs

yevhen commented 9 years ago

I'm not sure I'm following you on this. What do you mean by multi-tenant?

There various ways how you can model multi-tenant apps with Streamstone.

  1. One physical partition for tenant, virtual partitions (inside that physical partition) for each stream. That way you can have transaction around writing events into a stream and writing some entities at partition level. That's how inline synchronous fully consistent projections/snapshots could be implemented (in theory), where partition level entities could be an aggregation rows (such as counters) and concurrency for those rows should be managed by using normal WATS means, such as Etag. Ie, you need to read partition-level aggregation rows (table entities) before including them in transaction when writing events to stream.
  2. One physical partition for stream. Then you can model multi-tenancy by implementing stream directory so that you know which tenant has which streams and where.

In both cases, concurrency will always be handled for any stream-level operation. In 1-st case, concurrency for partition-level entities could be controlled by developer, using regular semantics of table operations (Insert, InsertOrReplace, Replace).

yevhen commented 9 years ago

Checkout Include.XXX class and sample here for how you can include additional entities when writing events (within same transaction).

yevhen commented 9 years ago

@turowicz Can I close this?

turowicz commented 9 years ago

thanks!