Last active
July 6, 2017 11:44
-
-
Save bklooste/566ce36304788b0b6ab8ae8293c7de25 to your computer and use it in GitHub Desktop.
CosmosTransactionalRepository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface CosmosTransactionalRepository<TKey, TValue> where TKey : IComparable<TKey>, IEquatable<TKey> | |
{ | |
event EventHandler<NotifyDictionaryChangedEventArgs<TKey, TValue>> DictionaryChanged; | |
Task AddAsync(ITransaction tx, TKey key, TValue value); | |
Task<TValue> AddOrUpdateManyAsync(ITransaction tx, KeyValuePair<TKey, TValue>> records, Func<TKey, TValue, TValue> updateValueFactory, TimeSpan timeout = default, CancellationToken cancellationToken = default); | |
Task<TValue> AddOrUpdateAsync(ITransaction tx, TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory, TimeSpan timeout = default, CancellationToken cancellationToken = default); | |
Task<TValue> GetOrAddAsync(ITransaction tx, TKey key, TValue value, TimeSpan timeout, CancellationToken cancellationToken); | |
Task<bool> TryDelete(ITransaction tx, TKey key, TimeSpan timeout, CancellationToken cancellationToken); | |
Task<int> Count(); | |
Task<bool> ContainsKeyAsync(TKey key); | |
Task<TValue> Get(TKey key); | |
Task<IEnumerable<TValue>> GetMany(Expression<Func<TValue, bool>> predicate); // underlying provider can use Linq | |
Task<IEnumerable<TValue>> GetMany(IEnumerable<TKey>> keys); | |
// ienumerable support? probably getMany will suffice | |
Task<IEnumerable<KeyValuePair<TKey, TValue>>> CreateEnumerable(); // we can make the rep enumerable but not with transaction | |
} |
Author
bklooste
commented
Jul 5, 2017
- TimeSpan timeout, CancellationToken cancellationToken should be on all fields but have defaults
- Due to latency Its important to have getoradd or addorupdate style
- Not sure whether gets should have a transaction ... I think this should be below the interface
- If we make transactions optional the concrete class can create them when needed and we would not need a non transactional interface
- ITransaction will be our class
Aaron makes the comment that we should have a non transactional one almost the same a ICrudService rather than the transactional one using defaults.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment