public async Task ClearStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { if (_dataManager == null) { throw new ArgumentException("GrainState-Bucket property not initialized"); } string pk = GetKeyString(grainReference); var entity = new GrainStateDocument { Id = pk }; try { if (_options.DeleteStateOnClear) { await DoOptimisticUpdateAsync(() => _dataManager.Delete(entity), grainType, grainReference, _options.BucketName).ConfigureAwait(false); } } catch (Exception ex) { throw ex; } }
public async Task <string> UpsertEntryAsync(GrainStateDocument document) { //Insert if document doesn't exist otherwise update existing document if (!String.IsNullOrWhiteSpace(document.Id)) { document.Id = Guid.NewGuid().ToString(); } if (_bucket == null) { await InitConnection(); } var bucket = _bucket.Bucket; await bucket.UpsertAsync(document.Id.ToString(), document.Data); //TODO: Add Exception Handling return(document.Id.ToString()); }
public async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { if (_dataManager == null) { throw new ArgumentException("GrainState-Couchbase property not initialized"); } string pk = GetKeyString(grainReference); var contents = ConvertToStorageFormat(grainState); var document = new GrainStateDocument { Id = pk, Data = contents }; try { await DoOptimisticUpdateAsync(() => _dataManager.Write(document), grainType, grainReference, _options.BucketName).ConfigureAwait(false); } catch (Exception) { throw; } }
public async Task Delete(GrainStateDocument document) { await dataManager.DeleteEntryAsync(document.Id.ToString()); }
public async Task Write(GrainStateDocument document) { await dataManager.UpsertEntryAsync(document); }