Skip to content

Commit

Permalink
Merge branch 'feature_LWDEV-7673_prevent-memory-leak' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	client/Lykke.Service.Assets.Client/ServiceCollectionExtensions.cs
  • Loading branch information
paradise committed May 31, 2018
2 parents fd3ee34 + 38be0da commit 29bcc8d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
3 changes: 0 additions & 3 deletions client/Lykke.Service.Assets.Client/AssetServiceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ namespace Lykke.Service.Assets.Client
{
public class AssetServiceSettings
{

public TimeSpan AssetsCacheExpirationPeriod { get; set; }

public TimeSpan AssetPairsCacheExpirationPeriod { get; set; }

public Uri BaseUri { get; set; }

public DelegatingHandler[] Handlers { get; set; }


public static AssetServiceSettings Create(Uri baseUri, TimeSpan cacheExpirationPeriod)
{
Expand Down
22 changes: 22 additions & 0 deletions client/Lykke.Service.Assets.Client/AssetsService.Extend.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;

// ReSharper disable once CheckNamespace
namespace Lykke.Service.Assets.Client
{
public partial class AssetsService
{
/// <inheritdoc />
/// <summary>
/// Should be used to prevent memory leak in RetryPolicy
/// </summary>
public AssetsService(Uri baseUri, HttpClient client) : base(client)
{
Initialize();

BaseUri = baseUri ?? throw new ArgumentNullException("baseUri");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Common.Log;
using System.Net.Http;
using Common.Log;
using Lykke.Service.Assets.Client.Cache;
using Lykke.Service.Assets.Client.Models;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -11,7 +12,7 @@ public static void RegisterAssetsClient(this IServiceCollection services, AssetS
ILog log)
{
services
.AddSingleton<IAssetsService>(x => new AssetsService(settings.BaseUri, settings.Handlers));
.AddSingleton<IAssetsService>(x => new AssetsService(settings.BaseUri, new HttpClient()));

services
.AddSingleton<IDictionaryCache<Asset>>(x =>
Expand Down

0 comments on commit 29bcc8d

Please sign in to comment.