public override void Commit() { using var realm = _storage.GetRealm(); using var transaction = realm.BeginWrite(); foreach (var command in _commandQueue) { command(realm); } transaction.Commit(); }
public override IDisposable AcquireDistributedLock(string resource, TimeSpan timeout) => null; //No locks in RealmDb public override string CreateExpiredJob(Job job, IDictionary <string, string> parameters, DateTime createdAt, TimeSpan expireIn) { if (job == null) { throw new ArgumentNullException(nameof(job)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var realm = _storage.GetRealm(); using var transaction = realm.BeginWrite(); var invocationData = InvocationData.SerializeJob(job); var jobDto = new JobDto { InvocationData = SerializationHelper.Serialize <InvocationData>(invocationData), Arguments = invocationData.Arguments, Created = createdAt, ExpireAt = createdAt.Add(expireIn) }; foreach (var param in parameters) { jobDto.Parameters.Add(new ParameterDto(param.Key, param.Value)); } realm.Add(jobDto); transaction.Commit(); return(jobDto.Id); }