forked from LykkeCity/MT
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #516 from LykkeBusiness/LT-5012-eod-borders
Lt 5012 eod borders
- Loading branch information
Showing
25 changed files
with
432 additions
and
52 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
src/MarginTrading.Backend.Core/Services/ISnapshotStatusTracker.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2019 Lykke Corp. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace MarginTrading.Backend.Core.Services | ||
{ | ||
/// <summary> | ||
/// This status tracker decouples draft snapshot creation from rabbit mq | ||
/// Normal flow: <see cref="MarginTrading.Backend.Contracts.TradingSchedule.MarketStateChangedEvent" /> generated => handled in PlatformClosureProjection => snapshot saved | ||
/// Degraded flow: <see cref="MarginTrading.Backend.Contracts.TradingSchedule.MarketStateChangedEvent" /> generated, snapshot requested => event not received in PlatformClosureProjection => SnapshotMonitoringService retries snapshot creation after a timeout | ||
/// </summary> | ||
public interface ISnapshotStatusTracker | ||
{ | ||
void SnapshotRequested(DateTime tradingDay); | ||
void SnapshotInProgress(); | ||
void SnapshotCreated(); | ||
bool ShouldRetrySnapshot(out DateTime tradingDay); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/MarginTrading.Backend.Core/Settings/BookKeeperServiceClient.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) 2019 Lykke Corp. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using JetBrains.Annotations; | ||
using Lykke.SettingsReader.Attributes; | ||
|
||
namespace MarginTrading.Backend.Core.Settings | ||
{ | ||
[UsedImplicitly] | ||
public class BookKeeperServiceClient | ||
{ | ||
// isAlive check leads to a deadlock | ||
public string ServiceUrl { get; set; } | ||
|
||
[Optional] | ||
public string ApiKey { get; set; } | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/MarginTrading.Backend.Core/Settings/SnapshotMonitorSettings.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2019 Lykke Corp. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace MarginTrading.Backend.Core.Settings | ||
{ | ||
public class SnapshotMonitorSettings | ||
{ | ||
/// <summary> | ||
/// Defines the interval between consecutive checks performed by the SnapshotMonitoringService service. | ||
/// </summary> | ||
public TimeSpan MonitoringDelay { get; set; } = TimeSpan.FromSeconds(30); | ||
|
||
/// <summary> | ||
/// If snapshot is not created after a specified amount of time, creation will be retried | ||
/// </summary> | ||
public TimeSpan DelayBeforeFallbackSnapshot { get; set; } = TimeSpan.FromMinutes(5); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/MarginTrading.Backend.Services/DraftSnapshotKeeperFactory.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2019 Lykke Corp. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using MarginTrading.Backend.Core.Repositories; | ||
|
||
namespace MarginTrading.Backend.Services | ||
{ | ||
public class DraftSnapshotKeeperFactory : IDraftSnapshotKeeperFactory | ||
{ | ||
private readonly ITradingEngineSnapshotsRepository _tradingEngineSnapshotsRepository; | ||
|
||
public DraftSnapshotKeeperFactory(ITradingEngineSnapshotsRepository tradingEngineSnapshotsRepository) | ||
{ | ||
_tradingEngineSnapshotsRepository = tradingEngineSnapshotsRepository; | ||
} | ||
|
||
public IDraftSnapshotKeeper Create(DateTime tradingDay) | ||
{ | ||
var draftSnapshotKeeper = new DraftSnapshotKeeper(_tradingEngineSnapshotsRepository); | ||
draftSnapshotKeeper.Init(tradingDay); | ||
return draftSnapshotKeeper; | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/MarginTrading.Backend.Services/IDraftSnapshotKeeperFactory.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2019 Lykke Corp. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
|
||
namespace MarginTrading.Backend.Services | ||
{ | ||
public interface IDraftSnapshotKeeperFactory | ||
{ | ||
IDraftSnapshotKeeper Create(DateTime tradingDay); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (c) 2019 Lykke Corp. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using MarginTrading.Backend.Contracts.Prices; | ||
using MarginTrading.Backend.Core.Snapshots; | ||
|
||
namespace MarginTrading.Backend.Services | ||
{ | ||
public interface ISnapshotService | ||
{ | ||
/// <summary> | ||
/// Make final trading snapshot from current system state | ||
/// </summary> | ||
/// <param name="tradingDay"></param> | ||
/// <param name="correlationId"></param> | ||
/// <param name="status"></param> | ||
/// <returns></returns> | ||
Task<string> MakeTradingDataSnapshot( | ||
DateTime tradingDay, | ||
string correlationId, | ||
SnapshotStatus status = SnapshotStatus.Final); | ||
|
||
/// <summary> | ||
/// Make final trading snapshot from draft | ||
/// </summary> | ||
/// <param name="correlationId"></param> | ||
/// <param name="cfdQuotes"></param> | ||
/// <param name="fxRates"></param> | ||
/// <returns></returns> | ||
Task MakeTradingDataSnapshotFromDraft( | ||
string correlationId, | ||
IEnumerable<ClosingAssetPrice> cfdQuotes, | ||
IEnumerable<ClosingFxRate> fxRates, | ||
IDraftSnapshotKeeper draftSnapshotKeeper = null); | ||
} | ||
} |
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
Oops, something went wrong.