Browse Source

Async improvements.

pull/537/head
Sebastian 6 years ago
parent
commit
a8d16f392d
  1. 2
      backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs
  2. 2
      backend/extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueActionHandler.cs
  3. 5
      backend/extensions/Squidex.Extensions/Actions/ClientPool.cs
  4. 2
      backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs
  5. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Comments/Comment.cs
  6. 8
      backend/src/Squidex.Domain.Users.MongoDb/Infrastructure/MongoPersistedGrantStore.cs
  7. 4
      backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs
  8. 1
      backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs

2
backend/extensions/Squidex.Extensions/Actions/Algolia/AlgoliaActionHandler.cs

@ -96,7 +96,7 @@ namespace Squidex.Extensions.Actions.Algolia
return Result.Ignored();
}
var index = clients.GetClient((job.AppId, job.ApiKey, job.IndexName));
var index = await clients.GetClientAsync((job.AppId, job.ApiKey, job.IndexName));
try
{

2
backend/extensions/Squidex.Extensions/Actions/AzureQueue/AzureQueueActionHandler.cs

@ -49,7 +49,7 @@ namespace Squidex.Extensions.Actions.AzureQueue
protected override async Task<Result> ExecuteJobAsync(AzureQueueJob job, CancellationToken ct = default)
{
var queue = clients.GetClient((job.QueueConnectionString, job.QueueName));
var queue = await clients.GetClientAsync((job.QueueConnectionString, job.QueueName));
await queue.AddMessageAsync(new CloudQueueMessage(job.MessageBodyV2), null, null, null, null, ct);

5
backend/extensions/Squidex.Extensions/Actions/ClientPool.cs

@ -30,11 +30,6 @@ namespace Squidex.Extensions.Actions
this.factory = factory;
}
public TClient GetClient(TKey key)
{
return GetClientAsync(key).Result;
}
public async Task<TClient> GetClientAsync(TKey key)
{
if (!memoryCache.TryGetValue<TClient>(key, out var client))

2
backend/extensions/Squidex.Extensions/Actions/ElasticSearch/ElasticSearchActionHandler.cs

@ -80,7 +80,7 @@ namespace Squidex.Extensions.Actions.ElasticSearch
return Result.Ignored();
}
var client = clients.GetClient((new Uri(job.ServerHost, UriKind.Absolute), job.ServerUser, job.ServerPassword));
var client = await clients.GetClientAsync((new Uri(job.ServerHost, UriKind.Absolute), job.ServerUser, job.ServerPassword));
try
{

4
backend/src/Squidex.Domain.Apps.Core.Model/Comments/Comment.cs

@ -30,9 +30,13 @@ namespace Squidex.Domain.Apps.Core.Comments
Guard.NotNull(text, nameof(text));
Id = id;
Text = text;
Time = time;
User = user;
Url = url;
}
}

8
backend/src/Squidex.Domain.Users.MongoDb/Infrastructure/MongoPersistedGrantStore.cs

@ -47,14 +47,14 @@ namespace Squidex.Domain.Users.MongoDb.Infrastructure
}, ct);
}
public Task StoreAsync(PersistedGrant grant)
public async Task<IEnumerable<PersistedGrant>> GetAllAsync(string subjectId)
{
return Collection.ReplaceOneAsync(x => x.Key == grant.Key, grant, UpsertReplace);
return await Collection.Find(x => x.SubjectId == subjectId).ToListAsync();
}
public Task<IEnumerable<PersistedGrant>> GetAllAsync(string subjectId)
public Task StoreAsync(PersistedGrant grant)
{
return Collection.Find(x => x.SubjectId == subjectId).ToListAsync().ContinueWith(x => (IEnumerable<PersistedGrant>)x.Result);
return Collection.ReplaceOneAsync(x => x.Key == grant.Key, grant, UpsertReplace);
}
public Task<PersistedGrant> GetAsync(string key)

4
backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs

@ -59,11 +59,11 @@ namespace Squidex.Infrastructure.EventSourcing
var settings = CatchUpSubscriptionSettings.Default;
return connection.SubscribeToStreamFrom(streamName, position, settings,
(s, e) =>
async (s, e) =>
{
var storedEvent = Formatter.Read(e, prefix, serializer);
subscriber.OnEventAsync(this, storedEvent).Wait();
await subscriber.OnEventAsync(this, storedEvent);
}, null,
(s, reason, ex) =>
{

1
backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs

@ -29,6 +29,7 @@ namespace Squidex.Infrastructure.Log.Store
Guard.NotNull(log, nameof(log));
this.logRepository = logRepository;
this.log = log;
timer = new CompletionTimer(Intervall, ct => TrackAsync(), Intervall);

Loading…
Cancel
Save