diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml
new file mode 100644
index 0000000..cf2d7c0
--- /dev/null
+++ b/.github/workflows/ci-dev.yml
@@ -0,0 +1,60 @@
+name: CI dev build
+
+on:
+ push:
+ branches:
+ - dev
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 5.0.x
+ - name: Build
+ run: dotnet build --configuration Release
+ - name: Test
+ run: dotnet test --no-build --configuration Release
+ - name: Publish API
+ run: dotnet publish --no-build ./src/Antares.Service.History/Antares.Service.History.csproj --output ./publish-api --configuration Release
+ - name: Publish worker
+ run: dotnet publish --no-build ./src/Antares.Job.History/Antares.Job.History.csproj --output ./publish-worker --configuration Release
+ - name: Check API dir
+ run: ls ./publish-api
+ - name: Check worker dir
+ run: ls ./publish-worker
+ - name: Publish API to Registry
+ uses: swisschain/Publish-Docker-Github-Action@master
+ with:
+ name: swisschains/antares-history-api:dev
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ workdir: ./publish-api
+ # snapshot: true # use snapshot to push an additional image, which is tagged with {YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}
+ tag_names: true
+ - name: Publish worker to Registry
+ uses: swisschain/Publish-Docker-Github-Action@master
+ with:
+ name: swisschains/antares-history-job:dev
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ workdir: ./publish-worker
+ # snapshot: true # use snapshot to push an additional image, which is tagged with {YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}
+ tag_names: true
+ - name: Restart service
+ uses: swisschain/kube-restart-pods@master
+ env:
+ KUBE_CONFIG_DATA: ${{ secrets.LYKKE_DEV_KUBE_CONFIG_DATA }}
+ NAMESPACE: lykke-service
+ POD: history
+ - name: Restart job
+ uses: swisschain/kube-restart-pods@master
+ env:
+ KUBE_CONFIG_DATA: ${{ secrets.LYKKE_DEV_KUBE_CONFIG_DATA }}
+ NAMESPACE: lykke-jobs
+ POD: history-job
\ No newline at end of file
diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml
new file mode 100644
index 0000000..d834ccb
--- /dev/null
+++ b/.github/workflows/ci-test.yml
@@ -0,0 +1,60 @@
+name: CI test build
+
+on:
+ push:
+ branches:
+ - test
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 5.0.x
+ - name: Build
+ run: dotnet build --configuration Release
+ - name: Test
+ run: dotnet test --no-build --configuration Release
+ - name: Publish API
+ run: dotnet publish --no-build ./src/Antares.Service.History/Antares.Service.History.csproj --output ./publish-api --configuration Release
+ - name: Publish worker
+ run: dotnet publish --no-build ./src/Antares.Job.History/Antares.Job.History.csproj --output ./publish-worker --configuration Release
+ - name: Check API dir
+ run: ls ./publish-api
+ - name: Check worker dir
+ run: ls ./publish-worker
+ - name: Publish API to Registry
+ uses: swisschain/Publish-Docker-Github-Action@master
+ with:
+ name: swisschains/antares-history-api:test
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ workdir: ./publish-api
+ # snapshot: true # use snapshot to push an additional image, which is tagged with {YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}
+ tag_names: true
+ - name: Publish worker to Registry
+ uses: swisschain/Publish-Docker-Github-Action@master
+ with:
+ name: swisschains/antares-history-job:test
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ workdir: ./publish-worker
+ # snapshot: true # use snapshot to push an additional image, which is tagged with {YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}
+ tag_names: true
+ - name: Restart service
+ uses: swisschain/kube-restart-pods@master
+ env:
+ KUBE_CONFIG_DATA: ${{ secrets.LYKKE_TEST_KUBE_CONFIG_DATA }}
+ NAMESPACE: services
+ POD: history
+ - name: Restart job
+ uses: swisschain/kube-restart-pods@master
+ env:
+ KUBE_CONFIG_DATA: ${{ secrets.LYKKE_TEST_KUBE_CONFIG_DATA }}
+ NAMESPACE: lykke-jobs
+ POD: history-job
\ No newline at end of file
diff --git a/.github/workflows/release-api-client.yml b/.github/workflows/release-api-client.yml
new file mode 100644
index 0000000..c14ab3f
--- /dev/null
+++ b/.github/workflows/release-api-client.yml
@@ -0,0 +1,23 @@
+name: Release History client nuget
+
+on:
+ push:
+ tags: "api-client-*"
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 3.1.100
+ - name: Build
+ run: dotnet build --configuration Release client/Antares.Service.History.GrpcClient/Antares.Service.History.GrpcClient.csproj
+ - name: Create the package
+ run: dotnet pack --configuration Release client/Antares.Service.History.GrpcClient /p:Version=${GITHUB_REF#refs/tags/api-client-}
+ - name: Publish the package to GPR
+ run: dotnet nuget push client/Antares.Service.History.GrpcClient/bin/Release/*.nupkg -s "https://api.nuget.org/v3/index.json" -k ${{ secrets.NUGET_TOCKEN }}
diff --git a/.github/workflows/release-service.yml b/.github/workflows/release-service.yml
new file mode 100644
index 0000000..95f1bfa
--- /dev/null
+++ b/.github/workflows/release-service.yml
@@ -0,0 +1,49 @@
+name: Release Service
+
+on:
+ push:
+ tags: "service-*"
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 5.0.x
+ - name: Build
+ run: dotnet build --configuration Release /p:AssemblyVersion=${GITHUB_REF#refs/tags/service-}
+ - name: Test
+ run: dotnet test --no-build --configuration Release
+ - name: Publish API
+ run: dotnet publish --no-build ./src/Antares.Service.History/Antares.Service.History.csproj --output ./publish-api --configuration Release
+ - name: Publish worker
+ run: dotnet publish --no-build ./src/Antares.Job.History/Antares.Job.History.csproj --output ./publish-worker --configuration Release
+ - name: Check API dir
+ run: ls ./publish-api
+ - name: Check worker dir
+ run: ls ./publish-worker
+ - name: Publish API to Registry
+ uses: swisschain/Publish-Docker-Github-Action@master
+ with:
+ name: swisschains/antares-history-api
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ workdir: ./publish-api
+ # snapshot: true # use snapshot to push an additional image, which is tagged with {YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}
+ tag_names: true
+ tag_name_skip: service-
+ - name: Publish worker to Registry
+ uses: swisschain/Publish-Docker-Github-Action@master
+ with:
+ name: swisschains/antares-history-job
+ username: ${{ secrets.DOCKER_USERNAME }}
+ password: ${{ secrets.DOCKER_PASSWORD }}
+ workdir: ./publish-worker
+ # snapshot: true # use snapshot to push an additional image, which is tagged with {YEAR}{MONTH}{DAY}{HOUR}{MINUTE}{SECOND}{first 6 digits of the git sha}
+ tag_names: true
+ tag_name_skip: service-
diff --git a/.github/workflows/validate-master.yml b/.github/workflows/validate-master.yml
new file mode 100644
index 0000000..e546819
--- /dev/null
+++ b/.github/workflows/validate-master.yml
@@ -0,0 +1,22 @@
+name: Validate master
+
+on:
+ push:
+ branches:
+ - master
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup .NET Core
+ uses: actions/setup-dotnet@v1
+ with:
+ dotnet-version: 5.0.x
+ - name: Build
+ run: dotnet build --configuration Release
+ - name: Test
+ run: dotnet test --no-build --configuration Release
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index a70883a..addfc08 100644
--- a/.gitignore
+++ b/.gitignore
@@ -337,3 +337,4 @@ ASALocalRun/
appsettings.*.json
/client/**/*.xml
+**/Properties/launchSettings.json
\ No newline at end of file
diff --git a/Antares.Service.History.sln b/Antares.Service.History.sln
new file mode 100644
index 0000000..0ed8034
--- /dev/null
+++ b/Antares.Service.History.sln
@@ -0,0 +1,121 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30804.86
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History", "src\Antares.Service.History\Antares.Service.History.csproj", "{E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1. Instrastructure", "1. Instrastructure", "{CC2067D7-1971-47BB-B491-5649EA3C18B2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.Core", "src\Antares.Service.History.Core\Antares.Service.History.Core.csproj", "{F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. Repositories", "2. Repositories", "{BF745453-B940-470E-81BC-43FB67703D4E}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.PostgresRepositories", "src\Antares.Service.History.PostgresRepositories\Antares.Service.History.PostgresRepositories.csproj", "{4BE49E02-AAAD-460B-8D00-57F412A3D181}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.Services", "src\Antares.Service.History.Services\Antares.Service.History.Services.csproj", "{2D5F52EC-2A27-4045-81ED-72355E2A6325}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "0. Solution items", "0. Solution items", "{6CA74DE0-A357-4934-9D8B-FEA3F0A2D690}"
+ ProjectSection(SolutionItems) = preProject
+ .gitignore = .gitignore
+ README.md = README.md
+ settings.yaml = settings.yaml
+ EndProjectSection
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.Tests", "tests\Antares.Service.History.Tests\Antares.Service.History.Tests.csproj", "{A61FFDEE-5725-4650-A788-6E55EE5EFD5B}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Tests", "4. Tests", "{8F9036B1-5106-4C69-B2D2-B78EE52687A0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Job.History", "src\Antares.Job.History\Antares.Job.History.csproj", "{20110F5A-E5BA-4147-BF4E-7258CB54FE93}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3. Client", "3. Client", "{CB89F731-A3D8-4AAB-8F8A-F1CCFEED51B0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.Client", "client\Antares.Service.History.Client\Antares.Service.History.Client.csproj", "{831EC068-8A52-4209-BCCA-6EB5A1FF363B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.Contracts", "client\Antares.Service.History.Contracts\Antares.Service.History.Contracts.csproj", "{E4199193-31F4-401B-8464-96783A6195D2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.GrpcContract", "client\Antares.Service.History.GrpcContract\Antares.Service.History.GrpcContract.csproj", "{FBE93CEC-068E-49C8-98EB-1157731401E7}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Antares.Service.History.GrpcClient", "client\Antares.Service.History.GrpcClient\Antares.Service.History.GrpcClient.csproj", "{E7309202-72EB-4ACB-8BD3-3E704CC433FB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTest", "tests\ConsoleTest\ConsoleTest.csproj", "{D8FED4D5-4643-44C6-860C-947A51FCE5F2}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github workflows", "Github workflows", "{1BE59376-4647-47A3-A509-E9F7B8772B1F}"
+ ProjectSection(SolutionItems) = preProject
+ .github\workflows\ci-dev.yml = .github\workflows\ci-dev.yml
+ .github\workflows\ci-test.yml = .github\workflows\ci-test.yml
+ .github\workflows\release-api-client.yml = .github\workflows\release-api-client.yml
+ .github\workflows\release-service.yml = .github\workflows\release-service.yml
+ .github\workflows\validate-master.yml = .github\workflows\validate-master.yml
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Release|Any CPU.Build.0 = Release|Any CPU
+ {831EC068-8A52-4209-BCCA-6EB5A1FF363B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {831EC068-8A52-4209-BCCA-6EB5A1FF363B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {831EC068-8A52-4209-BCCA-6EB5A1FF363B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {831EC068-8A52-4209-BCCA-6EB5A1FF363B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E4199193-31F4-401B-8464-96783A6195D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E4199193-31F4-401B-8464-96783A6195D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E4199193-31F4-401B-8464-96783A6195D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E4199193-31F4-401B-8464-96783A6195D2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FBE93CEC-068E-49C8-98EB-1157731401E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FBE93CEC-068E-49C8-98EB-1157731401E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FBE93CEC-068E-49C8-98EB-1157731401E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FBE93CEC-068E-49C8-98EB-1157731401E7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E7309202-72EB-4ACB-8BD3-3E704CC433FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E7309202-72EB-4ACB-8BD3-3E704CC433FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E7309202-72EB-4ACB-8BD3-3E704CC433FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E7309202-72EB-4ACB-8BD3-3E704CC433FB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D8FED4D5-4643-44C6-860C-947A51FCE5F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D8FED4D5-4643-44C6-860C-947A51FCE5F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D8FED4D5-4643-44C6-860C-947A51FCE5F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D8FED4D5-4643-44C6-860C-947A51FCE5F2}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955} = {CC2067D7-1971-47BB-B491-5649EA3C18B2}
+ {4BE49E02-AAAD-460B-8D00-57F412A3D181} = {BF745453-B940-470E-81BC-43FB67703D4E}
+ {2D5F52EC-2A27-4045-81ED-72355E2A6325} = {CC2067D7-1971-47BB-B491-5649EA3C18B2}
+ {A61FFDEE-5725-4650-A788-6E55EE5EFD5B} = {8F9036B1-5106-4C69-B2D2-B78EE52687A0}
+ {831EC068-8A52-4209-BCCA-6EB5A1FF363B} = {CB89F731-A3D8-4AAB-8F8A-F1CCFEED51B0}
+ {E4199193-31F4-401B-8464-96783A6195D2} = {CB89F731-A3D8-4AAB-8F8A-F1CCFEED51B0}
+ {FBE93CEC-068E-49C8-98EB-1157731401E7} = {CB89F731-A3D8-4AAB-8F8A-F1CCFEED51B0}
+ {E7309202-72EB-4ACB-8BD3-3E704CC433FB} = {CB89F731-A3D8-4AAB-8F8A-F1CCFEED51B0}
+ {D8FED4D5-4643-44C6-860C-947A51FCE5F2} = {8F9036B1-5106-4C69-B2D2-B78EE52687A0}
+ {1BE59376-4647-47A3-A509-E9F7B8772B1F} = {6CA74DE0-A357-4934-9D8B-FEA3F0A2D690}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {EB6C0EF4-AA6A-444D-8603-3669F73A58BC}
+ EndGlobalSection
+EndGlobal
diff --git a/Lykke.Service.History.sln b/Lykke.Service.History.sln
deleted file mode 100644
index 37cb4c7..0000000
--- a/Lykke.Service.History.sln
+++ /dev/null
@@ -1,90 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26430.12
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History", "src\Lykke.Service.History\Lykke.Service.History.csproj", "{E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "1. Instrastructure", "1. Instrastructure", "{CC2067D7-1971-47BB-B491-5649EA3C18B2}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History.Core", "src\Lykke.Service.History.Core\Lykke.Service.History.Core.csproj", "{F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "2. Repositories", "2. Repositories", "{BF745453-B940-470E-81BC-43FB67703D4E}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History.PostgresRepositories", "src\Lykke.Service.History.PostgresRepositories\Lykke.Service.History.PostgresRepositories.csproj", "{4BE49E02-AAAD-460B-8D00-57F412A3D181}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History.Services", "src\Lykke.Service.History.Services\Lykke.Service.History.Services.csproj", "{2D5F52EC-2A27-4045-81ED-72355E2A6325}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution items", "Solution items", "{6CA74DE0-A357-4934-9D8B-FEA3F0A2D690}"
- ProjectSection(SolutionItems) = preProject
- .gitignore = .gitignore
- README.md = README.md
- settings.yaml = settings.yaml
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3. Client", "3. Client", "{C9A2CFDE-EA32-4946-B679-7CE6EFA816B8}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History.Client", "client\Lykke.Service.History.Client\Lykke.Service.History.Client.csproj", "{3C300C31-97D3-41E8-A627-C53491BDA28B}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History.Tests", "tests\Lykke.Service.History.Tests\Lykke.Service.History.Tests.csproj", "{A61FFDEE-5725-4650-A788-6E55EE5EFD5B}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "4. Tests", "4. Tests", "{8F9036B1-5106-4C69-B2D2-B78EE52687A0}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lykke.Service.History.Contracts", "client\Lykke.Service.History.Contracts\Lykke.Service.History.Contracts.csproj", "{2064A769-4F07-4E1C-A946-7CFF768704F2}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lykke.Job.History", "src\Lykke.Job.History\Lykke.Job.History.csproj", "{20110F5A-E5BA-4147-BF4E-7258CB54FE93}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E414FDB9-FEEA-4CD0-9BBA-D1541601DF29}.Release|Any CPU.Build.0 = Release|Any CPU
- {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955}.Release|Any CPU.Build.0 = Release|Any CPU
- {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4BE49E02-AAAD-460B-8D00-57F412A3D181}.Release|Any CPU.Build.0 = Release|Any CPU
- {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2D5F52EC-2A27-4045-81ED-72355E2A6325}.Release|Any CPU.Build.0 = Release|Any CPU
- {3C300C31-97D3-41E8-A627-C53491BDA28B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3C300C31-97D3-41E8-A627-C53491BDA28B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3C300C31-97D3-41E8-A627-C53491BDA28B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3C300C31-97D3-41E8-A627-C53491BDA28B}.Release|Any CPU.Build.0 = Release|Any CPU
- {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A61FFDEE-5725-4650-A788-6E55EE5EFD5B}.Release|Any CPU.Build.0 = Release|Any CPU
- {2064A769-4F07-4E1C-A946-7CFF768704F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2064A769-4F07-4E1C-A946-7CFF768704F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2064A769-4F07-4E1C-A946-7CFF768704F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2064A769-4F07-4E1C-A946-7CFF768704F2}.Release|Any CPU.Build.0 = Release|Any CPU
- {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {20110F5A-E5BA-4147-BF4E-7258CB54FE93}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {F5B2F6B8-A8CC-4612-8F1D-C063EB8C8955} = {CC2067D7-1971-47BB-B491-5649EA3C18B2}
- {4BE49E02-AAAD-460B-8D00-57F412A3D181} = {BF745453-B940-470E-81BC-43FB67703D4E}
- {2D5F52EC-2A27-4045-81ED-72355E2A6325} = {CC2067D7-1971-47BB-B491-5649EA3C18B2}
- {3C300C31-97D3-41E8-A627-C53491BDA28B} = {C9A2CFDE-EA32-4946-B679-7CE6EFA816B8}
- {A61FFDEE-5725-4650-A788-6E55EE5EFD5B} = {8F9036B1-5106-4C69-B2D2-B78EE52687A0}
- {2064A769-4F07-4E1C-A946-7CFF768704F2} = {C9A2CFDE-EA32-4946-B679-7CE6EFA816B8}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {EB6C0EF4-AA6A-444D-8603-3669F73A58BC}
- EndGlobalSection
-EndGlobal
diff --git a/README.md b/README.md
index 3e331b3..03dc6c6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Lykke.Service.History
+# Antares.Service.History
# Purpose
@@ -6,13 +6,13 @@
# Contracts
-Input (v1, Lykke.Service.PostProcessing events; RabbitMQ, protobuf):
+Input (v1, Antares.Service.PostProcessing events; RabbitMQ, protobuf):
- CashInProcessedEvent, CashOutProcessedEvent, CashTransferProcessedEvent, ExecutionProcessedEvent, OrderPlacedEvent, OrderCancelledEvent.
-Input (v2, Lykke.Service.BlockchainCashinDetector; RabbitMQ, messagepack):
+Input (v2, Antares.Service.BlockchainCashinDetector; RabbitMQ, messagepack):
- CashinCompletedEvent.
-Input (v3, Lykke.Service.BlockchainCashoutProcessor; RabbitMQ, messagepack):
+Input (v3, Antares.Service.BlockchainCashoutProcessor; RabbitMQ, messagepack):
- CashoutCompletedEvent.
Input (v4, bitcoinservice; RabbitMQ, messagepack):
@@ -47,4 +47,4 @@ Output (HTTP):
- RabbitMQ (Cqrs);
# Service owners
-Core team
+Swisschain team
diff --git a/client/Lykke.Service.History.Client/Lykke.Service.History.Client.csproj b/client/Antares.Service.History.Client/Antares.Service.History.Client.csproj
similarity index 90%
rename from client/Lykke.Service.History.Client/Lykke.Service.History.Client.csproj
rename to client/Antares.Service.History.Client/Antares.Service.History.Client.csproj
index 23e3558..028773a 100644
--- a/client/Lykke.Service.History.Client/Lykke.Service.History.Client.csproj
+++ b/client/Antares.Service.History.Client/Antares.Service.History.Client.csproj
@@ -1,6 +1,6 @@
- netstandard2.0
+ netstandard2.1
1.0.1
Lykke
Lykke
@@ -27,13 +27,13 @@
-
-
-
true
lib/netstandard2.0
+
+
+
\ No newline at end of file
diff --git a/client/Lykke.Service.History.Client/AutofacExtension.cs b/client/Antares.Service.History.Client/AutofacExtension.cs
similarity index 91%
rename from client/Lykke.Service.History.Client/AutofacExtension.cs
rename to client/Antares.Service.History.Client/AutofacExtension.cs
index bff3149..5eb000b 100644
--- a/client/Lykke.Service.History.Client/AutofacExtension.cs
+++ b/client/Antares.Service.History.Client/AutofacExtension.cs
@@ -5,10 +5,8 @@
using Lykke.HttpClientGenerator;
using Lykke.HttpClientGenerator.Infrastructure;
using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-using Refit;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
/// History service autofac registration extension
@@ -35,7 +33,7 @@ public static void RegisterHistoryClient(
throw new ArgumentException("Value cannot be null or whitespace.",
nameof(HistoryServiceClientSettings.ServiceUrl));
- var clientBuilder = HttpClientGenerator.HttpClientGenerator.BuildForUrl(settings.ServiceUrl)
+ var clientBuilder = Lykke.HttpClientGenerator.HttpClientGenerator.BuildForUrl(settings.ServiceUrl)
.WithAdditionalCallsWrapper(new ExceptionHandlerCallsWrapper());
clientBuilder = builderConfigure?.Invoke(clientBuilder) ?? clientBuilder.WithoutRetries();
diff --git a/client/Lykke.Service.History.Client/HistoryClient.cs b/client/Antares.Service.History.Client/HistoryClient.cs
similarity index 95%
rename from client/Lykke.Service.History.Client/HistoryClient.cs
rename to client/Antares.Service.History.Client/HistoryClient.cs
index 0552bad..1f1d084 100644
--- a/client/Lykke.Service.History.Client/HistoryClient.cs
+++ b/client/Antares.Service.History.Client/HistoryClient.cs
@@ -1,6 +1,6 @@
using Lykke.HttpClientGenerator;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
///
diff --git a/client/Lykke.Service.History.Client/HistoryJsonConverter.cs b/client/Antares.Service.History.Client/HistoryJsonConverter.cs
similarity index 88%
rename from client/Lykke.Service.History.Client/HistoryJsonConverter.cs
rename to client/Antares.Service.History.Client/HistoryJsonConverter.cs
index b6beb81..4829ce5 100644
--- a/client/Lykke.Service.History.Client/HistoryJsonConverter.cs
+++ b/client/Antares.Service.History.Client/HistoryJsonConverter.cs
@@ -1,13 +1,10 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using Lykke.Service.History.Contracts;
-using Lykke.Service.History.Contracts.Enums;
-using Lykke.Service.History.Contracts.History;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.History;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
public class HistoryJsonConverter : JsonConverter
diff --git a/client/Lykke.Service.History.Client/HistoryServiceClientSettings.cs b/client/Antares.Service.History.Client/HistoryServiceClientSettings.cs
similarity index 88%
rename from client/Lykke.Service.History.Client/HistoryServiceClientSettings.cs
rename to client/Antares.Service.History.Client/HistoryServiceClientSettings.cs
index 1e9b1d0..e401246 100644
--- a/client/Lykke.Service.History.Client/HistoryServiceClientSettings.cs
+++ b/client/Antares.Service.History.Client/HistoryServiceClientSettings.cs
@@ -1,6 +1,6 @@
using Lykke.SettingsReader.Attributes;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
/// History client settings.
diff --git a/client/Lykke.Service.History.Client/IHistoryApi.cs b/client/Antares.Service.History.Client/IHistoryApi.cs
similarity index 89%
rename from client/Lykke.Service.History.Client/IHistoryApi.cs
rename to client/Antares.Service.History.Client/IHistoryApi.cs
index 7a0d40a..b61c696 100644
--- a/client/Lykke.Service.History.Client/IHistoryApi.cs
+++ b/client/Antares.Service.History.Client/IHistoryApi.cs
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.History;
using JetBrains.Annotations;
-using Lykke.Service.History.Contracts.Enums;
-using Lykke.Service.History.Contracts.History;
-using Microsoft.AspNetCore.Mvc;
using Refit;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
/// History client API interface.
diff --git a/client/Lykke.Service.History.Client/IHistoryClient.cs b/client/Antares.Service.History.Client/IHistoryClient.cs
similarity index 93%
rename from client/Lykke.Service.History.Client/IHistoryClient.cs
rename to client/Antares.Service.History.Client/IHistoryClient.cs
index 6a5f2d6..7dca88c 100644
--- a/client/Lykke.Service.History.Client/IHistoryClient.cs
+++ b/client/Antares.Service.History.Client/IHistoryClient.cs
@@ -1,6 +1,6 @@
using JetBrains.Annotations;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
/// History client interface.
diff --git a/client/Lykke.Service.History.Client/IOrdersApi.cs b/client/Antares.Service.History.Client/IOrdersApi.cs
similarity index 90%
rename from client/Lykke.Service.History.Client/IOrdersApi.cs
rename to client/Antares.Service.History.Client/IOrdersApi.cs
index 43146fb..8fca8fb 100644
--- a/client/Lykke.Service.History.Client/IOrdersApi.cs
+++ b/client/Antares.Service.History.Client/IOrdersApi.cs
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Orders;
using JetBrains.Annotations;
-using Lykke.Service.History.Contracts.Enums;
-using Lykke.Service.History.Contracts.History;
-using Lykke.Service.History.Contracts.Orders;
using Refit;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
/// Orders client API interface.
diff --git a/client/Lykke.Service.History.Client/ITradesApi.cs b/client/Antares.Service.History.Client/ITradesApi.cs
similarity index 90%
rename from client/Lykke.Service.History.Client/ITradesApi.cs
rename to client/Antares.Service.History.Client/ITradesApi.cs
index 388d9c5..735edb5 100644
--- a/client/Lykke.Service.History.Client/ITradesApi.cs
+++ b/client/Antares.Service.History.Client/ITradesApi.cs
@@ -1,12 +1,12 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.History;
using JetBrains.Annotations;
-using Lykke.Service.History.Contracts.Enums;
-using Lykke.Service.History.Contracts.History;
using Refit;
-namespace Lykke.Service.History.Client
+namespace Antares.Service.History.Client
{
///
/// Orders client API interface.
diff --git a/client/Lykke.Service.History.Contracts/Lykke.Service.History.Contracts.csproj b/client/Antares.Service.History.Contracts/Antares.Service.History.Contracts.csproj
similarity index 55%
rename from client/Lykke.Service.History.Contracts/Lykke.Service.History.Contracts.csproj
rename to client/Antares.Service.History.Contracts/Antares.Service.History.Contracts.csproj
index 9b1a5b5..1575194 100644
--- a/client/Lykke.Service.History.Contracts/Lykke.Service.History.Contracts.csproj
+++ b/client/Antares.Service.History.Contracts/Antares.Service.History.Contracts.csproj
@@ -2,11 +2,11 @@
1.0.0
- netstandard2.0
+ netstandard2.1
-
+
diff --git a/client/Lykke.Service.History.Contracts/Cqrs/Commands/CreateForwardCashinCommand.cs b/client/Antares.Service.History.Contracts/Cqrs/Commands/CreateForwardCashinCommand.cs
similarity index 81%
rename from client/Lykke.Service.History.Contracts/Cqrs/Commands/CreateForwardCashinCommand.cs
rename to client/Antares.Service.History.Contracts/Cqrs/Commands/CreateForwardCashinCommand.cs
index 05073da..527f3dc 100644
--- a/client/Lykke.Service.History.Contracts/Cqrs/Commands/CreateForwardCashinCommand.cs
+++ b/client/Antares.Service.History.Contracts/Cqrs/Commands/CreateForwardCashinCommand.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using ProtoBuf;
-namespace Lykke.Service.History.Contracts.Cqrs.Commands
+namespace Antares.Service.History.Contracts.Cqrs.Commands
{
[ProtoContract]
public class CreateForwardCashinCommand
diff --git a/client/Lykke.Service.History.Contracts/Cqrs/Commands/DeleteForwardCashinCommand.cs b/client/Antares.Service.History.Contracts/Cqrs/Commands/DeleteForwardCashinCommand.cs
similarity index 69%
rename from client/Lykke.Service.History.Contracts/Cqrs/Commands/DeleteForwardCashinCommand.cs
rename to client/Antares.Service.History.Contracts/Cqrs/Commands/DeleteForwardCashinCommand.cs
index b0bd2be..a96486c 100644
--- a/client/Lykke.Service.History.Contracts/Cqrs/Commands/DeleteForwardCashinCommand.cs
+++ b/client/Antares.Service.History.Contracts/Cqrs/Commands/DeleteForwardCashinCommand.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using ProtoBuf;
-namespace Lykke.Service.History.Contracts.Cqrs.Commands
+namespace Antares.Service.History.Contracts.Cqrs.Commands
{
[ProtoContract]
public class DeleteForwardCashinCommand
diff --git a/client/Lykke.Service.History.Contracts/Cqrs/Events/ForwardCashinCreatedEvent.cs b/client/Antares.Service.History.Contracts/Cqrs/Events/ForwardCashinCreatedEvent.cs
similarity index 81%
rename from client/Lykke.Service.History.Contracts/Cqrs/Events/ForwardCashinCreatedEvent.cs
rename to client/Antares.Service.History.Contracts/Cqrs/Events/ForwardCashinCreatedEvent.cs
index a3d7b81..7ef0fff 100644
--- a/client/Lykke.Service.History.Contracts/Cqrs/Events/ForwardCashinCreatedEvent.cs
+++ b/client/Antares.Service.History.Contracts/Cqrs/Events/ForwardCashinCreatedEvent.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using ProtoBuf;
-namespace Lykke.Service.History.Contracts.Cqrs.Events
+namespace Antares.Service.History.Contracts.Cqrs.Events
{
[ProtoContract]
public class ForwardCashinCreatedEvent
diff --git a/client/Lykke.Service.History.Contracts/Cqrs/Events/ForwardCashinDeletedEvent.cs b/client/Antares.Service.History.Contracts/Cqrs/Events/ForwardCashinDeletedEvent.cs
similarity index 70%
rename from client/Lykke.Service.History.Contracts/Cqrs/Events/ForwardCashinDeletedEvent.cs
rename to client/Antares.Service.History.Contracts/Cqrs/Events/ForwardCashinDeletedEvent.cs
index a2fc240..40bb00f 100644
--- a/client/Lykke.Service.History.Contracts/Cqrs/Events/ForwardCashinDeletedEvent.cs
+++ b/client/Antares.Service.History.Contracts/Cqrs/Events/ForwardCashinDeletedEvent.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using ProtoBuf;
-namespace Lykke.Service.History.Contracts.Cqrs.Events
+namespace Antares.Service.History.Contracts.Cqrs.Events
{
[ProtoContract]
public class ForwardCashinDeletedEvent
diff --git a/client/Lykke.Service.History.Contracts/Cqrs/HistoryBoundedContext.cs b/client/Antares.Service.History.Contracts/Cqrs/HistoryBoundedContext.cs
similarity index 69%
rename from client/Lykke.Service.History.Contracts/Cqrs/HistoryBoundedContext.cs
rename to client/Antares.Service.History.Contracts/Cqrs/HistoryBoundedContext.cs
index 5bfab1b..dbef386 100644
--- a/client/Lykke.Service.History.Contracts/Cqrs/HistoryBoundedContext.cs
+++ b/client/Antares.Service.History.Contracts/Cqrs/HistoryBoundedContext.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Lykke.Service.History.Contracts.Cqrs
+namespace Antares.Service.History.Contracts.Cqrs
{
///
/// History service bounded context
diff --git a/client/Lykke.Service.History.Contracts/Enums/HistoryState.cs b/client/Antares.Service.History.Contracts/Enums/HistoryState.cs
similarity index 62%
rename from client/Lykke.Service.History.Contracts/Enums/HistoryState.cs
rename to client/Antares.Service.History.Contracts/Enums/HistoryState.cs
index dcac352..1541d4e 100644
--- a/client/Lykke.Service.History.Contracts/Enums/HistoryState.cs
+++ b/client/Antares.Service.History.Contracts/Enums/HistoryState.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
///
/// History record state
diff --git a/client/Lykke.Service.History.Contracts/Enums/HistoryType.cs b/client/Antares.Service.History.Contracts/Enums/HistoryType.cs
similarity index 58%
rename from client/Lykke.Service.History.Contracts/Enums/HistoryType.cs
rename to client/Antares.Service.History.Contracts/Enums/HistoryType.cs
index eb6178b..2cbe61b 100644
--- a/client/Lykke.Service.History.Contracts/Enums/HistoryType.cs
+++ b/client/Antares.Service.History.Contracts/Enums/HistoryType.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
///
/// History type
diff --git a/client/Lykke.Service.History.Contracts/Enums/OrderSide.cs b/client/Antares.Service.History.Contracts/Enums/OrderSide.cs
similarity index 72%
rename from client/Lykke.Service.History.Contracts/Enums/OrderSide.cs
rename to client/Antares.Service.History.Contracts/Enums/OrderSide.cs
index 6917232..91679a3 100644
--- a/client/Lykke.Service.History.Contracts/Enums/OrderSide.cs
+++ b/client/Antares.Service.History.Contracts/Enums/OrderSide.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
///
/// Order side
diff --git a/client/Lykke.Service.History.Contracts/Enums/OrderStatus.cs b/client/Antares.Service.History.Contracts/Enums/OrderStatus.cs
similarity index 82%
rename from client/Lykke.Service.History.Contracts/Enums/OrderStatus.cs
rename to client/Antares.Service.History.Contracts/Enums/OrderStatus.cs
index 094168e..b6c3561 100644
--- a/client/Lykke.Service.History.Contracts/Enums/OrderStatus.cs
+++ b/client/Antares.Service.History.Contracts/Enums/OrderStatus.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
///
/// Order status
diff --git a/client/Lykke.Service.History.Contracts/Enums/OrderType.cs b/client/Antares.Service.History.Contracts/Enums/OrderType.cs
similarity index 75%
rename from client/Lykke.Service.History.Contracts/Enums/OrderType.cs
rename to client/Antares.Service.History.Contracts/Enums/OrderType.cs
index 7555787..fde9399 100644
--- a/client/Lykke.Service.History.Contracts/Enums/OrderType.cs
+++ b/client/Antares.Service.History.Contracts/Enums/OrderType.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
///
/// Order type
diff --git a/client/Lykke.Service.History.Contracts/Enums/TradeRole.cs b/client/Antares.Service.History.Contracts/Enums/TradeRole.cs
similarity index 73%
rename from client/Lykke.Service.History.Contracts/Enums/TradeRole.cs
rename to client/Antares.Service.History.Contracts/Enums/TradeRole.cs
index d55df3c..9e71d56 100644
--- a/client/Lykke.Service.History.Contracts/Enums/TradeRole.cs
+++ b/client/Antares.Service.History.Contracts/Enums/TradeRole.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
///
/// Trade role
diff --git a/client/Lykke.Service.History.Contracts/Enums/TradeType.cs b/client/Antares.Service.History.Contracts/Enums/TradeType.cs
similarity index 56%
rename from client/Lykke.Service.History.Contracts/Enums/TradeType.cs
rename to client/Antares.Service.History.Contracts/Enums/TradeType.cs
index 44006d8..b06af0c 100644
--- a/client/Lykke.Service.History.Contracts/Enums/TradeType.cs
+++ b/client/Antares.Service.History.Contracts/Enums/TradeType.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Contracts.Enums
+namespace Antares.Service.History.Contracts.Enums
{
public enum TradeType
{
diff --git a/client/Lykke.Service.History.Contracts/History/BaseHistoryModel.cs b/client/Antares.Service.History.Contracts/History/BaseHistoryModel.cs
similarity index 72%
rename from client/Lykke.Service.History.Contracts/History/BaseHistoryModel.cs
rename to client/Antares.Service.History.Contracts/History/BaseHistoryModel.cs
index 47fbae2..d21b33b 100644
--- a/client/Lykke.Service.History.Contracts/History/BaseHistoryModel.cs
+++ b/client/Antares.Service.History.Contracts/History/BaseHistoryModel.cs
@@ -1,7 +1,7 @@
using System;
-using Lykke.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Enums;
-namespace Lykke.Service.History.Contracts.History
+namespace Antares.Service.History.Contracts.History
{
public abstract class BaseHistoryModel
{
diff --git a/client/Lykke.Service.History.Contracts/History/CashinModel.cs b/client/Antares.Service.History.Contracts/History/CashinModel.cs
similarity index 78%
rename from client/Lykke.Service.History.Contracts/History/CashinModel.cs
rename to client/Antares.Service.History.Contracts/History/CashinModel.cs
index 6fab33d..e3f2d6a 100644
--- a/client/Lykke.Service.History.Contracts/History/CashinModel.cs
+++ b/client/Antares.Service.History.Contracts/History/CashinModel.cs
@@ -1,6 +1,6 @@
-using Lykke.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Enums;
-namespace Lykke.Service.History.Contracts.History
+namespace Antares.Service.History.Contracts.History
{
public class CashinModel : BaseHistoryModel
{
diff --git a/client/Lykke.Service.History.Contracts/History/CashoutModel.cs b/client/Antares.Service.History.Contracts/History/CashoutModel.cs
similarity index 78%
rename from client/Lykke.Service.History.Contracts/History/CashoutModel.cs
rename to client/Antares.Service.History.Contracts/History/CashoutModel.cs
index 17a8bbc..e436f05 100644
--- a/client/Lykke.Service.History.Contracts/History/CashoutModel.cs
+++ b/client/Antares.Service.History.Contracts/History/CashoutModel.cs
@@ -1,6 +1,6 @@
-using Lykke.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Enums;
-namespace Lykke.Service.History.Contracts.History
+namespace Antares.Service.History.Contracts.History
{
public class CashoutModel : BaseHistoryModel
{
diff --git a/client/Lykke.Service.History.Contracts/History/OrderEventModel.cs b/client/Antares.Service.History.Contracts/History/OrderEventModel.cs
similarity index 72%
rename from client/Lykke.Service.History.Contracts/History/OrderEventModel.cs
rename to client/Antares.Service.History.Contracts/History/OrderEventModel.cs
index 8bc04b6..c231c5a 100644
--- a/client/Lykke.Service.History.Contracts/History/OrderEventModel.cs
+++ b/client/Antares.Service.History.Contracts/History/OrderEventModel.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using Lykke.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Enums;
-namespace Lykke.Service.History.Contracts.History
+namespace Antares.Service.History.Contracts.History
{
public class OrderEventModel : BaseHistoryModel
{
diff --git a/client/Lykke.Service.History.Contracts/History/TradeModel.cs b/client/Antares.Service.History.Contracts/History/TradeModel.cs
similarity index 81%
rename from client/Lykke.Service.History.Contracts/History/TradeModel.cs
rename to client/Antares.Service.History.Contracts/History/TradeModel.cs
index b4f2b03..93ad703 100644
--- a/client/Lykke.Service.History.Contracts/History/TradeModel.cs
+++ b/client/Antares.Service.History.Contracts/History/TradeModel.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using Lykke.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Enums;
-namespace Lykke.Service.History.Contracts.History
+namespace Antares.Service.History.Contracts.History
{
public class TradeModel : BaseHistoryModel
{
diff --git a/client/Lykke.Service.History.Contracts/Orders/OrderModel.cs b/client/Antares.Service.History.Contracts/Orders/OrderModel.cs
similarity index 91%
rename from client/Lykke.Service.History.Contracts/Orders/OrderModel.cs
rename to client/Antares.Service.History.Contracts/Orders/OrderModel.cs
index 316a12c..f82fc5b 100644
--- a/client/Lykke.Service.History.Contracts/Orders/OrderModel.cs
+++ b/client/Antares.Service.History.Contracts/Orders/OrderModel.cs
@@ -1,7 +1,7 @@
using System;
-using Lykke.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Enums;
-namespace Lykke.Service.History.Contracts.Orders
+namespace Antares.Service.History.Contracts.Orders
{
public class OrderModel
{
diff --git a/client/Antares.Service.History.GrpcClient/Antares.Service.History.GrpcClient.csproj b/client/Antares.Service.History.GrpcClient/Antares.Service.History.GrpcClient.csproj
new file mode 100644
index 0000000..fddc231
--- /dev/null
+++ b/client/Antares.Service.History.GrpcClient/Antares.Service.History.GrpcClient.csproj
@@ -0,0 +1,58 @@
+
+
+
+ netstandard2.0
+ Antares.Service.History.GrpcClient
+ Antares.Service.History.GrpcClient
+ Antares.Service.History.GrpcClient
+ Swisschain
+ Antares
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+ $(TargetsForTfmSpecificBuildOutput);PackReferencedProjectOutputs
+
+
+
+ true
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/client/Antares.Service.History.GrpcClient/Common/BaseGrpcClient.cs b/client/Antares.Service.History.GrpcClient/Common/BaseGrpcClient.cs
new file mode 100644
index 0000000..eb10ba8
--- /dev/null
+++ b/client/Antares.Service.History.GrpcClient/Common/BaseGrpcClient.cs
@@ -0,0 +1,42 @@
+using System;
+using Grpc.Core;
+using Grpc.Core.Interceptors;
+
+namespace Antares.Service.History.GrpcClient.Common
+{
+ public abstract class BaseGrpcClient : IDisposable
+ {
+ protected readonly Channel _channel;
+
+ protected BaseGrpcClient(string serverGrpcUrl)
+ {
+ var lowerCaseUrl = serverGrpcUrl.ToLowerInvariant();
+
+ if (!lowerCaseUrl.StartsWith("http"))
+ {
+ throw new InvalidOperationException("Specify protocol explicitly ('http://' or 'https://')");
+ }
+
+ var isHttps = lowerCaseUrl.StartsWith("https://");
+
+ // It works only when there is no protocol in the URL :-\
+ var correctedUrl = serverGrpcUrl
+ .Replace("https://", string.Empty)
+ .Replace("http://", string.Empty);
+
+ if (!isHttps)
+ {
+ AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
+ }
+
+ var credentials = isHttps ? new SslCredentials() : ChannelCredentials.Insecure;
+
+ _channel = new Channel(correctedUrl, credentials);
+ }
+
+ public void Dispose()
+ {
+ _channel.ShutdownAsync().GetAwaiter().GetResult();
+ }
+ }
+}
diff --git a/client/Antares.Service.History.GrpcClient/HistoryClient.cs b/client/Antares.Service.History.GrpcClient/HistoryClient.cs
new file mode 100644
index 0000000..7f85e59
--- /dev/null
+++ b/client/Antares.Service.History.GrpcClient/HistoryClient.cs
@@ -0,0 +1,23 @@
+using Antares.Service.History.GrpcClient.Common;
+using Antares.Service.History.GrpcContract.Monitoring;
+using Antares.Service.History.GrpcContract.Orders;
+using Antares.Service.History.GrpcContract.Trades;
+
+namespace Antares.Service.History.GrpcClient
+{
+ public class HistoryGrpcClient : BaseGrpcClient, IHistoryGrpcClient
+ {
+ public HistoryGrpcClient(string serverGrpcUrl) : base(serverGrpcUrl)
+ {
+ Monitoring = new MonitoringService.MonitoringServiceClient(_channel);
+ Orders = new Orders.OrdersClient(_channel);
+ Trades = new Trades.TradesClient(_channel);
+ History = new GrpcContract.History.History.HistoryClient(_channel);
+ }
+
+ public MonitoringService.MonitoringServiceClient Monitoring { get; }
+ public Orders.OrdersClient Orders { get; }
+ public Trades.TradesClient Trades { get; }
+ public GrpcContract.History.History.HistoryClient History { get; }
+ }
+}
diff --git a/client/Antares.Service.History.GrpcClient/IHistoryGrpcClient.cs b/client/Antares.Service.History.GrpcClient/IHistoryGrpcClient.cs
new file mode 100644
index 0000000..f89c2e8
--- /dev/null
+++ b/client/Antares.Service.History.GrpcClient/IHistoryGrpcClient.cs
@@ -0,0 +1,17 @@
+using Antares.Service.History.GrpcContract.Monitoring;
+using Antares.Service.History.GrpcContract.Orders;
+using Antares.Service.History.GrpcContract.Trades;
+
+namespace Antares.Service.History.GrpcClient
+{
+ public interface IHistoryGrpcClient
+ {
+ MonitoringService.MonitoringServiceClient Monitoring { get; }
+
+ Orders.OrdersClient Orders { get; }
+
+ Trades.TradesClient Trades { get; }
+
+ GrpcContract.History.History.HistoryClient History { get; }
+ }
+}
diff --git a/client/Antares.Service.History.GrpcContract/Antares.Service.History.GrpcContract.csproj b/client/Antares.Service.History.GrpcContract/Antares.Service.History.GrpcContract.csproj
new file mode 100644
index 0000000..1624303
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/Antares.Service.History.GrpcContract.csproj
@@ -0,0 +1,39 @@
+
+
+
+ netstandard2.0
+ Antares.Service.History.GrpcContract
+ Antares.Service.History.GrpcContract
+ Antares.Service.History.GrpcContract
+ Swisschain
+ Sirius
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/client/Antares.Service.History.GrpcContract/Common/BigDecimal.cs b/client/Antares.Service.History.GrpcContract/Common/BigDecimal.cs
new file mode 100644
index 0000000..5d31375
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/Common/BigDecimal.cs
@@ -0,0 +1,17 @@
+using System.Globalization;
+
+namespace Antares.Service.History.GrpcContract.Common
+{
+ public partial class BigDecimal
+ {
+ public static implicit operator decimal(BigDecimal value)
+ {
+ return decimal.Parse(value.Value, CultureInfo.InvariantCulture);
+ }
+
+ public static implicit operator BigDecimal(decimal value)
+ {
+ return new BigDecimal { Value = value.ToString(CultureInfo.InvariantCulture) };
+ }
+ }
+}
diff --git a/client/Antares.Service.History.GrpcContract/common.proto b/client/Antares.Service.History.GrpcContract/common.proto
new file mode 100644
index 0000000..a67ef4d
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/common.proto
@@ -0,0 +1,151 @@
+syntax = "proto3";
+
+option csharp_namespace = "Antares.Service.History.GrpcContract.Common";
+
+import "google/protobuf/struct.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+package antares.service.history.common;
+
+enum PaginationOrder {
+ ASC = 0;
+ DESC = 1;
+}
+
+message PaginatedInt32Response {
+ int32 offset = 1;
+
+ int32 count = 2;
+}
+
+message PaginationInt32 {
+
+ int32 offset = 2;
+
+ int32 limit = 3;
+}
+
+message ErrorResponseBody {
+
+ enum ErrorCode {
+ UNKNOWN = 0;
+ INVALID_PARAMETERS = 1;
+ NOT_AUTHORIZED = 2;
+ NOT_FOUND = 3;
+ BROKER_ACCOUNT_INACTIVE = 4;
+ }
+
+ ErrorCode error_code = 1;
+ string error_message = 2;
+}
+
+message BigDecimal {
+ string value = 1;
+}
+
+message HistoryResponseItem {
+ string id = 1;
+
+ string wallet_id = 2;
+
+ google.protobuf.Timestamp timestamp = 3;
+
+ HistoryType type = 4;
+
+ oneof body {
+ CashInModel cash_in = 5;
+ CashOutModel cash_out = 6;
+ TradeModel trade = 7;
+ OrderEventModel order_event = 8;
+ }
+}
+
+message TradeModel {
+ string asset_pair_id = 1;
+
+ antares.service.history.common.BigDecimal base_volume = 2;
+
+ string base_asset_id = 3;
+
+ string quoting_asset_id = 4;
+
+ antares.service.history.common.BigDecimal quoting_volume = 5;
+
+ antares.service.history.common.BigDecimal price = 6;
+
+ antares.service.history.common.BigDecimal fee_size = 7;
+
+ google.protobuf.StringValue fee_asset_id = 8;
+
+ int32 index = 9;
+
+ TradeRole Role = 10;
+
+ string order_id = 11;
+}
+
+message CashInModel {
+ antares.service.history.common.BigDecimal volume = 1;
+
+ string asset_id = 2;
+
+ google.protobuf.StringValue blockchain_hash = 3;
+
+ antares.service.history.common.BigDecimal fee_size = 4;
+}
+
+message CashOutModel {
+ antares.service.history.common.BigDecimal volume = 1;
+
+ string asset_id = 2;
+
+ google.protobuf.StringValue blockchain_hash = 3;
+
+ antares.service.history.common.BigDecimal fee_size = 4;
+}
+
+
+message OrderEventModel {
+ antares.service.history.common.BigDecimal volume = 1;
+
+ string asset_pair_id = 2;
+
+ string order_id = 3;
+
+ antares.service.history.common.BigDecimal price = 4;
+
+ OrderStatus status = 5;
+}
+
+enum TradeRole
+{
+ UNKNOWN = 0;
+ MAKER = 1;
+ TAKER = 2;
+}
+
+enum HistoryType {
+ CASH_IN = 0;
+ CASH_OUT = 2;
+ TRADE = 3;
+ ORDER_EVENT = 4;
+}
+
+enum OrderStatus {
+ UNKNOWN_ORDER = 0;
+ PLACED = 1;
+ PARTIALLY_MATCHED = 2;
+ MATCHED = 3;
+ PENDING = 4;
+ CANCELLED = 5;
+ REPLACED = 6;
+ REJECTED = 7;
+}
+
+enum TradeType
+{
+ BUY = 0;
+ SELL = 1;
+ NONE = 2;
+}
\ No newline at end of file
diff --git a/client/Antares.Service.History.GrpcContract/history.proto b/client/Antares.Service.History.GrpcContract/history.proto
new file mode 100644
index 0000000..893a260
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/history.proto
@@ -0,0 +1,40 @@
+syntax = "proto3";
+
+option csharp_namespace = "Antares.Service.History.GrpcContract.History";
+
+import "common.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+package antares.service.history.history;
+
+service History {
+ rpc GetHistory (HistoryGetHistoryRequest) returns (HistoryGetHistoryResponse);
+
+ rpc GetHistoryItem (GetHistoryItemRequest) returns (GetHistoryItemResponse);
+}
+
+message GetHistoryItemRequest {
+ string wallet_id = 1;
+ string id = 2;
+}
+
+message HistoryGetHistoryRequest {
+ string wallet_id = 1;
+ repeated antares.service.history.common.HistoryType type = 2;
+ google.protobuf.StringValue asset_id = 3;
+ google.protobuf.StringValue asset_pair_id = 4;
+ antares.service.history.common.PaginationInt32 pagination = 5;
+ google.protobuf.Timestamp from = 6;
+ google.protobuf.Timestamp to = 7;
+}
+
+message GetHistoryItemResponse {
+ antares.service.history.common.HistoryResponseItem item = 1;
+}
+
+message HistoryGetHistoryResponse {
+ repeated antares.service.history.common.HistoryResponseItem items = 1;
+
+ antares.service.history.common.PaginatedInt32Response pagination = 2;
+}
diff --git a/client/Antares.Service.History.GrpcContract/isalive.proto b/client/Antares.Service.History.GrpcContract/isalive.proto
new file mode 100644
index 0000000..4ad2992
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/isalive.proto
@@ -0,0 +1,23 @@
+syntax = "proto3";
+
+option csharp_namespace = "Antares.Service.History.GrpcContract.Monitoring";
+
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+package common;
+
+service MonitoringService {
+ rpc IsAlive (IsAliveRequest) returns (IsAliveResponse);
+}
+
+message IsAliveRequest {
+}
+
+message IsAliveResponse {
+ string name = 1;
+ string version = 2;
+ google.protobuf.Timestamp started_at = 3;
+ string env = 4;
+ string host_name = 5;
+}
diff --git a/client/Antares.Service.History.GrpcContract/orders.proto b/client/Antares.Service.History.GrpcContract/orders.proto
new file mode 100644
index 0000000..8d7e89f
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/orders.proto
@@ -0,0 +1,118 @@
+syntax = "proto3";
+
+option csharp_namespace = "Antares.Service.History.GrpcContract.Orders";
+
+import "common.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+package antares.service.history.orders;
+
+service Orders {
+ rpc GetOrder (GetOrderRequest) returns (GetOrderResponse);
+
+ rpc GetOrderList (GetOrderListRequest) returns (GetOrderListResponse);
+
+ rpc GetOrdersByDates (GetOrdersByDatesRequest) returns (GetOrderListResponse);
+
+ rpc GetActiveOrders (GetActiveOrdersRequest) returns (GetOrderListResponse);
+}
+
+message GetOrderRequest {
+ string id = 1;
+}
+
+message GetOrderResponse {
+ .antares.service.history.orders.OrderModel item = 1;
+}
+
+message GetOrderListResponse {
+ antares.service.history.common.PaginatedInt32Response pagination = 1;
+
+ repeated .antares.service.history.orders.OrderModel items = 2;
+}
+
+message GetOrderListRequest {
+ string wallet_id = 1;
+ repeated antares.service.history.common.OrderStatus status = 2;
+ repeated OrderType type = 3;
+ google.protobuf.StringValue asset_pair_id = 4;
+ antares.service.history.common.PaginationInt32 pagination = 5;
+}
+
+message GetOrdersByDatesRequest {
+ antares.service.history.common.PaginationInt32 pagination = 1;
+ google.protobuf.Timestamp from = 2;
+ google.protobuf.Timestamp to = 3;
+}
+
+message GetActiveOrdersRequest {
+ string wallet_id = 1;
+ google.protobuf.StringValue asset_pair_id = 2;
+ antares.service.history.common.PaginationInt32 pagination = 3;
+}
+
+message GetHistoryItemResponse {
+ antares.service.history.common.HistoryResponseItem item = 1;
+}
+
+message GetTradesResponse {
+ repeated antares.service.history.common.HistoryResponseItem items = 1;
+
+ antares.service.history.common.PaginatedInt32Response pagination = 2;
+}
+
+enum OrderType {
+ UNKNOWN_TYPE = 0;
+ MARKET = 1;
+ LIMIT = 2;
+ STOP_LIMIT = 3;
+}
+
+enum OrderSide {
+ UNKNOWN = 0;
+ BUY = 1;
+ SELL = 2;
+}
+
+message OrderModel {
+ string id = 1;
+
+ string matching_id = 2;
+
+ string wallet_id = 3;
+
+ OrderType type = 4;
+
+ OrderSide side = 5;
+
+ antares.service.history.common.OrderStatus status = 6;
+
+ string asset_pair_id = 7;
+
+ antares.service.history.common.BigDecimal volume = 8;
+
+ antares.service.history.common.BigDecimal price = 9;
+
+ google.protobuf.Timestamp create_dt = 10;
+
+ google.protobuf.Timestamp register_dt = 11;
+
+ google.protobuf.Timestamp status_dt = 12;
+
+ google.protobuf.Timestamp match_dt = 13;
+
+ antares.service.history.common.BigDecimal remaining_volume = 14;
+
+ google.protobuf.StringValue RejectReason = 15;
+
+ antares.service.history.common.BigDecimal lower_limit_price = 16;
+
+ antares.service.history.common.BigDecimal lower_price = 17;
+
+ antares.service.history.common.BigDecimal upper_limit_price = 18;
+
+ antares.service.history.common.BigDecimal upper_price = 19;
+
+ bool straight = 20;
+}
\ No newline at end of file
diff --git a/client/Antares.Service.History.GrpcContract/trades.proto b/client/Antares.Service.History.GrpcContract/trades.proto
new file mode 100644
index 0000000..b7e720a
--- /dev/null
+++ b/client/Antares.Service.History.GrpcContract/trades.proto
@@ -0,0 +1,49 @@
+syntax = "proto3";
+
+option csharp_namespace = "Antares.Service.History.GrpcContract.Trades";
+
+import "common.proto";
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/wrappers.proto";
+
+package antares.service.history.trades;
+
+service Trades {
+ rpc GetTrades (GetTradesRequest) returns (GetTradesResponse);
+
+ rpc GetTradesByOrderId (GetTradesByOrderIdRequest) returns (GetTradesResponse);
+
+ rpc GetTradesByDates (GetTradesByDatesRequest) returns (GetTradesResponse);
+}
+
+message GetTradesByOrderIdRequest {
+ string wallet_id = 1;
+ string id = 2;
+}
+
+message GetTradesRequest {
+ string wallet_id = 1;
+ repeated antares.service.history.common.HistoryType type = 2;
+ google.protobuf.StringValue asset_id = 3;
+ google.protobuf.StringValue asset_pair_id = 4;
+ antares.service.history.common.PaginationInt32 pagination = 5;
+ google.protobuf.Timestamp from = 6;
+ google.protobuf.Timestamp to = 7;
+ antares.service.history.common.TradeType trade_type = 8;
+}
+
+message GetTradesByDatesRequest {
+ antares.service.history.common.PaginationInt32 pagination = 1;
+ google.protobuf.Timestamp from = 2;
+ google.protobuf.Timestamp to = 3;
+}
+
+message GetHistoryItemResponse {
+ antares.service.history.common.HistoryResponseItem item = 1;
+}
+
+message GetTradesResponse {
+ repeated antares.service.history.common.HistoryResponseItem items = 1;
+
+ antares.service.history.common.PaginatedInt32Response pagination = 2;
+}
diff --git a/client/Lykke.Service.History.Client/Lykke.Service.History.Client.xml b/client/Lykke.Service.History.Client/Lykke.Service.History.Client.xml
deleted file mode 100644
index 38d0e89..0000000
--- a/client/Lykke.Service.History.Client/Lykke.Service.History.Client.xml
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
-
- Lykke.Service.History.Client
-
-
-
-
- History service autofac registration extension
-
-
-
-
- Registers in Autofac container using .
-
- Autofac container builder.
- History client settings.
- Optional configure handler.
-
-
-
-
- History API aggregating interface.
-
-
-
- C-tor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- History client settings.
-
-
-
- Service url.
-
-
-
- History client API interface.
-
-
-
-
- Get history by wallet id
-
-
-
-
-
-
-
-
-
-
-
-
-
- Get history item by id
-
-
-
-
-
-
-
- History client interface.
-
-
-
-
- History api interface (trade \ cashin \ cashout \ transfer \ order event)
-
-
-
-
- Orders api interface
-
-
-
-
- Trades api interface
-
-
-
-
- Orders client API interface.
-
-
-
-
- Get order by id
-
-
-
-
-
-
- Get order list by wallet id
-
-
-
-
-
-
-
-
-
-
-
- Get active orders by wallet id
-
-
-
-
-
-
-
-
-
- Orders client API interface.
-
-
-
-
- Get trades by wallet id
-
-
-
-
-
-
-
-
-
-
-
-
-
- Get order trades
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/settings.yaml b/settings.yaml
index a9b54d7..49a48a1 100644
--- a/settings.yaml
+++ b/settings.yaml
@@ -22,6 +22,22 @@ HistoryService:
WalletIdsToLog:
settings-key: HistoryService-WalletIdsToLog
types: [Optional, JsonArray]
+ MatchingEngineRabbit:
+ ConnectionString:
+ settings-key: MatchingEngineRabbitMqConnectionString
+ types:
+ - RabbitMq
+ AlternativeConnectionString:
+ settings-key: AlternateMatchingEngineRabbitMqConnectionString
+ types:
+ - RabbitMq
+ - Optional
+ Exchange:
+ settings-key: MatchingEngineSpotEventsExchange
+ CqrsEnabled:
+ settings-key: HistoryService-CqrsEnabled
+ types:
+ - Optional
MonitoringServiceClient:
MonitoringServiceUrl:
settings-key: MonitoringServiceUrl
diff --git a/sql/1.2/1-create-schema.sql b/sql/1.2/1-create-schema.sql
new file mode 100644
index 0000000..444ea8d
--- /dev/null
+++ b/sql/1.2/1-create-schema.sql
@@ -0,0 +1,57 @@
+CREATE SCHEMA IF NOT EXISTS history;
+
+CREATE TABLE history.history (
+ id uuid NOT NULL,
+ wallet_id uuid NOT NULL,
+ asset_id text,
+ assetpair_id text,
+ volume numeric(28,10) NOT NULL,
+ type integer NOT NULL,
+ create_dt timestamp with time zone NOT NULL,
+ context jsonb
+);
+
+CREATE TABLE history.orders (
+ id uuid NOT NULL,
+ matching_id uuid NOT NULL,
+ wallet_id uuid NOT NULL,
+ type integer NOT NULL,
+ side integer NOT NULL,
+ status integer NOT NULL,
+ assetpair_id text NOT NULL,
+ volume numeric(28,10) NOT NULL,
+ price numeric(28,10),
+ create_dt timestamp with time zone NOT NULL,
+ register_dt timestamp with time zone NOT NULL,
+ status_dt timestamp with time zone NOT NULL,
+ match_dt timestamp with time zone,
+ remaining_volume numeric(28,10) NOT NULL,
+ reject_reason text,
+ lower_limit_price numeric(28,10),
+ lower_price numeric(28,10),
+ upper_limit_price numeric(28,10),
+ upper_price numeric(28,10),
+ straight boolean NOT NULL,
+ sequence_number bigint NOT NULL
+);
+
+ALTER TABLE ONLY history.history
+ ADD CONSTRAINT history_pkey PRIMARY KEY (id, wallet_id);
+
+ALTER TABLE ONLY history.orders
+ ADD CONSTRAINT orders_pkey PRIMARY KEY (id);
+
+CREATE INDEX history_type_pair_date_idx ON history.history USING btree (type, assetpair_id, create_dt DESC);
+
+CREATE INDEX history_wallet_type_date_idx ON history.history USING btree (wallet_id, type, create_dt DESC);
+
+CREATE INDEX orders_wallet_type_date_idx ON history.orders USING btree (wallet_id, type, create_dt DESC);
+
+alter table history.orders alter column volume type numeric;
+alter table history.orders alter column price type numeric;
+alter table history.orders alter column remaining_volume type numeric;
+alter table history.orders alter column lower_limit_price type numeric;
+alter table history.orders alter column lower_price type numeric;
+alter table history.orders alter column upper_limit_price type numeric;
+alter table history.orders alter column upper_price type numeric;
+alter table history.history alter column volume type numeric;
\ No newline at end of file
diff --git a/sql/1.2/2-migrate-data.sql b/sql/1.2/2-migrate-data.sql
new file mode 100644
index 0000000..13e94d7
--- /dev/null
+++ b/sql/1.2/2-migrate-data.sql
@@ -0,0 +1,7 @@
+insert into history.history
+select * from public.history
+ON CONFLICT (id, wallet_id) DO NOTHING;
+
+insert into history.orders
+select * from public.orders
+ON CONFLICT (id) DO NOTHING;
\ No newline at end of file
diff --git a/src/Lykke.Job.History/Lykke.Job.History.csproj b/src/Antares.Job.History/Antares.Job.History.csproj
similarity index 68%
rename from src/Lykke.Job.History/Lykke.Job.History.csproj
rename to src/Antares.Job.History/Antares.Job.History.csproj
index b82d6df..30210da 100644
--- a/src/Lykke.Job.History/Lykke.Job.History.csproj
+++ b/src/Antares.Job.History/Antares.Job.History.csproj
@@ -1,16 +1,16 @@
- netcoreapp2.2
+ net5.0
Exe
1.0.1
- bin\Release\netcoreapp2.0\Lykke.Job.History.xml
+ bin\Release\net5.0\Antares.Job.History.xml
1701;1702;1705;1591
latest
- bin\Debug\netcoreapp2.0\Lykke.Job.History.xml
+ bin\Debug\net5.0\Antares.Job.History.xml
1701;1702;1705;1591
latest
@@ -23,27 +23,29 @@
+
+
+
+
-
-
-
+
-
-
-
+
-
+
+
+
diff --git a/src/Antares.Job.History/AutoMapper/ServiceProfile.cs b/src/Antares.Job.History/AutoMapper/ServiceProfile.cs
new file mode 100644
index 0000000..f47df29
--- /dev/null
+++ b/src/Antares.Job.History/AutoMapper/ServiceProfile.cs
@@ -0,0 +1,40 @@
+using System;
+using Antares.Service.History.Contracts.Cqrs.Commands;
+using Antares.Service.History.Contracts.History;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using AutoMapper;
+using OrderModel = Antares.Job.History.RabbitSubscribers.Models.OrderModel;
+using TradeModel = Antares.Job.History.RabbitSubscribers.Models.TradeModel;
+
+namespace Antares.Job.History.AutoMapper
+{
+ public class ServiceProfile : Profile
+ {
+ public ServiceProfile()
+ {
+ CreateMap();
+
+ CreateMap();
+
+ CreateMap()
+ .ForMember(x => x.Id, o => o.MapFrom(s => s.OperationId))
+ .ForMember(x => x.State, o => o.UseValue(HistoryState.Finished))
+ .ForMember(x => x.Volume, o => o.MapFrom(s => Math.Abs(s.Volume)));
+
+ CreateMap();
+
+ CreateMap()
+ .IncludeBase();
+ CreateMap()
+ .IncludeBase();
+ CreateMap()
+ .IncludeBase();
+ CreateMap()
+ .IncludeBase();
+
+ CreateMap();
+ }
+ }
+}
diff --git a/src/Antares.Job.History/Dockerfile b/src/Antares.Job.History/Dockerfile
new file mode 100644
index 0000000..e26f3c9
--- /dev/null
+++ b/src/Antares.Job.History/Dockerfile
@@ -0,0 +1,6 @@
+FROM mcr.microsoft.com/dotnet/aspnet:5.0.1-buster-slim
+WORKDIR /app
+EXPOSE 5001
+EXPOSE 5000
+COPY . .
+ENTRYPOINT ["dotnet", "Antares.Job.History.dll"]
diff --git a/src/Lykke.Job.History/Modules/CqrsModule.cs b/src/Antares.Job.History/Modules/CqrsModule.cs
similarity index 69%
rename from src/Lykke.Job.History/Modules/CqrsModule.cs
rename to src/Antares.Job.History/Modules/CqrsModule.cs
index cae7e4b..93b6987 100644
--- a/src/Lykke.Job.History/Modules/CqrsModule.cs
+++ b/src/Antares.Job.History/Modules/CqrsModule.cs
@@ -1,5 +1,14 @@
using System;
using System.Collections.Generic;
+using Antares.Job.History.RabbitSubscribers;
+using Antares.Job.History.Workflow.ExecutionProcessing;
+using Antares.Job.History.Workflow.Handlers;
+using Antares.Job.History.Workflow.Projections;
+using Antares.Sdk.Services;
+using Antares.Service.History.Contracts.Cqrs;
+using Antares.Service.History.Contracts.Cqrs.Commands;
+using Antares.Service.History.Contracts.Cqrs.Events;
+using Antares.Service.History.Core.Settings;
using Autofac;
using Lykke.Bitcoin.Contracts;
using Lykke.Bitcoin.Contracts.Events;
@@ -9,24 +18,17 @@
using Lykke.Cqrs.Middleware.Logging;
using Lykke.Job.BlockchainCashinDetector.Contract;
using Lykke.Job.BlockchainCashoutProcessor.Contract;
-using Lykke.Job.History.Workflow.ExecutionProcessing;
-using Lykke.Job.History.Workflow.Handlers;
-using Lykke.Job.History.Workflow.Projections;
+using Lykke.Job.SiriusCashoutProcessor.Contract;
+using Lykke.Job.SiriusDepositsDetector.Contract;
using Lykke.Messaging;
using Lykke.Messaging.Contract;
using Lykke.Messaging.RabbitMq;
using Lykke.Messaging.Serialization;
-using Lykke.Sdk;
-using Lykke.Service.History.Contracts.Cqrs;
-using Lykke.Service.History.Contracts.Cqrs.Commands;
-using Lykke.Service.History.Contracts.Cqrs.Events;
-using Lykke.Service.History.Core.Settings;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
+using Lykke.RabbitMqBroker.Deduplication;
using Lykke.SettingsReader;
using RabbitMQ.Client;
-namespace Lykke.Job.History.Modules
+namespace Antares.Job.History.Modules
{
public class CqrsModule : Module
{
@@ -39,6 +41,23 @@ public CqrsModule(IReloadingManager settingsManager)
protected override void Load(ContainerBuilder builder)
{
+ builder.RegisterInstance(_settings).AsSelf();
+
+ builder.RegisterType()
+ .As()
+ .SingleInstance();
+
+ builder
+ .RegisterType()
+ .WithParameter(TypedParameter.From(_settings.MatchingEngineRabbit))
+ .WithParameter(TypedParameter.From(_settings.WalletIdsToLog))
+ .SingleInstance();
+
+ builder.RegisterType()
+ .As()
+ .SingleInstance()
+ .WithParameter(TypedParameter.From(_settings.MatchingEngineRabbit));
+
builder.Register(context => new AutofacDependencyResolver(context)).As()
.SingleInstance();
@@ -52,22 +71,12 @@ protected override void Load(ContainerBuilder builder)
builder.RegisterType().As();
builder.RegisterType()
- .WithParameter(TypedParameter.From(_settings.Cqrs.RabbitConnString))
.WithParameter(TypedParameter.From(_settings.WalletIdsToLog))
+ .WithParameter(TypedParameter.From(_settings.MatchingEngineRabbit))
.WithParameter(new NamedParameter("prefetchCount", _settings.RabbitPrefetchCount))
.WithParameter(new NamedParameter("batchCount", _settings.PostgresOrdersBatchSize))
.SingleInstance();
- builder.RegisterType()
- .WithParameter(TypedParameter.From(_settings.Cqrs.RabbitConnString))
- .WithParameter(TypedParameter.From(_settings.WalletIdsToLog))
- .WithParameter(new NamedParameter("prefetchCount", _settings.RabbitPrefetchCount))
- .WithParameter(new NamedParameter("batchCount", _settings.PostgresOrdersBatchSize))
- .SingleInstance();
-
- builder.RegisterType();
- builder.RegisterType();
- builder.RegisterType();
builder.RegisterType();
builder.RegisterType();
@@ -91,11 +100,13 @@ protected override void Load(ContainerBuilder builder)
}),
new RabbitMqTransportFactory(logFactory));
var cqrsEngine = CreateEngine(ctx, messagingEngine, logFactory);
- cqrsEngine.StartPublishers();
+
+ if (_settings.CqrsEnabled)
+ cqrsEngine.StartPublishers();
+
return cqrsEngine;
})
.As()
- .AutoActivate()
.SingleInstance();
}
@@ -125,22 +136,9 @@ private CqrsEngine CreateEngine(
Register.DefaultEndpointResolver(sagasProtobufEndpointResolver),
Register.EventInterceptors(new DefaultEventLoggingInterceptor(ctx.Resolve())),
+ Register.CommandInterceptors(new DefaultCommandLoggingInterceptor(ctx.Resolve())),
Register.BoundedContext(HistoryBoundedContext.Name)
- .ListeningEvents(typeof(CashInProcessedEvent))
- .From(PostProcessingBoundedContext.Name)
- .On(defaultRoute)
- .WithProjection(typeof(CashInProjection), PostProcessingBoundedContext.Name)
-
- .ListeningEvents(typeof(CashOutProcessedEvent))
- .From(PostProcessingBoundedContext.Name)
- .On(defaultRoute)
- .WithProjection(typeof(CashOutProjection), PostProcessingBoundedContext.Name)
-
- .ListeningEvents(typeof(CashTransferProcessedEvent))
- .From(PostProcessingBoundedContext.Name)
- .On(defaultRoute)
- .WithProjection(typeof(CashTransferProjection), PostProcessingBoundedContext.Name)
.ListeningEvents(typeof(CashoutCompletedEvent), typeof(CashinCompletedEvent))
.From(BitcoinBoundedContext.Name)
@@ -148,16 +146,28 @@ private CqrsEngine CreateEngine(
.WithEndpointResolver(sagasMessagePackEndpointResolver)
.WithProjection(typeof(TransactionHashProjection), BitcoinBoundedContext.Name)
- .ListeningEvents(typeof(Job.BlockchainCashinDetector.Contract.Events.CashinCompletedEvent))
+ .ListeningEvents(typeof(Lykke.Job.BlockchainCashinDetector.Contract.Events.CashinCompletedEvent))
.From(BlockchainCashinDetectorBoundedContext.Name)
.On(defaultRoute)
.WithEndpointResolver(sagasMessagePackEndpointResolver)
.WithProjection(typeof(TransactionHashProjection), BlockchainCashinDetectorBoundedContext.Name)
+ .ListeningEvents(typeof(Lykke.Job.SiriusDepositsDetector.Contract.Events.CashinCompletedEvent))
+ .From(SiriusDepositsDetectorBoundedContext.Name)
+ .On(defaultRoute)
+ .WithEndpointResolver(sagasMessagePackEndpointResolver)
+ .WithProjection(typeof(TransactionHashProjection), SiriusDepositsDetectorBoundedContext.Name)
+
+ .ListeningEvents(typeof(Lykke.Job.SiriusCashoutProcessor.Contract.Events.CashoutCompletedEvent))
+ .From(SiriusCashoutProcessorBoundedContext.Name)
+ .On(defaultRoute)
+ .WithEndpointResolver(sagasMessagePackEndpointResolver)
+ .WithProjection(typeof(TransactionHashProjection), SiriusCashoutProcessorBoundedContext.Name)
+
.ListeningEvents(
- typeof(Job.BlockchainCashoutProcessor.Contract.Events.CashoutCompletedEvent),
- typeof(Job.BlockchainCashoutProcessor.Contract.Events.CrossClientCashoutCompletedEvent),
- typeof(Job.BlockchainCashoutProcessor.Contract.Events.CashoutsBatchCompletedEvent))
+ typeof(Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutCompletedEvent),
+ typeof(Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CrossClientCashoutCompletedEvent),
+ typeof(Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutsBatchCompletedEvent))
.From(BlockchainCashoutProcessorBoundedContext.Name)
.On(defaultRoute)
.WithEndpointResolver(sagasMessagePackEndpointResolver)
diff --git a/src/Lykke.Service.History/Modules/DbModule.cs b/src/Antares.Job.History/Modules/DbModule.cs
similarity index 68%
rename from src/Lykke.Service.History/Modules/DbModule.cs
rename to src/Antares.Job.History/Modules/DbModule.cs
index 6261312..a5bd7d5 100644
--- a/src/Lykke.Service.History/Modules/DbModule.cs
+++ b/src/Antares.Job.History/Modules/DbModule.cs
@@ -1,12 +1,12 @@
-using Autofac;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.History.Core.Settings;
-using Lykke.Service.History.PostgresRepositories;
-using Lykke.Service.History.PostgresRepositories.Repositories;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.Core.Settings;
+using Antares.Service.History.PostgresRepositories;
+using Antares.Service.History.PostgresRepositories.Repositories;
+using Autofac;
using Lykke.SettingsReader;
-namespace Lykke.Service.History.Modules
+namespace Antares.Job.History.Modules
{
public class DbModule : Module
{
diff --git a/src/Lykke.Service.History/Program.cs b/src/Antares.Job.History/Program.cs
similarity index 85%
rename from src/Lykke.Service.History/Program.cs
rename to src/Antares.Job.History/Program.cs
index 38dd8f9..0af251e 100644
--- a/src/Lykke.Service.History/Program.cs
+++ b/src/Antares.Job.History/Program.cs
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
-using Lykke.Sdk;
+using Antares.Sdk;
-namespace Lykke.Service.History
+namespace Antares.Job.History
{
internal sealed class Program
{
diff --git a/src/Lykke.Service.History/Properties/launchSettings.json b/src/Antares.Job.History/Properties/launchSettings.json
similarity index 64%
rename from src/Lykke.Service.History/Properties/launchSettings.json
rename to src/Antares.Job.History/Properties/launchSettings.json
index d44eaac..60c8f43 100644
--- a/src/Lykke.Service.History/Properties/launchSettings.json
+++ b/src/Antares.Job.History/Properties/launchSettings.json
@@ -4,15 +4,14 @@
"commandName": "Project",
"environmentVariables": {
"ENV_INFO": "home",
- "SettingsUrl":
- "http://settingsv2.lykke-settings.svc.cluster.local/Home/RepositoryFile/c6462006-d3b2-44d9-9b47-0989b05700ea/Lykke.Service.History",
+ "SettingsUrl": "http://settingsv2.lykke-settings.svc.cluster.local/Home/RepositoryFile/de1f7d42-e533-4127-8fa3-b691d47ce13a/Antares.Service.History",
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"History local test settings": {
"commandName": "Project",
"environmentVariables": {
- "SettingsUrl": "token_to_test_settings",
+ "SettingsUrl": "http://settingsv2.lykke-settings.svc.cluster.local/Home/RepositoryFile/c96b7a34-b21f-49b9-8b29-9c3cd395b584/Antares.Service.History",
"ASPNETCORE_ENVIRONMENT": "Staging"
}
},
diff --git a/src/Antares.Job.History/RabbitSubscribers/MeRabbitSubscriber.cs b/src/Antares.Job.History/RabbitSubscribers/MeRabbitSubscriber.cs
new file mode 100644
index 0000000..e1eb3e3
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/MeRabbitSubscriber.cs
@@ -0,0 +1,195 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Settings;
+using Autofac;
+using Common;
+using Common.Log;
+using JetBrains.Annotations;
+using Lykke.Common.Log;
+using Lykke.Cqrs;
+using Lykke.MatchingEngine.Connector.Models.Events;
+using Lykke.RabbitMqBroker;
+using Lykke.RabbitMqBroker.Deduplication;
+using Lykke.RabbitMqBroker.Subscriber;
+using Utils = Antares.Service.History.Core.Utils;
+
+namespace Antares.Job.History.RabbitSubscribers
+{
+ [UsedImplicitly]
+ public class MeRabbitSubscriber : IStartable, IStopable
+ {
+ [NotNull] private readonly ILogFactory _logFactory;
+ private readonly RabbitMqSettings _rabbitMqSettings;
+ private readonly List _subscribers = new List();
+ private readonly IDeduplicator _deduplicator;
+ private readonly IHistoryRecordsRepository _historyRecordsRepository;
+ private readonly ILog _log;
+
+ private const string QueueName = "lykke.spot.matching.engine.out.events.antares-history";
+ private const bool QueueDurable = true;
+
+ public MeRabbitSubscriber(
+ [NotNull] ILogFactory logFactory,
+ [NotNull] RabbitMqSettings rabbitMqSettings,
+ [NotNull] IDeduplicator deduplicator,
+ IHistoryRecordsRepository historyRecordsRepository)
+ {
+ _logFactory = logFactory ?? throw new ArgumentNullException(nameof(logFactory));
+ _log = _logFactory.CreateLog(this);
+ _rabbitMqSettings = rabbitMqSettings ?? throw new ArgumentNullException(nameof(rabbitMqSettings));
+ _deduplicator = deduplicator ?? throw new ArgumentNullException(nameof(deduplicator));
+ _historyRecordsRepository = historyRecordsRepository;
+ }
+
+ public void Start()
+ {
+ _subscribers.Add(Subscribe(Lykke.MatchingEngine.Connector.Models.Events.Common.MessageType.CashIn, ProcessMessageAsync));
+ _subscribers.Add(Subscribe(Lykke.MatchingEngine.Connector.Models.Events.Common.MessageType.CashOut, ProcessMessageAsync));
+ _subscribers.Add(Subscribe(Lykke.MatchingEngine.Connector.Models.Events.Common.MessageType.CashTransfer, ProcessMessageAsync));
+ }
+
+ private RabbitMqSubscriber Subscribe(Lykke.MatchingEngine.Connector.Models.Events.Common.MessageType messageType, Func func)
+ {
+ var settings = new RabbitMqSubscriptionSettings
+ {
+ ConnectionString = _rabbitMqSettings.ConnectionString,
+ QueueName = $"{QueueName}.{messageType}",
+ ExchangeName = _rabbitMqSettings.Exchange,
+ RoutingKey = ((int)messageType).ToString(),
+ IsDurable = QueueDurable
+ };
+
+ return new RabbitMqSubscriber(
+ _logFactory,
+ settings,
+ new ResilientErrorHandlingStrategy(_logFactory, settings,
+ retryTimeout: TimeSpan.FromSeconds(10),
+ next: new DeadQueueErrorHandlingStrategy(_logFactory, settings)))
+ .SetMessageDeserializer(new ProtobufMessageDeserializer())
+ .SetMessageReadStrategy(new MessageReadQueueStrategy())
+ .Subscribe(func)
+ .CreateDefaultBinding()
+ .SetAlternativeExchange(_rabbitMqSettings.AlternativeConnectionString)
+ .SetDeduplicator(_deduplicator)
+ .Start();
+ }
+
+
+ private async Task ProcessMessageAsync(CashInEvent message)
+ {
+ var fees = message.CashIn.Fees;
+ var fee = fees?.FirstOrDefault()?.Transfer;
+
+ var entity = new Cashin()
+ {
+ AssetId = message.CashIn.AssetId,
+ //BlockchainHash = ,
+ FeeSize = ParseNullabe(fee?.Volume),
+ Id = Guid.Parse(message.Header.RequestId),
+ State = HistoryState.Finished,
+ Timestamp = message.Header.Timestamp,
+ Volume = Math.Abs(decimal.Parse(message.CashIn.Volume)),
+ WalletId = Guid.Parse(message.CashIn.WalletId)
+ };
+
+ if (!await _historyRecordsRepository.TryInsertAsync(entity))
+ _log.Warning($"Skipped duplicated cashin record", context: new
+ {
+ id = message.Header.RequestId
+ });
+ }
+
+ private async Task ProcessMessageAsync(CashOutEvent message)
+ {
+ var fees = message.CashOut.Fees;
+ var fee = fees?.FirstOrDefault()?.Transfer;
+
+ var entity = new Cashout()
+ {
+ //BlockchainHash = ,
+ FeeSize = ParseNullabe(fee?.Volume),
+ State = HistoryState.Finished,
+ Id = Guid.Parse(message.Header.RequestId),
+ WalletId = Guid.Parse(message.CashOut.WalletId),
+ AssetId = message.CashOut.AssetId,
+ Timestamp = message.Header.Timestamp,
+ Volume = -Math.Abs(decimal.Parse(message.CashOut.Volume))
+ };
+
+ if (!await _historyRecordsRepository.TryInsertAsync(entity))
+ _log.Warning($"Skipped duplicated cashout record", context: new
+ {
+ id = message.Header.RequestId
+ });
+ }
+
+ private async Task ProcessMessageAsync(CashTransferEvent message)
+ {
+ var fees = message.CashTransfer.Fees;
+ var fee = fees?.FirstOrDefault()?.Transfer;
+ var operationId = Guid.Parse(message.Header.RequestId);
+ var fromWallet = Guid.Parse(message.CashTransfer.FromWalletId);
+ var toWallet = Guid.Parse(message.CashTransfer.ToWalletId);
+ var volume = decimal.Parse(message.CashTransfer.Volume);
+ var timestamp = message.Header.Timestamp;
+ var assetId = message.CashTransfer.AssetId;
+ var feeSourceWalletId = fee != null ? Guid.Parse(fee.SourceWalletId) : (Guid?)null;
+ var feeSize = ParseNullabe(fee?.Volume);
+
+ var cashInOuts = new BaseHistoryRecord[] {
+ new Cashout()
+ {
+ Id = operationId,
+ WalletId = fromWallet,
+ Volume = -Math.Abs(volume),
+ Timestamp = timestamp,
+ AssetId = assetId,
+ FeeSize = fromWallet == feeSourceWalletId ? feeSize : null,
+ State = Antares.Service.History.Core.Domain.Enums.HistoryState.Finished
+ },
+ new Cashin()
+ {
+ Id = operationId,
+ WalletId = toWallet,
+ Volume = Math.Abs(volume),
+ Timestamp = timestamp,
+ AssetId = assetId,
+ FeeSize = toWallet == feeSourceWalletId ? feeSize : null,
+ State = Antares.Service.History.Core.Domain.Enums.HistoryState.Finished
+ }};
+
+ foreach (var cashInOut in cashInOuts)
+ if (!await _historyRecordsRepository.TryInsertAsync(cashInOut))
+ _log.Warning($"Skipped duplicated transfer record", context: new
+ {
+ id = operationId
+ });
+ }
+
+ private decimal? ParseNullabe(string value)
+ {
+ return !string.IsNullOrEmpty(value) ? decimal.Parse(value) : (decimal?)null;
+ }
+
+ public void Dispose()
+ {
+ foreach (var subscriber in _subscribers)
+ {
+ subscriber?.Dispose();
+ }
+
+ }
+
+ public void Stop()
+ {
+ foreach (var subscriber in _subscribers)
+ {
+ subscriber?.Stop();
+ }
+ }
+ }
+}
diff --git a/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderSide.cs b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderSide.cs
new file mode 100644
index 0000000..f40e279
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderSide.cs
@@ -0,0 +1,9 @@
+namespace Antares.Job.History.RabbitSubscribers.Models.Enums
+{
+ public enum OrderSide
+ {
+ Unknown,
+ Buy,
+ Sell
+ }
+}
diff --git a/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderStatus.cs b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderStatus.cs
new file mode 100644
index 0000000..a837e2a
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderStatus.cs
@@ -0,0 +1,14 @@
+namespace Antares.Job.History.RabbitSubscribers.Models.Enums
+{
+ public enum OrderStatus
+ {
+ Unknown,
+ Placed,
+ PartiallyMatched,
+ Matched,
+ Pending,
+ Cancelled,
+ Replaced,
+ Rejected
+ }
+}
diff --git a/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderType.cs b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderType.cs
new file mode 100644
index 0000000..35e4be3
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/OrderType.cs
@@ -0,0 +1,10 @@
+namespace Antares.Job.History.RabbitSubscribers.Models.Enums
+{
+ public enum OrderType
+ {
+ Unknown,
+ Market,
+ Limit,
+ StopLimit
+ }
+}
diff --git a/src/Antares.Job.History/RabbitSubscribers/Models/Enums/TradeRole.cs b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/TradeRole.cs
new file mode 100644
index 0000000..564d1fa
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/Models/Enums/TradeRole.cs
@@ -0,0 +1,9 @@
+namespace Antares.Job.History.RabbitSubscribers.Models.Enums
+{
+ public enum TradeRole
+ {
+ Unknown,
+ Maker,
+ Taker
+ }
+}
diff --git a/src/Antares.Job.History/RabbitSubscribers/Models/OrderModel.cs b/src/Antares.Job.History/RabbitSubscribers/Models/OrderModel.cs
new file mode 100644
index 0000000..4156ebb
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/Models/OrderModel.cs
@@ -0,0 +1,77 @@
+using System;
+using System.Collections.Generic;
+using Antares.Job.History.RabbitSubscribers.Models.Enums;
+using ProtoBuf;
+
+namespace Antares.Job.History.RabbitSubscribers.Models
+{
+ ///
+ /// Executed order
+ ///
+ [ProtoContract]
+ public class OrderModel
+ {
+ [ProtoMember(1, IsRequired = true)]
+ public Guid Id { get; set; }
+
+ [ProtoMember(2, IsRequired = true)]
+ public Guid MatchingId { get; set; }
+
+ [ProtoMember(3, IsRequired = true)]
+ public Guid WalletId { get; set; }
+
+ [ProtoMember(4, IsRequired = true)]
+ public OrderType Type { get; set; }
+
+ [ProtoMember(5, IsRequired = true)]
+ public OrderSide Side { get; set; }
+
+ [ProtoMember(6, IsRequired = true)]
+ public OrderStatus Status { get; set; }
+
+ [ProtoMember(7, IsRequired = true)]
+ public string AssetPairId { get; set; }
+
+ [ProtoMember(8, IsRequired = true)]
+ public decimal Volume { get; set; }
+
+ [ProtoMember(9, IsRequired = false)]
+ public decimal? Price { get; set; }
+
+ [ProtoMember(10, IsRequired = true)]
+ public DateTime CreateDt { get; set; }
+
+ [ProtoMember(11, IsRequired = true)]
+ public DateTime RegisterDt { get; set; }
+
+ [ProtoMember(12, IsRequired = true)]
+ public DateTime StatusDt { get; set; }
+
+ [ProtoMember(13, IsRequired = false)]
+ public DateTime? MatchDt { get; set; }
+
+ [ProtoMember(14, IsRequired = false)]
+ public decimal? RemainingVolume { get; set; }
+
+ [ProtoMember(15, IsRequired = true)]
+ public string RejectReason { get; set; }
+
+ [ProtoMember(16, IsRequired = false)]
+ public decimal? LowerLimitPrice { get; set; }
+
+ [ProtoMember(17, IsRequired = false)]
+ public decimal? LowerPrice { get; set; }
+
+ [ProtoMember(18, IsRequired = false)]
+ public decimal? UpperLimitPrice { get; set; }
+
+ [ProtoMember(19, IsRequired = false)]
+ public decimal? UpperPrice { get; set; }
+
+ [ProtoMember(20, IsRequired = true)]
+ public bool Straight { get; set; } = true;
+
+ [ProtoMember(21, IsRequired = false)]
+ public IReadOnlyCollection Trades { get; set; } = new List();
+ }
+}
diff --git a/src/Antares.Job.History/RabbitSubscribers/Models/TradeModel.cs b/src/Antares.Job.History/RabbitSubscribers/Models/TradeModel.cs
new file mode 100644
index 0000000..f4c0eec
--- /dev/null
+++ b/src/Antares.Job.History/RabbitSubscribers/Models/TradeModel.cs
@@ -0,0 +1,55 @@
+using System;
+using Antares.Job.History.RabbitSubscribers.Models.Enums;
+using ProtoBuf;
+
+namespace Antares.Job.History.RabbitSubscribers.Models
+{
+ ///
+ /// User trade item
+ ///
+ [ProtoContract]
+ public class TradeModel
+ {
+ [ProtoMember(1, IsRequired = true)]
+ public Guid Id { get; set; }
+
+ [ProtoMember(2, IsRequired = true)]
+ public Guid WalletId { get; set; }
+
+ [ProtoMember(3, IsRequired = true)]
+ public string AssetPairId { get; set; }
+
+ [ProtoMember(4, IsRequired = true)]
+ public string BaseAssetId { get; set; }
+
+ [ProtoMember(5, IsRequired = true)]
+ public decimal BaseVolume { get; set; }
+
+ [ProtoMember(6, IsRequired = true)]
+ public decimal Price { get; set; }
+
+ [ProtoMember(7, IsRequired = true)]
+ public DateTime Timestamp { get; set; }
+
+ [ProtoMember(8, IsRequired = true)]
+ public string QuotingAssetId { get; set; }
+
+ [ProtoMember(9, IsRequired = true)]
+ public decimal QuotingVolume { get; set; }
+
+ [ProtoMember(10, IsRequired = true)]
+ public int Index { get; set; }
+
+ [ProtoMember(11, IsRequired = true)]
+ public TradeRole Role { get; set; }
+
+ [ProtoMember(12, IsRequired = false)]
+ public decimal? FeeSize { get; set; }
+
+ [ProtoMember(13, IsRequired = false)]
+ public string FeeAssetId { get; set; }
+
+ [ProtoMember(14, IsRequired = true)]
+ public Guid OppositeWalletId { get; set; }
+ }
+}
diff --git a/src/Lykke.Job.History/ShutdownManager.cs b/src/Antares.Job.History/ShutdownManager.cs
similarity index 51%
rename from src/Lykke.Job.History/ShutdownManager.cs
rename to src/Antares.Job.History/ShutdownManager.cs
index 8c9e4db..06d5ae9 100644
--- a/src/Lykke.Job.History/ShutdownManager.cs
+++ b/src/Antares.Job.History/ShutdownManager.cs
@@ -1,27 +1,22 @@
using System.Threading.Tasks;
-using Lykke.Job.History.Workflow.ExecutionProcessing;
-using Lykke.Sdk;
+using Antares.Job.History.Workflow.ExecutionProcessing;
+using Antares.Sdk.Services;
-namespace Lykke.Job.History
+namespace Antares.Job.History
{
public class ShutdownManager : IShutdownManager
{
private readonly ExecutionQueueReader _executionQueueReader;
- private readonly OrderEventQueueReader _orderEventQueueReader;
public ShutdownManager(
- ExecutionQueueReader executionQueueReader,
- OrderEventQueueReader orderEventQueueReader
- )
+ ExecutionQueueReader executionQueueReader)
{
_executionQueueReader = executionQueueReader;
- _orderEventQueueReader = orderEventQueueReader;
}
public Task StopAsync()
{
_executionQueueReader.Stop();
- _orderEventQueueReader.Stop();
return Task.CompletedTask;
}
diff --git a/src/Lykke.Job.History/Startup.cs b/src/Antares.Job.History/Startup.cs
similarity index 73%
rename from src/Lykke.Job.History/Startup.cs
rename to src/Antares.Job.History/Startup.cs
index eb70689..2b9ece5 100644
--- a/src/Lykke.Job.History/Startup.cs
+++ b/src/Antares.Job.History/Startup.cs
@@ -1,14 +1,17 @@
using System;
+using Antares.Job.History.AutoMapper;
+using Antares.Sdk;
+using Antares.Service.History.Core.Settings;
+using Antares.Service.History.PostgresRepositories.Mappings;
+using Autofac;
using AutoMapper;
using JetBrains.Annotations;
-using Lykke.Job.History.AutoMapper;
-using Lykke.Sdk;
-using Lykke.Service.History.Core.Settings;
-using Lykke.Service.History.PostgresRepositories.Mappings;
+using Lykke.SettingsReader;
using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-namespace Lykke.Job.History
+namespace Antares.Job.History
{
[UsedImplicitly]
public class Startup
@@ -19,8 +22,11 @@ public class Startup
ApiVersion = "v1"
};
+ private IReloadingManagerWithConfiguration _settings;
+ private LykkeServiceOptions _lykkeOptions;
+
[UsedImplicitly]
- public IServiceProvider ConfigureServices(IServiceCollection services)
+ public void ConfigureServices(IServiceCollection services)
{
Mapper.Initialize(cfg =>
{
@@ -28,7 +34,8 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
cfg.AddProfiles(typeof(RepositoryProfile));
});
- return services.BuildServiceProvider(options =>
+ //DependencyResolver
+ (_lykkeOptions, _settings) = services.ConfigureServices(options =>
{
options.SwaggerOptions = _swaggerOptions;
@@ -69,6 +76,18 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
};
*/
});
+
+ Console.WriteLine($"CQRS enabled: {_settings.CurrentValue.HistoryService.CqrsEnabled}");
+ }
+
+ [UsedImplicitly]
+ public void ConfigureContainer(ContainerBuilder builder)
+ {
+ var configurationRoot = new ConfigurationBuilder()
+ .AddEnvironmentVariables()
+ .Build();
+
+ builder.ConfigureContainerBuilder(_lykkeOptions, configurationRoot, _settings);
}
[UsedImplicitly]
diff --git a/src/Antares.Job.History/StartupManager.cs b/src/Antares.Job.History/StartupManager.cs
new file mode 100644
index 0000000..4754ff5
--- /dev/null
+++ b/src/Antares.Job.History/StartupManager.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Threading.Tasks;
+using Antares.Job.History.Workflow.ExecutionProcessing;
+using Antares.Sdk.Services;
+using Antares.Service.History.Core.Settings;
+using Common.Log;
+using Lykke.Common.Log;
+using Lykke.Cqrs;
+
+namespace Antares.Job.History
+{
+ public class StartupManager : IStartupManager
+ {
+ private readonly HistorySettings _historySettings;
+ private readonly ICqrsEngine _cqrsEngine;
+ private readonly ExecutionQueueReader _executionQueueReader;
+ private readonly ILog _log;
+
+ public StartupManager(
+ HistorySettings historySettings,
+ ICqrsEngine cqrsEngine,
+ ExecutionQueueReader executionQueueReader,
+ ILogFactory logFactory)
+ {
+ _historySettings = historySettings;
+ _cqrsEngine = cqrsEngine;
+ _executionQueueReader = executionQueueReader;
+ _log = logFactory.CreateLog(nameof(StartupManager));
+ }
+
+ public Task StartAsync()
+ {
+ _executionQueueReader.Start();
+
+ if (_historySettings.CqrsEnabled)
+ {
+ _cqrsEngine.StartSubscribers();
+ }
+ else
+ {
+ _log.Info("CQRS Engine is disabled");
+ }
+
+
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/src/Lykke.Job.History/Workflow/ExecutionProcessing/BaseBatchQueueReader.cs b/src/Antares.Job.History/Workflow/ExecutionProcessing/BaseBatchQueueReader.cs
similarity index 88%
rename from src/Lykke.Job.History/Workflow/ExecutionProcessing/BaseBatchQueueReader.cs
rename to src/Antares.Job.History/Workflow/ExecutionProcessing/BaseBatchQueueReader.cs
index cdd7a8f..85ab8df 100644
--- a/src/Lykke.Job.History/Workflow/ExecutionProcessing/BaseBatchQueueReader.cs
+++ b/src/Antares.Job.History/Workflow/ExecutionProcessing/BaseBatchQueueReader.cs
@@ -8,7 +8,7 @@
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
-namespace Lykke.Job.History.Workflow.ExecutionProcessing
+namespace Antares.Job.History.Workflow.ExecutionProcessing
{
public abstract class BaseBatchQueueReader
{
@@ -104,7 +104,18 @@ private async Task StartQueueReader()
{
channel.BasicQos(0, (ushort)_prefetchCount, false);
- channel.QueueDeclare(QueueName, true, false, false);
+ // see https://www.rabbitmq.com/dlx.html
+ var dlxName = $"{QueueName}-dlx";
+ var poisonQueueName = $"{QueueName}-poison";
+ var args = new Dictionary
+ {
+ { "x-dead-letter-exchange", dlxName }
+ };
+ channel.ExchangeDeclare(dlxName, type: "direct", durable: true);
+ channel.QueueDeclare(poisonQueueName, durable: true, exclusive: false, autoDelete: false);
+ channel.QueueBind(poisonQueueName, exchange: $"{QueueName}-dlx", routingKey: string.Empty);
+
+ channel.QueueDeclare(QueueName, durable: true, exclusive: false, autoDelete: false);
foreach (var key in RoutingKeys)
channel.QueueBind(QueueName, ExchangeName, key);
diff --git a/src/Lykke.Job.History/Workflow/ExecutionProcessing/CustomQueueItem.cs b/src/Antares.Job.History/Workflow/ExecutionProcessing/CustomQueueItem.cs
similarity index 91%
rename from src/Lykke.Job.History/Workflow/ExecutionProcessing/CustomQueueItem.cs
rename to src/Antares.Job.History/Workflow/ExecutionProcessing/CustomQueueItem.cs
index 77588e4..398ff91 100644
--- a/src/Lykke.Job.History/Workflow/ExecutionProcessing/CustomQueueItem.cs
+++ b/src/Antares.Job.History/Workflow/ExecutionProcessing/CustomQueueItem.cs
@@ -1,6 +1,6 @@
using RabbitMQ.Client;
-namespace Lykke.Job.History.Workflow.ExecutionProcessing
+namespace Antares.Job.History.Workflow.ExecutionProcessing
{
public class CustomQueueItem
{
diff --git a/src/Antares.Job.History/Workflow/ExecutionProcessing/ExecutionEventHandler.cs b/src/Antares.Job.History/Workflow/ExecutionProcessing/ExecutionEventHandler.cs
new file mode 100644
index 0000000..8ff752d
--- /dev/null
+++ b/src/Antares.Job.History/Workflow/ExecutionProcessing/ExecutionEventHandler.cs
@@ -0,0 +1,223 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Common;
+using Common.Log;
+using JetBrains.Annotations;
+using Lykke.Common.Log;
+using Lykke.MatchingEngine.Connector.Models.Events;
+using MoreLinq;
+using Utils = Antares.Service.History.Core.Utils;
+
+namespace Antares.Job.History.Workflow.ExecutionProcessing
+{
+ public class ExecutionEventHandler
+ {
+ private const int TradesBulkSize = 5000;
+
+ private readonly IHistoryRecordsRepository _historyRecordsRepository;
+ private readonly IOrdersRepository _ordersRepository;
+ private readonly IReadOnlyList _walletIds;
+ private readonly ILog _log;
+
+ public ExecutionEventHandler(
+ [NotNull] ILogFactory logFactory,
+ IHistoryRecordsRepository historyRecordsRepository,
+ IOrdersRepository ordersRepository,
+ IReadOnlyList walletIds)
+ {
+ _log = logFactory.CreateLog(nameof(ExecutionEventHandler));
+ _historyRecordsRepository = historyRecordsRepository;
+ _ordersRepository = ordersRepository;
+ _walletIds = walletIds;
+ }
+
+ public async Task HandleAsync(IReadOnlyCollection executionEvents)
+ {
+ var pairs = executionEvents.Select(Map).ToArray();
+ var orders = pairs.SelectMany(x => x.Orders).ToList();
+ var orderEvents = pairs.SelectMany(x => x.OrderEvent).ToList();
+ var batchId = Guid.NewGuid().ToString();
+
+ bool needLog = orders.Any(x => _walletIds.Contains(x.WalletId.ToString()));
+
+ foreach (var order in orders.Where(x => _walletIds.Contains(x.WalletId.ToString())))
+ {
+ _log.Info("Saving order (ProcessBatch)", context: $"order: {new { order.Id, order.Status, order.SequenceNumber, batchId }.ToJson()}");
+ }
+
+ await _ordersRepository.UpsertBulkAsync(orders);
+
+ if (needLog)
+ {
+ _log.Info("Orders have been saved (ProcessBatch)", context: $"batchId: {batchId}");
+ }
+
+ var trades = orders.SelectMany(x => x.Trades)?.ToArray();
+
+ if (trades.Any())
+ {
+ var batched = trades.Batch(TradesBulkSize).ToArray();
+
+ foreach (var tradesBatch in batched)
+ await _historyRecordsRepository.InsertBulkAsync(tradesBatch);
+ }
+
+ foreach (var batch in orderEvents.Batch(TradesBulkSize))
+ await _historyRecordsRepository.InsertBulkAsync(batch);
+ }
+
+ private (IReadOnlyCollection Orders, IReadOnlyCollection OrderEvent)
+ Map(ExecutionEvent executionEvent)
+ {
+ var orders = new List(executionEvent.Orders.Count);
+
+ foreach (var x in executionEvent.Orders)
+ {
+ Antares.Service.History.Core.Domain.Orders.Order order;
+
+ try
+ {
+ order = new Antares.Service.History.Core.Domain.Orders.Order
+ {
+ Id = Guid.Parse(x.ExternalId),
+ WalletId = Guid.Parse(x.WalletId),
+ Volume = decimal.Parse(x.Volume),
+ AssetPairId = x.AssetPairId,
+ CreateDt = x.CreatedAt,
+ LowerLimitPrice = ParseNullabe(x.LowerLimitPrice),
+ LowerPrice = ParseNullabe(x.LowerPrice),
+ MatchDt = x.LastMatchTime,
+ MatchingId = Guid.Parse(x.Id),
+ Price = ParseNullabe(x.Price),
+ RegisterDt = x.Registered,
+ RejectReason = x.RejectReason,
+ RemainingVolume = ParseNullabe(x.RemainingVolume) ?? 0m,
+ Side = (Antares.Service.History.Core.Domain.Enums.OrderSide) (int) x.Side,
+ Status = (Antares.Service.History.Core.Domain.Enums.OrderStatus) (int) x.Status,
+ StatusDt = x.StatusDate,
+ Straight = x.OrderType == Lykke.MatchingEngine.Connector.Models.Events.OrderType.Limit ||
+ x.OrderType == Lykke.MatchingEngine.Connector.Models.Events.OrderType.StopLimit ||
+ x.Straight,
+ SequenceNumber = executionEvent.Header.SequenceNumber,
+ Type = (Antares.Service.History.Core.Domain.Enums.OrderType) (int) x.OrderType,
+ UpperLimitPrice = ParseNullabe(x.UpperLimitPrice),
+ UpperPrice = ParseNullabe(x.UpperPrice),
+ };
+
+ order.Trades = x.Trades == null
+ ? Array.Empty()
+ : x.Trades.Select(t => new Antares.Service.History.Core.Domain.History.Trade()
+ {
+ Id = Guid.Parse(t.TradeId),
+ WalletId = Guid.Parse(x.WalletId),
+ AssetPairId = x.AssetPairId,
+ BaseAssetId = t.BaseAssetId,
+ BaseVolume = decimal.Parse(t.BaseVolume),
+ Price = decimal.Parse(t.Price),
+ Timestamp = t.Timestamp,
+ QuotingAssetId = t.QuotingAssetId,
+ QuotingVolume = decimal.Parse(t.QuotingVolume),
+ Index = t.Index,
+ Role = (Antares.Service.History.Core.Domain.Enums.TradeRole) (int) t.Role,
+ FeeSize = ParseNullabe(t.Fees?.FirstOrDefault()?.Volume),
+ FeeAssetId = t.Fees?.FirstOrDefault()?.AssetId,
+ OrderId = order.Id
+ //OppositeWalletId = Guid.Parse(t.OppositeWalletId),
+ }).ToArray();
+
+ orders.Add(order);
+ }
+ catch (Exception ex)
+ {
+ _log.Error(ex, "Can't convert execution event to order", context: $"execution event: {x.ToJson()}");
+ }
+ }
+
+ foreach (var order in orders.Where(x => _walletIds.Contains(x.WalletId.ToString())))
+ {
+ _log.Info("Order from ME", $"order: {new { order.Id, order.Status, executionEvent.Header.SequenceNumber }.ToJson()}");
+ }
+
+ var limitOrders = orders.Where(x => x.Type == Antares.Service.History.Core.Domain.Enums.OrderType.Limit ||
+ x.Type == Antares.Service.History.Core.Domain.Enums.OrderType.StopLimit).ToList();
+ var historyOrders = new List(limitOrders.Count);
+
+ foreach (var order in limitOrders)
+ {
+ switch (order.Status)
+ {
+ case Service.History.Core.Domain.Enums.OrderStatus.Cancelled:
+ {
+ var orderEvent = new OrderEvent
+ {
+ OrderId = order.Id,
+ Status = order.Status,
+ AssetPairId = order.AssetPairId,
+ Price = order.Price ?? 0,
+ Timestamp = order.StatusDt,
+ Volume = order.Volume,
+ WalletId = order.WalletId,
+ Id = Utils.IncrementGuid(order.Id, (int)Service.History.Core.Domain.Enums.OrderStatus.Cancelled)
+ };
+
+ historyOrders.Add(orderEvent);
+
+ break;
+ }
+ case Service.History.Core.Domain.Enums.OrderStatus.Placed:
+ {
+ var orderEvent = new OrderEvent
+ {
+ OrderId = order.Id,
+ Status = order.Status,
+ AssetPairId = order.AssetPairId,
+ Price = order.Price ?? 0,
+ Timestamp = order.CreateDt,
+ Volume = order.Volume,
+ WalletId = order.WalletId,
+ Id = Utils.IncrementGuid(order.Id, (int)Service.History.Core.Domain.Enums.OrderStatus.Placed)
+ };
+
+ historyOrders.Add(orderEvent);
+
+ break;
+ }
+ case Service.History.Core.Domain.Enums.OrderStatus.Matched:
+ case Service.History.Core.Domain.Enums.OrderStatus.PartiallyMatched:
+ {
+ if (!order.Trades.Any(t => t.Role == Service.History.Core.Domain.Enums.TradeRole.Taker))
+ break;
+ var orderEvent = new OrderEvent()
+ {
+ OrderId = order.Id,
+ Status = Service.History.Core.Domain.Enums.OrderStatus.Placed,
+ AssetPairId = order.AssetPairId,
+ Price = order.Price ?? 0,
+ Timestamp = order.CreateDt,
+ Volume = order.Volume,
+ WalletId = order.WalletId,
+ Id = Utils.IncrementGuid(order.Id, (int)Service.History.Core.Domain.Enums.OrderStatus.Placed)
+ };
+
+ historyOrders.Add(orderEvent);
+
+ break;
+ }
+ default:
+ continue;
+ }
+ }
+
+ return (orders, historyOrders);
+ }
+
+ private decimal? ParseNullabe(string value)
+ {
+ return !string.IsNullOrEmpty(value) ? decimal.Parse(value) : (decimal?)null;
+ }
+ }
+}
diff --git a/src/Antares.Job.History/Workflow/ExecutionProcessing/ExecutionQueueReader.cs b/src/Antares.Job.History/Workflow/ExecutionProcessing/ExecutionQueueReader.cs
new file mode 100644
index 0000000..ba9da0a
--- /dev/null
+++ b/src/Antares.Job.History/Workflow/ExecutionProcessing/ExecutionQueueReader.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.Core.Settings;
+using Common;
+using Common.Log;
+using Lykke.Common.Log;
+using Lykke.MatchingEngine.Connector.Models.Events;
+using Lykke.RabbitMqBroker.Subscriber;
+using RabbitMQ.Client;
+using RabbitMQ.Client.Events;
+
+namespace Antares.Job.History.Workflow.ExecutionProcessing
+{
+ public class ExecutionQueueReader : BaseBatchQueueReader
+ {
+ private readonly IReadOnlyList _walletIds;
+ private readonly RabbitMqSettings _rabbitMqSettings;
+ private readonly ExecutionEventHandler _executionEventHandler;
+ private readonly ILog _log;
+
+ public ExecutionQueueReader(
+ ILogFactory logFactory,
+ int prefetchCount,
+ int batchCount,
+ IReadOnlyList walletIds,
+ RabbitMqSettings rabbitMqSettings,
+ ExecutionEventHandler executionEventHandler)
+ : base(logFactory, rabbitMqSettings.ConnectionString, prefetchCount, batchCount, walletIds)
+ {
+ _walletIds = walletIds;
+ _rabbitMqSettings = rabbitMqSettings;
+ _executionEventHandler = executionEventHandler;
+ _log = logFactory.CreateLog(this);
+ }
+
+ protected override string ExchangeName => _rabbitMqSettings.Exchange;
+
+ protected override string QueueName =>
+ $"lykke.spot.matching.engine.out.events.antares-history.{Lykke.MatchingEngine.Connector.Models.Events.Common.MessageType.Order}";
+
+ protected override string[] RoutingKeys => new[] { ((int)Lykke.MatchingEngine.Connector.Models.Events.Common.MessageType.Order).ToString() };
+
+ protected override EventHandler CreateOnMessageReceivedEventHandler(IModel channel)
+ {
+ var deserializer = new ProtobufMessageDeserializer();
+
+ void OnMessageReceived(object o, BasicDeliverEventArgs basicDeliverEventArgs)
+ {
+ try
+ {
+ var message = deserializer.Deserialize(basicDeliverEventArgs.Body);
+
+ if (message.Orders.Any(x => _walletIds.Contains(x.WalletId.ToString())))
+ {
+ _log.Info("Adding orders in queue for processing", context: $"sequence number: {message.Header.SequenceNumber}");
+ }
+
+ Queue.Enqueue(new CustomQueueItem(message,
+ basicDeliverEventArgs.DeliveryTag, channel));
+ }
+ catch (Exception e)
+ {
+ Log.Error(e);
+
+ channel.BasicReject(basicDeliverEventArgs.DeliveryTag, false);
+ }
+ }
+
+ return OnMessageReceived;
+ }
+
+ protected override async Task ProcessBatch(IList> batch)
+ {
+ await _executionEventHandler.HandleAsync(batch.Select(x => x.Value).ToArray());
+ }
+
+ protected override void LogQueue()
+ {
+ while (Queue.Count > 0)
+ {
+ if (Queue.TryDequeue(out var item))
+ {
+ var orders = item.Value.Orders.Select(x => new {x.Id, x.Status, item.Value.Header.SequenceNumber}).ToList()
+ .ToJson();
+
+ Log.Info("Orders in queue on shutdown", context: $"orders: {orders}");
+ }
+ }
+ }
+ }
+}
diff --git a/src/Lykke.Job.History/Workflow/Handlers/EthereumCommandHandler.cs b/src/Antares.Job.History/Workflow/Handlers/EthereumCommandHandler.cs
similarity index 96%
rename from src/Lykke.Job.History/Workflow/Handlers/EthereumCommandHandler.cs
rename to src/Antares.Job.History/Workflow/Handlers/EthereumCommandHandler.cs
index 0fe33fa..ec2d9ac 100644
--- a/src/Lykke.Job.History/Workflow/Handlers/EthereumCommandHandler.cs
+++ b/src/Antares.Job.History/Workflow/Handlers/EthereumCommandHandler.cs
@@ -1,14 +1,14 @@
using System;
using System.Threading.Tasks;
+using Antares.Service.History.Core;
+using Antares.Service.History.Core.Domain.History;
using Common.Log;
using Lykke.Common.Log;
using Lykke.Cqrs;
using Lykke.Job.EthereumCore.Contracts.Enums;
-using Lykke.Service.History.Core;
-using Lykke.Service.History.Core.Domain.History;
using MessagePack;
-namespace Lykke.Job.History.Workflow.Handlers
+namespace Antares.Job.History.Workflow.Handlers
{
public class EthereumCommandHandler
{
diff --git a/src/Lykke.Job.History/Workflow/Handlers/ForwardWithdrawalCommandHandler.cs b/src/Antares.Job.History/Workflow/Handlers/ForwardWithdrawalCommandHandler.cs
similarity index 91%
rename from src/Lykke.Job.History/Workflow/Handlers/ForwardWithdrawalCommandHandler.cs
rename to src/Antares.Job.History/Workflow/Handlers/ForwardWithdrawalCommandHandler.cs
index 715f413..b899689 100644
--- a/src/Lykke.Job.History/Workflow/Handlers/ForwardWithdrawalCommandHandler.cs
+++ b/src/Antares.Job.History/Workflow/Handlers/ForwardWithdrawalCommandHandler.cs
@@ -1,13 +1,13 @@
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Cqrs.Commands;
+using Antares.Service.History.Contracts.Cqrs.Events;
+using Antares.Service.History.Core.Domain.History;
using AutoMapper;
using Common.Log;
using Lykke.Common.Log;
using Lykke.Cqrs;
-using Lykke.Service.History.Contracts.Cqrs.Commands;
-using Lykke.Service.History.Contracts.Cqrs.Events;
-using Lykke.Service.History.Core.Domain.History;
-namespace Lykke.Job.History.Workflow.Handlers
+namespace Antares.Job.History.Workflow.Handlers
{
public class ForwardWithdrawalCommandHandler
{
diff --git a/src/Lykke.Job.History/Workflow/Projections/TransactionHashProjection.cs b/src/Antares.Job.History/Workflow/Projections/TransactionHashProjection.cs
similarity index 68%
rename from src/Lykke.Job.History/Workflow/Projections/TransactionHashProjection.cs
rename to src/Antares.Job.History/Workflow/Projections/TransactionHashProjection.cs
index 24656f2..d487a2b 100644
--- a/src/Lykke.Job.History/Workflow/Projections/TransactionHashProjection.cs
+++ b/src/Antares.Job.History/Workflow/Projections/TransactionHashProjection.cs
@@ -1,12 +1,12 @@
using System;
using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.History;
using Common.Log;
using Lykke.Bitcoin.Contracts.Events;
using Lykke.Common.Log;
using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-namespace Lykke.Job.History.Workflow.Projections
+namespace Antares.Job.History.Workflow.Projections
{
public class TransactionHashProjection
{
@@ -29,7 +29,7 @@ public async Task Handle(CashinCompletedEvent @event)
{
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, @event.TxHash))
{
- _logger.Warning($"Transaction hash was not set", context: new
+ _logger.Warning($"Bitcoin cashin hash was not set", context: new
{
id = @event.OperationId,
hash = @event.TxHash
@@ -50,7 +50,7 @@ public async Task Handle(CashoutCompletedEvent @event)
{
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, @event.TxHash))
{
- _logger.Warning($"Transaction hash was not set", context: new
+ _logger.Warning($"Bitcoin cashout hash was not set", context: new
{
id = @event.OperationId,
hash = @event.TxHash
@@ -68,11 +68,33 @@ public async Task Handle(CashoutCompletedEvent @event)
///
///
public async Task Handle(
- Job.BlockchainCashinDetector.Contract.Events.CashinCompletedEvent @event)
+ Lykke.Job.BlockchainCashinDetector.Contract.Events.CashinCompletedEvent @event)
{
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, @event.TransactionHash))
{
- _logger.Warning($"Transaction hash was not set", context: new
+ _logger.Warning($"BIL cashin hash was not set", context: new
+ {
+ id = @event.OperationId,
+ hash = @event.TransactionHash
+ });
+
+ return CommandHandlingResult.Fail(TimeSpan.FromMinutes(1));
+ }
+
+ return CommandHandlingResult.Ok();
+ }
+
+ ///
+ /// Sirius cashin event
+ ///
+ ///
+ ///
+ public async Task Handle(
+ Lykke.Job.SiriusDepositsDetector.Contract.Events.CashinCompletedEvent @event)
+ {
+ if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, @event.TransactionHash))
+ {
+ _logger.Warning($"Sirius cashin hash was not set", context: new
{
id = @event.OperationId,
hash = @event.TransactionHash
@@ -90,11 +112,33 @@ public async Task Handle(
///
///
public async Task Handle(
- Job.BlockchainCashoutProcessor.Contract.Events.CashoutCompletedEvent @event)
+ Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutCompletedEvent @event)
+ {
+ if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, @event.TransactionHash))
+ {
+ _logger.Warning($"BIL cashout hash was not set", context: new
+ {
+ id = @event.OperationId,
+ hash = @event.TransactionHash
+ });
+
+ return CommandHandlingResult.Fail(TimeSpan.FromMinutes(1));
+ }
+
+ return CommandHandlingResult.Ok();
+ }
+
+ ///
+ /// Sirius cashout event
+ ///
+ ///
+ ///
+ public async Task Handle(
+ Lykke.Job.SiriusCashoutProcessor.Contract.Events.CashoutCompletedEvent @event)
{
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId, @event.TransactionHash))
{
- _logger.Warning($"Transaction hash was not set", context: new
+ _logger.Warning($"Sirius cashout hash was not set", context: new
{
id = @event.OperationId,
hash = @event.TransactionHash
@@ -112,7 +156,7 @@ public async Task Handle(
///
///
public async Task Handle(
- Job.BlockchainCashoutProcessor.Contract.Events.CashoutsBatchCompletedEvent @event)
+ Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CashoutsBatchCompletedEvent @event)
{
if (@event.Cashouts == null || @event.Cashouts.Length == 0)
{
@@ -126,7 +170,7 @@ public async Task Handle(
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(cashout.OperationId,
@event.TransactionHash))
{
- _logger.Warning($"Transaction hash was not set, BIL cashout", context: new
+ _logger.Warning($"BIL batch transaction hash was not set", context: new
{
id = cashout.OperationId,
hash = @event.TransactionHash
@@ -145,12 +189,12 @@ public async Task Handle(
///
///
public async Task Handle(
- Job.BlockchainCashoutProcessor.Contract.Events.CrossClientCashoutCompletedEvent @event)
+ Lykke.Job.BlockchainCashoutProcessor.Contract.Events.CrossClientCashoutCompletedEvent @event)
{
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.OperationId,
_crossClientTransactionHashSubstituition))
{
- _logger.Warning($"Transaction hash was not set. " +
+ _logger.Warning($"BIL cross-client cashout hash was not set. " +
$"OperationId: {@event.OperationId}, " +
$"TxHash: {_crossClientTransactionHashSubstituition}", context: new
{
@@ -164,7 +208,7 @@ public async Task Handle(
if (!await _historyRecordsRepository.UpdateBlockchainHashAsync(@event.CashinOperationId,
_crossClientTransactionHashSubstituition))
{
- _logger.Warning($"Transaction cashin hash was not set. " +
+ _logger.Warning($"BIL cross-client cashin hash was not set. " +
$"OperationId: {@event.OperationId}, " +
$"TxHash: {_crossClientTransactionHashSubstituition}", context: new
{
diff --git a/src/Lykke.Service.History.Core/Lykke.Service.History.Core.csproj b/src/Antares.Service.History.Core/Antares.Service.History.Core.csproj
similarity index 52%
rename from src/Lykke.Service.History.Core/Lykke.Service.History.Core.csproj
rename to src/Antares.Service.History.Core/Antares.Service.History.Core.csproj
index f978c44..9153ad4 100644
--- a/src/Lykke.Service.History.Core/Lykke.Service.History.Core.csproj
+++ b/src/Antares.Service.History.Core/Antares.Service.History.Core.csproj
@@ -1,13 +1,13 @@
- netcoreapp2.2
- Lykke.Service.History.Core
- Lykke.Service.History.Core
+ net5.0
+ Antares.Service.History.Core
+ Antares.Service.History.Core
1.0.0
+
-
diff --git a/src/Lykke.Service.History.Core/Domain/Enums/HistoryState.cs b/src/Antares.Service.History.Core/Domain/Enums/HistoryState.cs
similarity index 70%
rename from src/Lykke.Service.History.Core/Domain/Enums/HistoryState.cs
rename to src/Antares.Service.History.Core/Domain/Enums/HistoryState.cs
index fcce463..b87cff2 100644
--- a/src/Lykke.Service.History.Core/Domain/Enums/HistoryState.cs
+++ b/src/Antares.Service.History.Core/Domain/Enums/HistoryState.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Core.Domain.Enums
+namespace Antares.Service.History.Core.Domain.Enums
{
public enum HistoryState
{
diff --git a/src/Lykke.Service.History.Core/Domain/Enums/HistoryType.cs b/src/Antares.Service.History.Core/Domain/Enums/HistoryType.cs
similarity index 76%
rename from src/Lykke.Service.History.Core/Domain/Enums/HistoryType.cs
rename to src/Antares.Service.History.Core/Domain/Enums/HistoryType.cs
index b4b5c96..6dc2c5d 100644
--- a/src/Lykke.Service.History.Core/Domain/Enums/HistoryType.cs
+++ b/src/Antares.Service.History.Core/Domain/Enums/HistoryType.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Core.Domain.Enums
+namespace Antares.Service.History.Core.Domain.Enums
{
public enum HistoryType
{
diff --git a/src/Lykke.Service.History.Core/Domain/Enums/OrderSide.cs b/src/Antares.Service.History.Core/Domain/Enums/OrderSide.cs
similarity index 60%
rename from src/Lykke.Service.History.Core/Domain/Enums/OrderSide.cs
rename to src/Antares.Service.History.Core/Domain/Enums/OrderSide.cs
index 2c6ca2b..fce6076 100644
--- a/src/Lykke.Service.History.Core/Domain/Enums/OrderSide.cs
+++ b/src/Antares.Service.History.Core/Domain/Enums/OrderSide.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Core.Domain.Enums
+namespace Antares.Service.History.Core.Domain.Enums
{
public enum OrderSide
{
diff --git a/src/Lykke.Service.History.Core/Domain/Enums/OrderStatus.cs b/src/Antares.Service.History.Core/Domain/Enums/OrderStatus.cs
similarity index 77%
rename from src/Lykke.Service.History.Core/Domain/Enums/OrderStatus.cs
rename to src/Antares.Service.History.Core/Domain/Enums/OrderStatus.cs
index f32f56d..605d28a 100644
--- a/src/Lykke.Service.History.Core/Domain/Enums/OrderStatus.cs
+++ b/src/Antares.Service.History.Core/Domain/Enums/OrderStatus.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Core.Domain.Enums
+namespace Antares.Service.History.Core.Domain.Enums
{
public enum OrderStatus
{
diff --git a/src/Lykke.Service.History.Core/Domain/Enums/OrderType.cs b/src/Antares.Service.History.Core/Domain/Enums/OrderType.cs
similarity index 66%
rename from src/Lykke.Service.History.Core/Domain/Enums/OrderType.cs
rename to src/Antares.Service.History.Core/Domain/Enums/OrderType.cs
index 0674f7f..288f60a 100644
--- a/src/Lykke.Service.History.Core/Domain/Enums/OrderType.cs
+++ b/src/Antares.Service.History.Core/Domain/Enums/OrderType.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Core.Domain.Enums
+namespace Antares.Service.History.Core.Domain.Enums
{
public enum OrderType
{
diff --git a/src/Lykke.Service.History.Core/Domain/Enums/TradeRole.cs b/src/Antares.Service.History.Core/Domain/Enums/TradeRole.cs
similarity index 61%
rename from src/Lykke.Service.History.Core/Domain/Enums/TradeRole.cs
rename to src/Antares.Service.History.Core/Domain/Enums/TradeRole.cs
index a46633d..9199514 100644
--- a/src/Lykke.Service.History.Core/Domain/Enums/TradeRole.cs
+++ b/src/Antares.Service.History.Core/Domain/Enums/TradeRole.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.Core.Domain.Enums
+namespace Antares.Service.History.Core.Domain.Enums
{
public enum TradeRole
{
diff --git a/src/Lykke.Service.History.Core/Domain/History/BaseHistoryRecord.cs b/src/Antares.Service.History.Core/Domain/History/BaseHistoryRecord.cs
similarity index 71%
rename from src/Lykke.Service.History.Core/Domain/History/BaseHistoryRecord.cs
rename to src/Antares.Service.History.Core/Domain/History/BaseHistoryRecord.cs
index d9c386c..2aaa238 100644
--- a/src/Lykke.Service.History.Core/Domain/History/BaseHistoryRecord.cs
+++ b/src/Antares.Service.History.Core/Domain/History/BaseHistoryRecord.cs
@@ -1,7 +1,7 @@
using System;
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.Core.Domain.History
+namespace Antares.Service.History.Core.Domain.History
{
public abstract class BaseHistoryRecord
{
diff --git a/src/Lykke.Service.History.Core/Domain/History/Cashin.cs b/src/Antares.Service.History.Core/Domain/History/Cashin.cs
similarity index 77%
rename from src/Lykke.Service.History.Core/Domain/History/Cashin.cs
rename to src/Antares.Service.History.Core/Domain/History/Cashin.cs
index 0891737..47f8376 100644
--- a/src/Lykke.Service.History.Core/Domain/History/Cashin.cs
+++ b/src/Antares.Service.History.Core/Domain/History/Cashin.cs
@@ -1,6 +1,6 @@
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.Core.Domain.History
+namespace Antares.Service.History.Core.Domain.History
{
public class Cashin : BaseHistoryRecord
{
diff --git a/src/Lykke.Service.History.Core/Domain/History/Cashout.cs b/src/Antares.Service.History.Core/Domain/History/Cashout.cs
similarity index 77%
rename from src/Lykke.Service.History.Core/Domain/History/Cashout.cs
rename to src/Antares.Service.History.Core/Domain/History/Cashout.cs
index bcbb9a4..c552c5c 100644
--- a/src/Lykke.Service.History.Core/Domain/History/Cashout.cs
+++ b/src/Antares.Service.History.Core/Domain/History/Cashout.cs
@@ -1,6 +1,6 @@
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.Core.Domain.History
+namespace Antares.Service.History.Core.Domain.History
{
public class Cashout : BaseHistoryRecord
{
diff --git a/src/Lykke.Service.History.Core/Domain/History/IHistoryRecordsRepository.cs b/src/Antares.Service.History.Core/Domain/History/IHistoryRecordsRepository.cs
similarity index 92%
rename from src/Lykke.Service.History.Core/Domain/History/IHistoryRecordsRepository.cs
rename to src/Antares.Service.History.Core/Domain/History/IHistoryRecordsRepository.cs
index 43389d7..be3b5f7 100644
--- a/src/Lykke.Service.History.Core/Domain/History/IHistoryRecordsRepository.cs
+++ b/src/Antares.Service.History.Core/Domain/History/IHistoryRecordsRepository.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.Core.Domain.History
+namespace Antares.Service.History.Core.Domain.History
{
public interface IHistoryRecordsRepository
{
diff --git a/src/Lykke.Service.History.Core/Domain/History/OrderEvent.cs b/src/Antares.Service.History.Core/Domain/History/OrderEvent.cs
similarity index 78%
rename from src/Lykke.Service.History.Core/Domain/History/OrderEvent.cs
rename to src/Antares.Service.History.Core/Domain/History/OrderEvent.cs
index 738a038..7af7b0b 100644
--- a/src/Lykke.Service.History.Core/Domain/History/OrderEvent.cs
+++ b/src/Antares.Service.History.Core/Domain/History/OrderEvent.cs
@@ -1,7 +1,7 @@
using System;
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.Core.Domain.History
+namespace Antares.Service.History.Core.Domain.History
{
public class OrderEvent : BaseHistoryRecord
{
diff --git a/src/Lykke.Service.History.Core/Domain/History/Trade.cs b/src/Antares.Service.History.Core/Domain/History/Trade.cs
similarity index 86%
rename from src/Lykke.Service.History.Core/Domain/History/Trade.cs
rename to src/Antares.Service.History.Core/Domain/History/Trade.cs
index 8fb7d61..a112d0a 100644
--- a/src/Lykke.Service.History.Core/Domain/History/Trade.cs
+++ b/src/Antares.Service.History.Core/Domain/History/Trade.cs
@@ -1,7 +1,7 @@
using System;
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.Core.Domain.History
+namespace Antares.Service.History.Core.Domain.History
{
public class Trade : BaseHistoryRecord
{
diff --git a/src/Lykke.Service.History.Core/Domain/Orders/IOrdersRepository.cs b/src/Antares.Service.History.Core/Domain/Orders/IOrdersRepository.cs
similarity index 83%
rename from src/Lykke.Service.History.Core/Domain/Orders/IOrdersRepository.cs
rename to src/Antares.Service.History.Core/Domain/Orders/IOrdersRepository.cs
index c089f6a..cdcb682 100644
--- a/src/Lykke.Service.History.Core/Domain/Orders/IOrdersRepository.cs
+++ b/src/Antares.Service.History.Core/Domain/Orders/IOrdersRepository.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
-namespace Lykke.Service.History.Core.Domain.Orders
+namespace Antares.Service.History.Core.Domain.Orders
{
public interface IOrdersRepository
{
diff --git a/src/Lykke.Service.History.Core/Domain/Orders/Order.cs b/src/Antares.Service.History.Core/Domain/Orders/Order.cs
similarity index 83%
rename from src/Lykke.Service.History.Core/Domain/Orders/Order.cs
rename to src/Antares.Service.History.Core/Domain/Orders/Order.cs
index 2f01cbe..43a70b6 100644
--- a/src/Lykke.Service.History.Core/Domain/Orders/Order.cs
+++ b/src/Antares.Service.History.Core/Domain/Orders/Order.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
-namespace Lykke.Service.History.Core.Domain.Orders
+namespace Antares.Service.History.Core.Domain.Orders
{
public class Order
{
@@ -47,7 +47,7 @@ public class Order
public bool Straight { get; set; }
- public List Trades { get; set; } = new List();
+ public Trade[] Trades { get; set; } = Array.Empty();
public long SequenceNumber { get; set; }
}
diff --git a/src/Lykke.Service.History.Core/Settings/AppSettings.cs b/src/Antares.Service.History.Core/Settings/AppSettings.cs
similarity index 62%
rename from src/Lykke.Service.History.Core/Settings/AppSettings.cs
rename to src/Antares.Service.History.Core/Settings/AppSettings.cs
index 4f98b01..f7845e5 100644
--- a/src/Lykke.Service.History.Core/Settings/AppSettings.cs
+++ b/src/Antares.Service.History.Core/Settings/AppSettings.cs
@@ -1,7 +1,7 @@
-using JetBrains.Annotations;
-using Lykke.Sdk.Settings;
+using Antares.Sdk.Settings;
+using JetBrains.Annotations;
-namespace Lykke.Service.History.Core.Settings
+namespace Antares.Service.History.Core.Settings
{
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
public class AppSettings : BaseAppSettings
diff --git a/src/Lykke.Service.History.Core/Settings/CqrsSettings.cs b/src/Antares.Service.History.Core/Settings/CqrsSettings.cs
similarity index 77%
rename from src/Lykke.Service.History.Core/Settings/CqrsSettings.cs
rename to src/Antares.Service.History.Core/Settings/CqrsSettings.cs
index 2bb2b9a..39ef47a 100644
--- a/src/Lykke.Service.History.Core/Settings/CqrsSettings.cs
+++ b/src/Antares.Service.History.Core/Settings/CqrsSettings.cs
@@ -1,6 +1,6 @@
using Lykke.SettingsReader.Attributes;
-namespace Lykke.Service.History.Core.Settings
+namespace Antares.Service.History.Core.Settings
{
public class CqrsSettings
{
diff --git a/src/Lykke.Service.History.Core/Settings/DbSettings.cs b/src/Antares.Service.History.Core/Settings/DbSettings.cs
similarity index 82%
rename from src/Lykke.Service.History.Core/Settings/DbSettings.cs
rename to src/Antares.Service.History.Core/Settings/DbSettings.cs
index 652c773..0fc6fc3 100644
--- a/src/Lykke.Service.History.Core/Settings/DbSettings.cs
+++ b/src/Antares.Service.History.Core/Settings/DbSettings.cs
@@ -1,6 +1,6 @@
using Lykke.SettingsReader.Attributes;
-namespace Lykke.Service.History.Core.Settings
+namespace Antares.Service.History.Core.Settings
{
public class DbSettings
{
diff --git a/src/Lykke.Service.History.Core/Settings/HistorySettings.cs b/src/Antares.Service.History.Core/Settings/HistorySettings.cs
similarity index 71%
rename from src/Lykke.Service.History.Core/Settings/HistorySettings.cs
rename to src/Antares.Service.History.Core/Settings/HistorySettings.cs
index c5b93e1..bddb924 100644
--- a/src/Lykke.Service.History.Core/Settings/HistorySettings.cs
+++ b/src/Antares.Service.History.Core/Settings/HistorySettings.cs
@@ -3,7 +3,7 @@
using JetBrains.Annotations;
using Lykke.SettingsReader.Attributes;
-namespace Lykke.Service.History.Core.Settings
+namespace Antares.Service.History.Core.Settings
{
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
public class HistorySettings
@@ -12,6 +12,12 @@ public class HistorySettings
public CqrsSettings Cqrs { get; set; }
+ public RabbitMqSettings MatchingEngineRabbit
+ {
+ get;
+ set;
+ }
+
[Optional]
public int RabbitPrefetchCount { get; set; } = 500;
@@ -20,5 +26,8 @@ public class HistorySettings
[Optional]
public IReadOnlyList WalletIdsToLog { get; set; } = Array.Empty();
+
+ [Optional]
+ public bool CqrsEnabled { get; set; } = false;
}
}
diff --git a/src/Antares.Service.History.Core/Settings/RabbitMqSettings.cs b/src/Antares.Service.History.Core/Settings/RabbitMqSettings.cs
new file mode 100644
index 0000000..793a33a
--- /dev/null
+++ b/src/Antares.Service.History.Core/Settings/RabbitMqSettings.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Lykke.SettingsReader.Attributes;
+
+namespace Antares.Service.History.Core.Settings
+{
+ [UsedImplicitly]
+ public class RabbitMqSettings
+ {
+ [AmqpCheck]
+ public string ConnectionString { get; set; }
+ [AmqpCheck]
+ [Optional]
+ public string AlternativeConnectionString { get; set; }
+ public string Exchange { get; set; }
+ }
+}
diff --git a/src/Lykke.Service.History.Core/Utils.cs b/src/Antares.Service.History.Core/Utils.cs
similarity index 93%
rename from src/Lykke.Service.History.Core/Utils.cs
rename to src/Antares.Service.History.Core/Utils.cs
index 0fadaa6..5cb8e80 100644
--- a/src/Lykke.Service.History.Core/Utils.cs
+++ b/src/Antares.Service.History.Core/Utils.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Text.RegularExpressions;
-namespace Lykke.Service.History.Core
+namespace Antares.Service.History.Core
{
public class Utils
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Lykke.Service.History.PostgresRepositories.csproj b/src/Antares.Service.History.PostgresRepositories/Antares.Service.History.PostgresRepositories.csproj
similarity index 51%
rename from src/Lykke.Service.History.PostgresRepositories/Lykke.Service.History.PostgresRepositories.csproj
rename to src/Antares.Service.History.PostgresRepositories/Antares.Service.History.PostgresRepositories.csproj
index 098af54..e99a9f9 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Lykke.Service.History.PostgresRepositories.csproj
+++ b/src/Antares.Service.History.PostgresRepositories/Antares.Service.History.PostgresRepositories.csproj
@@ -1,18 +1,18 @@
- netcoreapp2.2
- Lykke.Service.History.PostgresRepositories
- Lykke.Service.History.PostgresRepositories
+ net5.0
+ Antares.Service.History.PostgresRepositories
+ Antares.Service.History.PostgresRepositories
1.0.0
-
-
-
+
+
+
-
+
diff --git a/src/Lykke.Service.History.PostgresRepositories/ConnectionFactory.cs b/src/Antares.Service.History.PostgresRepositories/ConnectionFactory.cs
similarity index 91%
rename from src/Lykke.Service.History.PostgresRepositories/ConnectionFactory.cs
rename to src/Antares.Service.History.PostgresRepositories/ConnectionFactory.cs
index 25e0fbd..7aa8526 100644
--- a/src/Lykke.Service.History.PostgresRepositories/ConnectionFactory.cs
+++ b/src/Antares.Service.History.PostgresRepositories/ConnectionFactory.cs
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Npgsql;
-namespace Lykke.Service.History.PostgresRepositories
+namespace Antares.Service.History.PostgresRepositories
{
public class ConnectionFactory
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Constants.cs b/src/Antares.Service.History.PostgresRepositories/Constants.cs
similarity index 71%
rename from src/Lykke.Service.History.PostgresRepositories/Constants.cs
rename to src/Antares.Service.History.PostgresRepositories/Constants.cs
index 0f9effc..05fc07d 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Constants.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Constants.cs
@@ -1,4 +1,4 @@
-namespace Lykke.Service.History.PostgresRepositories
+namespace Antares.Service.History.PostgresRepositories
{
internal class Constants
{
@@ -9,5 +9,7 @@ internal class Constants
public const string TempOrdersTableName = "temporders";
public const string DateTimeFormat = "yyyy-MM-dd HH:mm:ss.fff";
+
+ public const string HistorySchemaName = "public";
}
}
diff --git a/src/Lykke.Service.History.PostgresRepositories/DataContext.cs b/src/Antares.Service.History.PostgresRepositories/DataContext.cs
similarity index 68%
rename from src/Lykke.Service.History.PostgresRepositories/DataContext.cs
rename to src/Antares.Service.History.PostgresRepositories/DataContext.cs
index 6d8ef80..8905ffc 100644
--- a/src/Lykke.Service.History.PostgresRepositories/DataContext.cs
+++ b/src/Antares.Service.History.PostgresRepositories/DataContext.cs
@@ -1,9 +1,9 @@
-using Lykke.Service.History.PostgresRepositories.Entities;
-using Lykke.Service.History.PostgresRepositories.JsonbQuery;
+using Antares.Service.History.PostgresRepositories.Entities;
+using Antares.Service.History.PostgresRepositories.JsonbQuery;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
-namespace Lykke.Service.History.PostgresRepositories
+namespace Antares.Service.History.PostgresRepositories
{
public class DataContext : DbContext
{
@@ -18,10 +18,14 @@ public DataContext(string connectionString)
internal virtual DbSet Orders { get; set; }
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.HasDefaultSchema(Constants.HistorySchemaName);
+ }
+
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.ReplaceService();
-
optionsBuilder.UseNpgsql(_connectionString);
}
}
diff --git a/src/Lykke.Service.History.PostgresRepositories/Entities/HistoryEntity.cs b/src/Antares.Service.History.PostgresRepositories/Entities/HistoryEntity.cs
similarity index 91%
rename from src/Lykke.Service.History.PostgresRepositories/Entities/HistoryEntity.cs
rename to src/Antares.Service.History.PostgresRepositories/Entities/HistoryEntity.cs
index e4e5dce..f71a7bc 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Entities/HistoryEntity.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Entities/HistoryEntity.cs
@@ -1,10 +1,10 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
+using Antares.Service.History.Core.Domain.Enums;
using Common;
-using Lykke.Service.History.Core.Domain.Enums;
using Newtonsoft.Json;
-namespace Lykke.Service.History.PostgresRepositories.Entities
+namespace Antares.Service.History.PostgresRepositories.Entities
{
[Table(Constants.HistoryTableName)]
internal class HistoryEntity
diff --git a/src/Lykke.Service.History.PostgresRepositories/Entities/HistoryEntityContext.cs b/src/Antares.Service.History.PostgresRepositories/Entities/HistoryEntityContext.cs
similarity index 93%
rename from src/Lykke.Service.History.PostgresRepositories/Entities/HistoryEntityContext.cs
rename to src/Antares.Service.History.PostgresRepositories/Entities/HistoryEntityContext.cs
index 7dc8396..260508e 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Entities/HistoryEntityContext.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Entities/HistoryEntityContext.cs
@@ -1,6 +1,6 @@
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.PostgresRepositories.Entities
+namespace Antares.Service.History.PostgresRepositories.Entities
{
internal class HistoryEntityContext
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Entities/OrderEntity.cs b/src/Antares.Service.History.PostgresRepositories/Entities/OrderEntity.cs
similarity index 94%
rename from src/Lykke.Service.History.PostgresRepositories/Entities/OrderEntity.cs
rename to src/Antares.Service.History.PostgresRepositories/Entities/OrderEntity.cs
index aa487c2..70612fd 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Entities/OrderEntity.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Entities/OrderEntity.cs
@@ -1,8 +1,8 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
-using Lykke.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.Enums;
-namespace Lykke.Service.History.PostgresRepositories.Entities
+namespace Antares.Service.History.PostgresRepositories.Entities
{
[Table(Constants.OrdersTableName)]
internal class OrderEntity
diff --git a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/CustomSqlMethodCallTranslator.cs b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/CustomSqlMethodCallTranslator.cs
similarity index 90%
rename from src/Lykke.Service.History.PostgresRepositories/JsonbQuery/CustomSqlMethodCallTranslator.cs
rename to src/Antares.Service.History.PostgresRepositories/JsonbQuery/CustomSqlMethodCallTranslator.cs
index eeceff6..6beec78 100644
--- a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/CustomSqlMethodCallTranslator.cs
+++ b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/CustomSqlMethodCallTranslator.cs
@@ -2,7 +2,7 @@
using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal;
using Npgsql.EntityFrameworkCore.PostgreSQL.Query.ExpressionTranslators.Internal;
-namespace Lykke.Service.History.PostgresRepositories.JsonbQuery
+namespace Antares.Service.History.PostgresRepositories.JsonbQuery
{
internal class CustomSqlMethodCallTranslator : NpgsqlCompositeMethodCallTranslator
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/JsonbExtensions.cs b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/JsonbExtensions.cs
similarity index 80%
rename from src/Lykke.Service.History.PostgresRepositories/JsonbQuery/JsonbExtensions.cs
rename to src/Antares.Service.History.PostgresRepositories/JsonbQuery/JsonbExtensions.cs
index c9c7fbc..9cf6cad 100644
--- a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/JsonbExtensions.cs
+++ b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/JsonbExtensions.cs
@@ -1,6 +1,6 @@
using System;
-namespace Lykke.Service.History.PostgresRepositories.JsonbQuery
+namespace Antares.Service.History.PostgresRepositories.JsonbQuery
{
internal static class JsonbExtensions
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/JsonbFindTranslator.cs b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/JsonbFindTranslator.cs
similarity index 94%
rename from src/Lykke.Service.History.PostgresRepositories/JsonbQuery/JsonbFindTranslator.cs
rename to src/Antares.Service.History.PostgresRepositories/JsonbQuery/JsonbFindTranslator.cs
index 2aa98fb..922a6f5 100644
--- a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/JsonbFindTranslator.cs
+++ b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/JsonbFindTranslator.cs
@@ -3,7 +3,7 @@
using Microsoft.EntityFrameworkCore.Query.Expressions;
using Microsoft.EntityFrameworkCore.Query.ExpressionTranslators;
-namespace Lykke.Service.History.PostgresRepositories.JsonbQuery
+namespace Antares.Service.History.PostgresRepositories.JsonbQuery
{
internal class JsonbFindTranslator : IMethodCallTranslator
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/NpgsqlFragmentExpression.cs b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/NpgsqlFragmentExpression.cs
similarity index 93%
rename from src/Lykke.Service.History.PostgresRepositories/JsonbQuery/NpgsqlFragmentExpression.cs
rename to src/Antares.Service.History.PostgresRepositories/JsonbQuery/NpgsqlFragmentExpression.cs
index 6fe229e..6bffbf2 100644
--- a/src/Lykke.Service.History.PostgresRepositories/JsonbQuery/NpgsqlFragmentExpression.cs
+++ b/src/Antares.Service.History.PostgresRepositories/JsonbQuery/NpgsqlFragmentExpression.cs
@@ -2,7 +2,7 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query.Expressions;
-namespace Lykke.Service.History.PostgresRepositories.JsonbQuery
+namespace Antares.Service.History.PostgresRepositories.JsonbQuery
{
internal class NpgsqlFragmentExpression : SqlFragmentExpression
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Mappings/HistoryEntityBulkMapping.cs b/src/Antares.Service.History.PostgresRepositories/Mappings/HistoryEntityBulkMapping.cs
similarity index 78%
rename from src/Lykke.Service.History.PostgresRepositories/Mappings/HistoryEntityBulkMapping.cs
rename to src/Antares.Service.History.PostgresRepositories/Mappings/HistoryEntityBulkMapping.cs
index 11bbafa..0defacb 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Mappings/HistoryEntityBulkMapping.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Mappings/HistoryEntityBulkMapping.cs
@@ -1,13 +1,13 @@
-using Lykke.Service.History.PostgresRepositories.Entities;
+using Antares.Service.History.PostgresRepositories.Entities;
using PostgreSQLCopyHelper;
-namespace Lykke.Service.History.PostgresRepositories.Mappings
+namespace Antares.Service.History.PostgresRepositories.Mappings
{
internal class HistoryEntityBulkMapping
{
public static PostgreSQLCopyHelper Generate()
{
- return new PostgreSQLCopyHelper(Constants.HistoryTableName)
+ return new PostgreSQLCopyHelper(Constants.HistorySchemaName, Constants.HistoryTableName)
.MapUUID("id", x => x.Id)
.MapUUID("wallet_id", x => x.WalletId)
.MapText("asset_id", x => x.AssetId)
diff --git a/src/Lykke.Service.History.PostgresRepositories/Mappings/HistoryTypeMapper.cs b/src/Antares.Service.History.PostgresRepositories/Mappings/HistoryTypeMapper.cs
similarity index 86%
rename from src/Lykke.Service.History.PostgresRepositories/Mappings/HistoryTypeMapper.cs
rename to src/Antares.Service.History.PostgresRepositories/Mappings/HistoryTypeMapper.cs
index 45aa032..58734a3 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Mappings/HistoryTypeMapper.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Mappings/HistoryTypeMapper.cs
@@ -1,10 +1,10 @@
using System;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.PostgresRepositories.Entities;
using AutoMapper;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.PostgresRepositories.Entities;
-namespace Lykke.Service.History.PostgresRepositories.Mappings
+namespace Antares.Service.History.PostgresRepositories.Mappings
{
internal class HistoryTypeMapper
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Mappings/OrderEntityBulkMapping.cs b/src/Antares.Service.History.PostgresRepositories/Mappings/OrderEntityBulkMapping.cs
similarity index 92%
rename from src/Lykke.Service.History.PostgresRepositories/Mappings/OrderEntityBulkMapping.cs
rename to src/Antares.Service.History.PostgresRepositories/Mappings/OrderEntityBulkMapping.cs
index 12067cf..114489c 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Mappings/OrderEntityBulkMapping.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Mappings/OrderEntityBulkMapping.cs
@@ -1,8 +1,8 @@
-using Lykke.Service.History.PostgresRepositories.Entities;
+using Antares.Service.History.PostgresRepositories.Entities;
using NpgsqlTypes;
using PostgreSQLCopyHelper;
-namespace Lykke.Service.History.PostgresRepositories.Mappings
+namespace Antares.Service.History.PostgresRepositories.Mappings
{
internal class OrderEntityBulkMapping
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Mappings/RepositoryProfile.cs b/src/Antares.Service.History.PostgresRepositories/Mappings/RepositoryProfile.cs
similarity index 93%
rename from src/Lykke.Service.History.PostgresRepositories/Mappings/RepositoryProfile.cs
rename to src/Antares.Service.History.PostgresRepositories/Mappings/RepositoryProfile.cs
index a9098bf..854ad81 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Mappings/RepositoryProfile.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Mappings/RepositoryProfile.cs
@@ -1,10 +1,10 @@
-using AutoMapper;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.History.PostgresRepositories.Entities;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.PostgresRepositories.Entities;
+using AutoMapper;
-namespace Lykke.Service.History.PostgresRepositories.Mappings
+namespace Antares.Service.History.PostgresRepositories.Mappings
{
public class RepositoryProfile : Profile
{
diff --git a/src/Lykke.Service.History.PostgresRepositories/Repositories/HistoryRecordsRepository.cs b/src/Antares.Service.History.PostgresRepositories/Repositories/HistoryRecordsRepository.cs
similarity index 91%
rename from src/Lykke.Service.History.PostgresRepositories/Repositories/HistoryRecordsRepository.cs
rename to src/Antares.Service.History.PostgresRepositories/Repositories/HistoryRecordsRepository.cs
index 18c2fcb..8324590 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Repositories/HistoryRecordsRepository.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Repositories/HistoryRecordsRepository.cs
@@ -3,18 +3,18 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.PostgresRepositories.Entities;
+using Antares.Service.History.PostgresRepositories.JsonbQuery;
+using Antares.Service.History.PostgresRepositories.Mappings;
using AutoMapper;
using Dapper;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.PostgresRepositories.Entities;
-using Lykke.Service.History.PostgresRepositories.JsonbQuery;
-using Lykke.Service.History.PostgresRepositories.Mappings;
using Microsoft.EntityFrameworkCore;
using Npgsql;
using PostgreSQLCopyHelper;
-namespace Lykke.Service.History.PostgresRepositories.Repositories
+namespace Antares.Service.History.PostgresRepositories.Repositories
{
public class HistoryRecordsRepository : IHistoryRecordsRepository
{
@@ -23,25 +23,25 @@ public class HistoryRecordsRepository : IHistoryRecordsRepository
private readonly ConnectionFactory _connectionFactory;
private readonly string _insertQuery = $@"
-insert into {Constants.HistoryTableName}(id, wallet_id, asset_id, assetpair_id, volume, type, create_dt, context)
+insert into {Constants.HistorySchemaName}.{Constants.HistoryTableName}(id, wallet_id, asset_id, assetpair_id, volume, type, create_dt, context)
values (@Id, @WalletId, @AssetId, @AssetPairId, @Volume, @Type, @Timestamp, @Context::jsonb)
ON CONFLICT (id, wallet_id) DO NOTHING;
";
private readonly string _deleteQuery = $@"
-delete from {Constants.HistoryTableName}
+delete from {Constants.HistorySchemaName}.{Constants.HistoryTableName}
where id = @Id and wallet_id = @WalletId
";
private readonly string _updateBlockchainHashQuery = $@"
-update {Constants.HistoryTableName}
+update {Constants.HistorySchemaName}.{Constants.HistoryTableName}
set context = jsonb_set(coalesce(context, '{{}}'), '{{{
nameof(HistoryEntityContext.BlockchainHash)
}}}', coalesce(to_jsonb(@Hash::text), jsonb 'null'))
where id = @Id
";
- private readonly string _tradesDateRangeQuery = $@"SELECT * FROM {Constants.HistoryTableName}
+ private readonly string _tradesDateRangeQuery = $@"SELECT * FROM {Constants.HistorySchemaName}.{Constants.HistoryTableName}
WHERE type = {(int)HistoryType.Trade} AND create_dt >= '{{0}}' AND create_dt < '{{1}}' ORDER BY create_dt
LIMIT {{2}} OFFSET {{3}}";
@@ -81,6 +81,7 @@ public async Task InsertBulkAsync(IEnumerable records)
try
{
+ //TODO: Save Async
BulkMapping.SaveAll(connection, baseHistoryRecords.Select(HistoryTypeMapper.Map));
}
catch (PostgresException e) when (e.SqlState == DuplicateSqlState)
diff --git a/src/Lykke.Service.History.PostgresRepositories/Repositories/OrdersRepository.cs b/src/Antares.Service.History.PostgresRepositories/Repositories/OrdersRepository.cs
similarity index 86%
rename from src/Lykke.Service.History.PostgresRepositories/Repositories/OrdersRepository.cs
rename to src/Antares.Service.History.PostgresRepositories/Repositories/OrdersRepository.cs
index e4f7494..482a2c5 100644
--- a/src/Lykke.Service.History.PostgresRepositories/Repositories/OrdersRepository.cs
+++ b/src/Antares.Service.History.PostgresRepositories/Repositories/OrdersRepository.cs
@@ -3,25 +3,25 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.PostgresRepositories.Entities;
+using Antares.Service.History.PostgresRepositories.JsonbQuery;
+using Antares.Service.History.PostgresRepositories.Mappings;
using AutoMapper;
using Dapper;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.History.PostgresRepositories.Entities;
-using Lykke.Service.History.PostgresRepositories.JsonbQuery;
-using Lykke.Service.History.PostgresRepositories.Mappings;
using Microsoft.EntityFrameworkCore;
using PostgreSQLCopyHelper;
-namespace Lykke.Service.History.PostgresRepositories.Repositories
+namespace Antares.Service.History.PostgresRepositories.Repositories
{
public class OrdersRepository : IOrdersRepository
{
private static readonly PostgreSQLCopyHelper BulkMapping;
private readonly string _bulkUpsertQuery = $@"
-insert into {Constants.OrdersTableName}
+insert into {Constants.HistorySchemaName}.{Constants.OrdersTableName}
select * from {Constants.TempOrdersTableName}
ON CONFLICT (id) DO UPDATE
set type = excluded.type,
@@ -38,17 +38,18 @@ ON CONFLICT (id) DO UPDATE
upper_limit_price = excluded.upper_limit_price,
upper_price = excluded.upper_price,
sequence_number = excluded.sequence_number
- where {Constants.OrdersTableName}.sequence_number < excluded.sequence_number";
+ where {Constants.HistorySchemaName}.{Constants.OrdersTableName}.sequence_number < excluded.sequence_number";
private readonly ConnectionFactory _connectionFactory;
+ //Note: Temp tables are created in their own schema (for each session)
private readonly string _createTempTableQuery = $@"
create temp table if not exists {Constants.TempOrdersTableName}
-(like {Constants.OrdersTableName})
+(like {Constants.HistorySchemaName}.{Constants.OrdersTableName})
on commit drop";
private readonly string _insertOrUpdateQuery = $@"
-insert into {Constants.OrdersTableName}(id, matching_id, wallet_id, assetpair_id, type, side, status, volume, price,
+insert into {Constants.HistorySchemaName}.{Constants.OrdersTableName}(id, matching_id, wallet_id, assetpair_id, type, side, status, volume, price,
create_dt, register_dt, status_dt, match_dt, remaining_volume, reject_reason,
lower_limit_price, lower_price, upper_limit_price, upper_price, straight, sequence_number)
values (@Id, @MatchingId, @WalletId, @AssetPairId, @Type, @Side, @Status, @Volume, @Price,
@@ -69,9 +70,9 @@ ON CONFLICT (id) DO UPDATE
upper_limit_price = @UpperLimitPrice,
upper_price = @UpperPrice,
sequence_number = @SequenceNumber
- where {Constants.OrdersTableName}.sequence_number < @SequenceNumber";
+ where {Constants.HistorySchemaName}.{Constants.OrdersTableName}.sequence_number < @SequenceNumber";
- private readonly string _ordersDateRangeQuery = $@"SELECT * FROM {Constants.OrdersTableName}
+ private readonly string _ordersDateRangeQuery = $@"SELECT * FROM {Constants.HistorySchemaName}.{Constants.OrdersTableName}
WHERE create_dt >= '{{0}}' AND create_dt < '{{1}}' ORDER BY create_dt
LIMIT {{2}} OFFSET {{3}}";
diff --git a/src/Lykke.Service.History.Services/Lykke.Service.History.Services.csproj b/src/Antares.Service.History.Services/Antares.Service.History.Services.csproj
similarity index 60%
rename from src/Lykke.Service.History.Services/Lykke.Service.History.Services.csproj
rename to src/Antares.Service.History.Services/Antares.Service.History.Services.csproj
index 23f9ec6..aaac335 100644
--- a/src/Lykke.Service.History.Services/Lykke.Service.History.Services.csproj
+++ b/src/Antares.Service.History.Services/Antares.Service.History.Services.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.2
- Lykke.Service.History.Services
+ net5.0
+ Antares.Service.History.Services
Lykke.Service.History.Services
1.0.0
diff --git a/src/Lykke.Service.History/Lykke.Service.History.csproj b/src/Antares.Service.History/Antares.Service.History.csproj
similarity index 67%
rename from src/Lykke.Service.History/Lykke.Service.History.csproj
rename to src/Antares.Service.History/Antares.Service.History.csproj
index 7049abb..6ea80bd 100644
--- a/src/Lykke.Service.History/Lykke.Service.History.csproj
+++ b/src/Antares.Service.History/Antares.Service.History.csproj
@@ -1,18 +1,18 @@
- netcoreapp2.2
+ net5.0
Exe
1.0.1
- Lykke.Service.History
- Lykke.Service.History
+ Antares.Service.History
+ Antares.Service.History
- bin\Release\netcoreapp2.0\Lykke.Service.History.xml
+ bin\Release\net5.0\Antares.Service.History.xml
1701;1702;1705;1591
latest
- bin\Debug\netcoreapp2.0\Lykke.Service.History.xml
+ bin\Debug\net5.0\Antares.Service.History.xml
1701;1702;1705;1591
latest
@@ -22,6 +22,7 @@
+
@@ -30,16 +31,15 @@
-
-
-
+
-
-
-
+
+
+
+
diff --git a/src/Lykke.Service.History/AutoMapper/ServiceProfile.cs b/src/Antares.Service.History/AutoMapper/ServiceProfile.cs
similarity index 65%
rename from src/Lykke.Service.History/AutoMapper/ServiceProfile.cs
rename to src/Antares.Service.History/AutoMapper/ServiceProfile.cs
index 5decb63..5c75b57 100644
--- a/src/Lykke.Service.History/AutoMapper/ServiceProfile.cs
+++ b/src/Antares.Service.History/AutoMapper/ServiceProfile.cs
@@ -1,17 +1,16 @@
-using AutoMapper;
-using Lykke.Service.History.Contracts.History;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Models;
-using TradeModel = Lykke.Service.PostProcessing.Contracts.Cqrs.Models.TradeModel;
+using Antares.Service.History.Contracts.History;
+using Antares.Service.History.Contracts.Orders;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using AutoMapper;
-namespace Lykke.Service.History.AutoMapper
+namespace Antares.Service.History.AutoMapper
{
public class ServiceProfile : Profile
{
public ServiceProfile()
{
- CreateMap();
+ CreateMap();
CreateMap();
diff --git a/src/Lykke.Service.History/Controllers/HistoryController.cs b/src/Antares.Service.History/Controllers/HistoryController.cs
similarity index 72%
rename from src/Lykke.Service.History/Controllers/HistoryController.cs
rename to src/Antares.Service.History/Controllers/HistoryController.cs
index 53aea76..5513bf5 100644
--- a/src/Lykke.Service.History/Controllers/HistoryController.cs
+++ b/src/Antares.Service.History/Controllers/HistoryController.cs
@@ -3,14 +3,14 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.History;
+using Antares.Service.History.Core.Domain.History;
using AutoMapper;
-using Lykke.Service.History.Contracts.History;
-using Lykke.Service.History.Core.Domain.History;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
-using HistoryType = Lykke.Service.History.Core.Domain.Enums.HistoryType;
-namespace Lykke.Service.History.Controllers
+namespace Antares.Service.History.Controllers
{
[Route("api/history")]
[ApiController]
@@ -51,7 +51,22 @@ public async Task> GetHistory(
if (type.Length == 0)
type = Enum.GetValues(typeof(HistoryType)).Cast().ToArray();
- var data = await _historyRecordsRepository.GetByWalletAsync(walletId, type, offset, limit, assetPairId, assetId, from, to);
+ var mappedType = type.Select(x => x switch
+ {
+ HistoryType.CashIn => Antares.Service.History.Core.Domain.Enums.HistoryType.CashIn,
+ HistoryType.CashOut => Antares.Service.History.Core.Domain.Enums.HistoryType.CashOut,
+ HistoryType.Trade => Antares.Service.History.Core.Domain.Enums.HistoryType.Trade,
+ HistoryType.OrderEvent => Antares.Service.History.Core.Domain.Enums.HistoryType.OrderEvent,
+
+ _ => throw new ArgumentOutOfRangeException(nameof(x), x, null)
+ }).ToArray();
+ var data = await _historyRecordsRepository.GetByWalletAsync(walletId, mappedType,
+ offset,
+ limit,
+ assetPairId,
+ assetId,
+ from,
+ to);
return Mapper.Map>(data);
}
@@ -73,3 +88,5 @@ public async Task GetHistory(Guid walletId, Guid id)
}
}
}
+
+
diff --git a/src/Lykke.Service.History/Controllers/OrdersController.cs b/src/Antares.Service.History/Controllers/OrdersController.cs
similarity index 66%
rename from src/Lykke.Service.History/Controllers/OrdersController.cs
rename to src/Antares.Service.History/Controllers/OrdersController.cs
index 9a3c924..750b909 100644
--- a/src/Lykke.Service.History/Controllers/OrdersController.cs
+++ b/src/Antares.Service.History/Controllers/OrdersController.cs
@@ -3,14 +3,14 @@
using System.Linq;
using System.Net;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.Orders;
+using Antares.Service.History.Core.Domain.Orders;
using AutoMapper;
-using Lykke.Service.History.Contracts.Orders;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.Orders;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
-namespace Lykke.Service.History.Controllers
+namespace Antares.Service.History.Controllers
{
[Route("api/orders")]
[ApiController]
@@ -63,10 +63,32 @@ public async Task> GetOrders(
if (type.Length == 0)
type = Enum.GetValues(typeof(OrderType)).Cast().ToArray();
+ var mappedType = type.Select(x => x switch
+ {
+ OrderType.Unknown => Antares.Service.History.Core.Domain.Enums.OrderType.Unknown,
+ OrderType.Market => Antares.Service.History.Core.Domain.Enums.OrderType.Market,
+ OrderType.Limit => Antares.Service.History.Core.Domain.Enums.OrderType.Limit,
+ OrderType.StopLimit => Antares.Service.History.Core.Domain.Enums.OrderType.StopLimit,
+ _ => throw new ArgumentOutOfRangeException(nameof(x), x, null)
+ }).ToArray();
+
+ var mappedStatus = status.Select(x => x switch
+ {
+ OrderStatus.Unknown => Antares.Service.History.Core.Domain.Enums.OrderStatus.Unknown,
+ OrderStatus.Placed => Antares.Service.History.Core.Domain.Enums.OrderStatus.Placed,
+ OrderStatus.PartiallyMatched => Antares.Service.History.Core.Domain.Enums.OrderStatus.PartiallyMatched,
+ OrderStatus.Matched => Antares.Service.History.Core.Domain.Enums.OrderStatus.Matched,
+ OrderStatus.Pending => Antares.Service.History.Core.Domain.Enums.OrderStatus.Pending,
+ OrderStatus.Cancelled => Antares.Service.History.Core.Domain.Enums.OrderStatus.Cancelled,
+ OrderStatus.Replaced => Antares.Service.History.Core.Domain.Enums.OrderStatus.Replaced,
+ OrderStatus.Rejected => Antares.Service.History.Core.Domain.Enums.OrderStatus.Rejected,
+ _ => throw new ArgumentOutOfRangeException(nameof(x), x, null)
+ }).ToArray();
+
var data = await _ordersRepository.GetOrdersAsync(
walletId,
- type,
- status,
+ mappedType,
+ mappedStatus,
assetPairId,
offset,
limit);
@@ -122,8 +144,11 @@ public async Task> GetActiveOrders(
{
var data = await _ordersRepository.GetOrdersAsync(
walletId,
- new[] { OrderType.Limit, OrderType.StopLimit },
- new[] { OrderStatus.Placed, OrderStatus.PartiallyMatched, OrderStatus.Pending },
+ new[] { Antares.Service.History.Core.Domain.Enums.OrderType.Limit,
+ Antares.Service.History.Core.Domain.Enums.OrderType.StopLimit },
+ new[] { Antares.Service.History.Core.Domain.Enums.OrderStatus.Placed,
+ Antares.Service.History.Core.Domain.Enums.OrderStatus.PartiallyMatched,
+ Antares.Service.History.Core.Domain.Enums.OrderStatus.Pending },
assetPairId,
offset,
limit);
diff --git a/src/Lykke.Service.History/Controllers/TradesController.cs b/src/Antares.Service.History/Controllers/TradesController.cs
similarity index 94%
rename from src/Lykke.Service.History/Controllers/TradesController.cs
rename to src/Antares.Service.History/Controllers/TradesController.cs
index 006aba1..e5d7219 100644
--- a/src/Lykke.Service.History/Controllers/TradesController.cs
+++ b/src/Antares.Service.History/Controllers/TradesController.cs
@@ -2,15 +2,15 @@
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Contracts.History;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
using AutoMapper;
-using Lykke.Service.History.Contracts.Enums;
-using Lykke.Service.History.Contracts.History;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
-namespace Lykke.Service.History.Controllers
+namespace Antares.Service.History.Controllers
{
[Route("api/trades")]
[ApiController]
diff --git a/src/Antares.Service.History/Dockerfile b/src/Antares.Service.History/Dockerfile
new file mode 100644
index 0000000..83e94fd
--- /dev/null
+++ b/src/Antares.Service.History/Dockerfile
@@ -0,0 +1,6 @@
+FROM mcr.microsoft.com/dotnet/aspnet:5.0.1-buster-slim
+WORKDIR /app
+EXPOSE 5001
+EXPOSE 5000
+COPY . .
+ENTRYPOINT ["dotnet", "Antares.Service.History.dll"]
diff --git a/src/Antares.Service.History/GrpcServices/HistoryService.cs b/src/Antares.Service.History/GrpcServices/HistoryService.cs
new file mode 100644
index 0000000..2e64aab
--- /dev/null
+++ b/src/Antares.Service.History/GrpcServices/HistoryService.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.GrpcContract.Common;
+using Antares.Service.History.GrpcContract.History;
+using Antares.Service.History.GrpcServices.Mappers;
+using Grpc.Core;
+using GetHistoryItemResponse = Antares.Service.History.GrpcContract.History.GetHistoryItemResponse;
+
+namespace Antares.Service.History.GrpcServices
+{
+ public class HistoryService : GrpcContract.History.History.HistoryBase
+ {
+ private readonly IHistoryRecordsRepository _historyRecordsRepository;
+
+ public HistoryService(IHistoryRecordsRepository historyRecordsRepository)
+ {
+ _historyRecordsRepository = historyRecordsRepository;
+ }
+
+ public override async Task GetHistory(HistoryGetHistoryRequest request, ServerCallContext context)
+ {
+ var type = request.Type.ToArray();
+
+ if (type.Length == 0)
+ type = Enum.GetValues(typeof(GrpcContract.Common.HistoryType)).Cast().ToArray();
+
+ var mappedType = type.Select(x => x switch
+ {
+ GrpcContract.Common.HistoryType.CashIn => Antares.Service.History.Core.Domain.Enums.HistoryType.CashIn,
+ GrpcContract.Common.HistoryType.CashOut => Antares.Service.History.Core.Domain.Enums.HistoryType.CashOut,
+ GrpcContract.Common.HistoryType.Trade => Antares.Service.History.Core.Domain.Enums.HistoryType.Trade,
+ GrpcContract.Common.HistoryType.OrderEvent => Antares.Service.History.Core.Domain.Enums.HistoryType.OrderEvent,
+
+ _ => throw new ArgumentOutOfRangeException(nameof(x), x, null)
+ }).ToArray();
+
+
+ var pagination = GrpcMapper.EnsurePagination(request.Pagination);
+
+ var data = await _historyRecordsRepository.GetByWalletAsync(
+ Guid.Parse(request.WalletId),
+ mappedType,
+ pagination.Offset,
+ pagination.Limit,
+ request.AssetPairId,
+ request.AssetId,
+ request.From?.ToDateTime(),
+ request.To?.ToDateTime());
+
+ var mappedItems = GrpcMapper.Map(data);
+ return new HistoryGetHistoryResponse()
+ {
+ Items = { mappedItems },
+ Pagination = new PaginatedInt32Response()
+ {
+ Count = mappedItems.Count,
+ Offset = pagination.Offset + mappedItems.Count,
+ }
+ };
+ }
+
+ public override async Task GetHistoryItem(GetHistoryItemRequest request, ServerCallContext context)
+ {
+ var item = await _historyRecordsRepository.GetAsync(Guid.Parse( request.Id), Guid.Parse(request.WalletId));
+
+ return new GetHistoryItemResponse()
+ {
+ Item = item != null ? GrpcMapper.Map(item): null
+ };
+ }
+ }
+}
diff --git a/src/Antares.Service.History/GrpcServices/IsAliveService.cs b/src/Antares.Service.History/GrpcServices/IsAliveService.cs
new file mode 100644
index 0000000..0584741
--- /dev/null
+++ b/src/Antares.Service.History/GrpcServices/IsAliveService.cs
@@ -0,0 +1,24 @@
+using System.Threading.Tasks;
+using Antares.Service.History.GrpcContract.Monitoring;
+using Google.Protobuf.WellKnownTypes;
+using Grpc.Core;
+using Lykke.Common;
+
+namespace Antares.Service.History.GrpcServices
+{
+ //TODO:
+ public class IsAliveService : MonitoringService.MonitoringServiceBase
+ {
+ public override Task IsAlive(IsAliveRequest request, ServerCallContext context)
+ {
+ return Task.FromResult(new IsAliveResponse()
+ {
+ Name = AppEnvironment.Name,
+ Version = AppEnvironment.Version,
+ //StartedAt = Timestamp.FromDateTime(ApplicationInformation.StartedAt),
+ Env = AppEnvironment.EnvInfo,
+ //HostName = ApplicationEnvironment.HostName,
+ });
+ }
+ }
+}
diff --git a/src/Antares.Service.History/GrpcServices/Mappers/GrpcMapper.cs b/src/Antares.Service.History/GrpcServices/Mappers/GrpcMapper.cs
new file mode 100644
index 0000000..fec35b6
--- /dev/null
+++ b/src/Antares.Service.History/GrpcServices/Mappers/GrpcMapper.cs
@@ -0,0 +1,188 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.GrpcContract.Common;
+using Antares.Service.History.GrpcContract.Orders;
+using Google.Protobuf.WellKnownTypes;
+using HistoryType = Antares.Service.History.Core.Domain.Enums.HistoryType;
+using OrderSide = Antares.Service.History.Core.Domain.Enums.OrderSide;
+using OrderStatus = Antares.Service.History.Core.Domain.Enums.OrderStatus;
+using OrderType = Antares.Service.History.Core.Domain.Enums.OrderType;
+using TradeRole = Antares.Service.History.Core.Domain.Enums.TradeRole;
+
+namespace Antares.Service.History.GrpcServices.Mappers
+{
+ public static class GrpcMapper
+ {
+ public static IReadOnlyCollection Map(IEnumerable records)
+ {
+ return records.Select(Map).ToArray();
+ }
+
+ public static HistoryResponseItem Map(BaseHistoryRecord baseHistoryRecord)
+ {
+ var item = new HistoryResponseItem()
+ {
+ Id = baseHistoryRecord.Id.ToString(),
+ Timestamp = baseHistoryRecord.Timestamp.ToUniversalTime().ToTimestamp(),
+ WalletId = baseHistoryRecord.WalletId.ToString(),
+ };
+
+ switch (baseHistoryRecord.Type)
+ {
+ case HistoryType.CashIn:
+ {
+ var cashinModel = (Antares.Service.History.Core.Domain.History.Cashin)baseHistoryRecord;
+ item.Type = GrpcContract.Common.HistoryType.CashIn;
+ item.CashIn = new CashInModel()
+ {
+ AssetId = cashinModel.AssetId,
+ BlockchainHash = cashinModel.BlockchainHash,
+ FeeSize = cashinModel.FeeSize,
+ Volume = cashinModel.Volume
+ };
+ break;
+ }
+ case HistoryType.CashOut:
+ {
+ var cashout = (Antares.Service.History.Core.Domain.History.Cashout)baseHistoryRecord;
+ item.Type = GrpcContract.Common.HistoryType.CashOut;
+ item.CashOut = new CashOutModel()
+ {
+ AssetId = cashout.AssetId,
+ BlockchainHash = cashout.BlockchainHash,
+ FeeSize = cashout.FeeSize,
+ Volume = cashout.Volume
+ };
+ break;
+ }
+ case HistoryType.Trade:
+ {
+ var trade = (Antares.Service.History.Core.Domain.History.Trade)baseHistoryRecord;
+ item.Type = GrpcContract.Common.HistoryType.Trade;
+ item.Trade = new TradeModel()
+ {
+ FeeSize = trade.FeeSize,
+ AssetPairId = trade.AssetPairId,
+ OrderId = trade.OrderId.ToString(),
+ BaseAssetId = trade.BaseAssetId,
+ BaseVolume = trade.BaseVolume,
+ FeeAssetId = trade.FeeAssetId,
+ Index = trade.Index,
+ Price = trade.Price,
+ QuotingAssetId = trade.QuotingAssetId,
+ QuotingVolume = trade.QuotingVolume,
+ Role = trade.Role switch
+ {
+ TradeRole.Unknown => GrpcContract.Common.TradeRole.Unknown,
+ TradeRole.Maker => GrpcContract.Common.TradeRole.Maker,
+ TradeRole.Taker => GrpcContract.Common.TradeRole.Taker,
+ _ => throw new ArgumentOutOfRangeException(nameof(trade.Role), trade.Role, null)
+ }
+ };
+ break;
+ }
+ case HistoryType.OrderEvent:
+ {
+ var orderEvent = (Antares.Service.History.Core.Domain.History.OrderEvent)baseHistoryRecord;
+ item.Type = GrpcContract.Common.HistoryType.OrderEvent;
+ item.OrderEvent = new OrderEventModel()
+ {
+ AssetPairId = orderEvent.AssetPairId,
+ OrderId = orderEvent.OrderId.ToString(),
+ Price = orderEvent.Price,
+ Status = orderEvent.Status switch
+ {
+ OrderStatus.Unknown => GrpcContract.Common.OrderStatus.UnknownOrder,
+ OrderStatus.Placed => GrpcContract.Common.OrderStatus.Placed,
+ OrderStatus.PartiallyMatched => GrpcContract.Common.OrderStatus.PartiallyMatched,
+ OrderStatus.Matched => GrpcContract.Common.OrderStatus.Matched,
+ OrderStatus.Pending => GrpcContract.Common.OrderStatus.Pending,
+ OrderStatus.Cancelled => GrpcContract.Common.OrderStatus.Cancelled,
+ OrderStatus.Replaced => GrpcContract.Common.OrderStatus.Replaced,
+ OrderStatus.Rejected => GrpcContract.Common.OrderStatus.Rejected,
+ _ => throw new ArgumentOutOfRangeException(nameof(orderEvent.Status), orderEvent.Status, null)
+ },
+ Volume = orderEvent.Volume
+ };
+ break;
+
+ }
+
+ default:
+ throw new ArgumentOutOfRangeException(nameof(baseHistoryRecord.Type), baseHistoryRecord.Type, null);
+ }
+
+ return item;
+ }
+
+ public static OrderModel MapOrder(Order order)
+ {
+ return new OrderModel()
+ {
+ Volume = order.Volume,
+ AssetPairId = order.AssetPairId,
+ CreateDt = order.CreateDt.ToUniversalTime().ToTimestamp(),
+ Id = order.Id.ToString(),
+ Type = order.Type switch
+ {
+ OrderType.Unknown => GrpcContract.Orders.OrderType.UnknownType,
+ OrderType.Market => GrpcContract.Orders.OrderType.Market,
+ OrderType.Limit => GrpcContract.Orders.OrderType.Limit,
+ OrderType.StopLimit => GrpcContract.Orders.OrderType.StopLimit,
+ _ => throw new ArgumentOutOfRangeException()
+ },
+ WalletId = order.WalletId.ToString(),
+ Status = order.Status switch
+ {
+ OrderStatus.Unknown => GrpcContract.Common.OrderStatus.UnknownOrder,
+ OrderStatus.Placed => GrpcContract.Common.OrderStatus.Placed,
+ OrderStatus.PartiallyMatched => GrpcContract.Common.OrderStatus.PartiallyMatched,
+ OrderStatus.Matched => GrpcContract.Common.OrderStatus.Matched,
+ OrderStatus.Pending => GrpcContract.Common.OrderStatus.Pending,
+ OrderStatus.Cancelled => GrpcContract.Common.OrderStatus.Cancelled,
+ OrderStatus.Replaced => GrpcContract.Common.OrderStatus.Replaced,
+ OrderStatus.Rejected => GrpcContract.Common.OrderStatus.Rejected,
+ _ => throw new ArgumentOutOfRangeException()
+ },
+ Price = order.Price,
+ LowerLimitPrice = order.LowerLimitPrice,
+ LowerPrice = order.LowerPrice,
+ MatchDt = order.MatchDt?.ToUniversalTime().ToTimestamp(),
+ MatchingId = order.MatchingId.ToString(),
+ RegisterDt = order.RegisterDt.ToUniversalTime().ToTimestamp(),
+ RejectReason = order.RejectReason,
+ RemainingVolume = order.RemainingVolume,
+ Side = order.Side switch
+ {
+ OrderSide.Unknown => GrpcContract.Orders.OrderSide.Unknown,
+ OrderSide.Buy => GrpcContract.Orders.OrderSide.Buy,
+ OrderSide.Sell => GrpcContract.Orders.OrderSide.Sell,
+ _ => throw new ArgumentOutOfRangeException()
+ },
+ StatusDt = order.StatusDt.ToUniversalTime().ToTimestamp(),
+ Straight = order.Straight,
+ UpperLimitPrice = order.UpperLimitPrice,
+ UpperPrice = order.UpperPrice
+ };
+ }
+
+ public static PaginationInt32 EnsurePagination(PaginationInt32 paginationInt32)
+ {
+ if (paginationInt32 == null)
+ {
+ return new PaginationInt32()
+ {
+ Limit = 1000,
+ Offset = 0
+ };
+ }
+
+ return paginationInt32;
+ }
+ }
+}
diff --git a/src/Antares.Service.History/GrpcServices/OrderService.cs b/src/Antares.Service.History/GrpcServices/OrderService.cs
new file mode 100644
index 0000000..0a62e9c
--- /dev/null
+++ b/src/Antares.Service.History/GrpcServices/OrderService.cs
@@ -0,0 +1,137 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.GrpcContract.Common;
+using Antares.Service.History.GrpcContract.Orders;
+using Antares.Service.History.GrpcServices.Mappers;
+using Grpc.Core;
+
+namespace Antares.Service.History.GrpcServices
+{
+ public class OrderService : Orders.OrdersBase
+ {
+ private readonly IOrdersRepository _ordersRepository;
+
+ public OrderService(IOrdersRepository ordersRepository)
+ {
+ _ordersRepository = ordersRepository;
+ }
+
+ public override async Task GetActiveOrders(GetActiveOrdersRequest request, ServerCallContext context)
+ {
+ var pagination = GrpcMapper.EnsurePagination(request.Pagination);
+ var data = await _ordersRepository.GetOrdersAsync(
+ Guid.Parse(request.WalletId),
+ new[] { Core.Domain.Enums.OrderType.Limit,
+ Core.Domain.Enums.OrderType.StopLimit },
+ new[] { Core.Domain.Enums.OrderStatus.Placed,
+ Core.Domain.Enums.OrderStatus.PartiallyMatched,
+ Core.Domain.Enums.OrderStatus.Pending },
+ request.AssetPairId,
+ pagination.Offset,
+ pagination.Limit);
+
+ var items = data.Select(x => GrpcMapper.MapOrder(x)).ToArray();
+
+ return new GetOrderListResponse
+ {
+ Items = { items },
+ Pagination = new PaginatedInt32Response
+ {
+ Count = items.Length,
+ Offset = pagination.Offset + items.Length,
+ }
+ };
+ }
+
+ public override async Task GetOrder(GetOrderRequest request, ServerCallContext context)
+ {
+ var order = await _ordersRepository.GetAsync(Guid.Parse(request.Id));
+
+ return new GetOrderResponse
+ {
+ Item = order == null ? null : GrpcMapper.MapOrder(order)
+ };
+ }
+
+ public override async Task GetOrderList(GetOrderListRequest request, ServerCallContext context)
+ {
+ var status = request.Status.ToArray();
+
+ if (status.Length == 0)
+ status = Enum.GetValues(typeof(OrderStatus)).Cast().ToArray();
+
+ var type = request.Type.ToArray();
+
+ if (type.Length == 0)
+ type = Enum.GetValues(typeof(OrderType)).Cast().ToArray();
+
+ var mappedType = type.Select(x => x switch
+ {
+ OrderType.UnknownType => Core.Domain.Enums.OrderType.Unknown,
+ OrderType.Market => Core.Domain.Enums.OrderType.Market,
+ OrderType.Limit => Core.Domain.Enums.OrderType.Limit,
+ OrderType.StopLimit => Core.Domain.Enums.OrderType.StopLimit,
+ _ => throw new ArgumentOutOfRangeException(nameof(x), x, null)
+ }).ToArray();
+
+ var mappedStatus = status.Select(x => x switch
+ {
+ OrderStatus.UnknownOrder => Core.Domain.Enums.OrderStatus.Unknown,
+ OrderStatus.Placed => Core.Domain.Enums.OrderStatus.Placed,
+ OrderStatus.PartiallyMatched => Core.Domain.Enums.OrderStatus.PartiallyMatched,
+ OrderStatus.Matched => Core.Domain.Enums.OrderStatus.Matched,
+ OrderStatus.Pending => Core.Domain.Enums.OrderStatus.Pending,
+ OrderStatus.Cancelled => Core.Domain.Enums.OrderStatus.Cancelled,
+ OrderStatus.Replaced => Core.Domain.Enums.OrderStatus.Replaced,
+ OrderStatus.Rejected => Core.Domain.Enums.OrderStatus.Rejected,
+ _ => throw new ArgumentOutOfRangeException(nameof(x), x, null)
+ }).ToArray();
+
+ var pagination = GrpcMapper.EnsurePagination(request.Pagination);
+
+ var data = await _ordersRepository.GetOrdersAsync(
+ Guid.Parse(request.WalletId),
+ mappedType,
+ mappedStatus,
+ request.AssetPairId,
+ pagination.Offset,
+ pagination.Limit);
+
+ var items = data.Select(GrpcMapper.MapOrder).ToArray();
+
+ return new GetOrderListResponse
+ {
+ Items = { items },
+ Pagination = new PaginatedInt32Response
+ {
+ Count = items.Length,
+ Offset = pagination.Offset + items.Length
+ }
+ };
+ }
+
+ public override async Task GetOrdersByDates(GetOrdersByDatesRequest request, ServerCallContext context)
+ {
+ var pagination = GrpcMapper.EnsurePagination(request.Pagination);
+ var data = await _ordersRepository.GetOrdersByDatesAsync(
+ request.From.ToDateTime(),
+ request.To.ToDateTime(),
+ pagination.Offset,
+ pagination.Limit);
+
+ var items = data.Select(GrpcMapper.MapOrder).ToArray();
+
+ return new GetOrderListResponse
+ {
+ Items = { items },
+ Pagination = new PaginatedInt32Response
+ {
+ Count = items.Length,
+ Offset = pagination.Offset + items.Length
+ }
+ };
+ }
+ }
+}
diff --git a/src/Antares.Service.History/GrpcServices/TradesService.cs b/src/Antares.Service.History/GrpcServices/TradesService.cs
new file mode 100644
index 0000000..48fdc0f
--- /dev/null
+++ b/src/Antares.Service.History/GrpcServices/TradesService.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.GrpcContract.Common;
+using Antares.Service.History.GrpcContract.Trades;
+using Antares.Service.History.GrpcServices.Mappers;
+using Grpc.Core;
+using GetTradesResponse = Antares.Service.History.GrpcContract.Trades.GetTradesResponse;
+using TradeType = Antares.Service.History.GrpcContract.Common.TradeType;
+
+namespace Antares.Service.History.GrpcServices
+{
+ public class TradesService : Trades.TradesBase
+ {
+ private readonly IOrdersRepository _ordersRepository;
+ private readonly IHistoryRecordsRepository _historyRecordsRepository;
+
+ public TradesService(
+ IOrdersRepository ordersRepository,
+ IHistoryRecordsRepository historyRecordsRepository)
+ {
+ _ordersRepository = ordersRepository;
+ _historyRecordsRepository = historyRecordsRepository;
+ }
+
+ public override async Task GetTrades(GetTradesRequest request, ServerCallContext context)
+ {
+ var tradeType = request.TradeType;
+ bool? onlyBuyTrades = null;
+ if (tradeType == GrpcContract.Common.TradeType.Buy)
+ onlyBuyTrades = true;
+ if (tradeType == TradeType.Sell)
+ onlyBuyTrades = false;
+
+ var pagination = GrpcMapper.EnsurePagination(request.Pagination);
+
+ var data = await _historyRecordsRepository
+ .GetTradesByWalletAsync(
+ Guid.Parse(request.WalletId),
+ pagination.Offset,
+ pagination.Limit,
+ request.AssetPairId,
+ request.AssetId,
+ request.From?.ToDateTime(),
+ request.To?.ToDateTime(),
+ onlyBuyTrades);
+
+ var items = data.Select(GrpcMapper.Map).ToArray();
+
+ return new GetTradesResponse()
+ {
+ Pagination = new PaginatedInt32Response()
+ {
+ Count = items.Length,
+ Offset = pagination.Offset + items.Length
+ },
+ Items = { items }
+ };
+ }
+
+ public override async Task GetTradesByDates(GetTradesByDatesRequest request, ServerCallContext context)
+ {
+ var pagination = GrpcMapper.EnsurePagination(request.Pagination);
+ var data = await _historyRecordsRepository.GetByDatesAsync(
+ request.From.ToDateTime(),
+ request.To.ToDateTime(),
+ pagination.Offset,
+ pagination.Limit);
+
+ var items = data.Select(GrpcMapper.Map).ToArray();
+
+ return new GetTradesResponse()
+ {
+ Pagination = new PaginatedInt32Response()
+ {
+ Count = items.Length,
+ Offset = pagination.Offset + items.Length
+ },
+ Items = { items }
+ };
+ }
+
+ public override async Task GetTradesByOrderId(GetTradesByOrderIdRequest request, ServerCallContext context)
+ {
+ var data = await _ordersRepository.GetTradesByOrderIdAsync(Guid.Parse(request.WalletId), Guid.Parse(request.Id));
+
+ var items = data.Select(GrpcMapper.Map).ToArray();
+
+ return new GetTradesResponse()
+ {
+ Pagination = new PaginatedInt32Response()
+ {
+ Count = items.Length,
+ Offset = items.Length
+ },
+ Items = { items }
+ };
+ }
+ }
+}
diff --git a/src/Lykke.Job.History/Modules/DbModule.cs b/src/Antares.Service.History/Modules/DbModule.cs
similarity index 67%
rename from src/Lykke.Job.History/Modules/DbModule.cs
rename to src/Antares.Service.History/Modules/DbModule.cs
index b6b26a7..580c579 100644
--- a/src/Lykke.Job.History/Modules/DbModule.cs
+++ b/src/Antares.Service.History/Modules/DbModule.cs
@@ -1,12 +1,12 @@
-using Autofac;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.History.Core.Settings;
-using Lykke.Service.History.PostgresRepositories;
-using Lykke.Service.History.PostgresRepositories.Repositories;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.Core.Settings;
+using Antares.Service.History.PostgresRepositories;
+using Antares.Service.History.PostgresRepositories.Repositories;
+using Autofac;
using Lykke.SettingsReader;
-namespace Lykke.Job.History.Modules
+namespace Antares.Service.History.Modules
{
public class DbModule : Module
{
diff --git a/src/Lykke.Job.History/Program.cs b/src/Antares.Service.History/Program.cs
similarity index 84%
rename from src/Lykke.Job.History/Program.cs
rename to src/Antares.Service.History/Program.cs
index 4710329..aca1884 100644
--- a/src/Lykke.Job.History/Program.cs
+++ b/src/Antares.Service.History/Program.cs
@@ -1,7 +1,7 @@
using System.Threading.Tasks;
-using Lykke.Sdk;
+using Antares.Sdk;
-namespace Lykke.Job.History
+namespace Antares.Service.History
{
internal sealed class Program
{
diff --git a/src/Lykke.Job.History/Properties/launchSettings.json b/src/Antares.Service.History/Properties/launchSettings.json
similarity index 64%
rename from src/Lykke.Job.History/Properties/launchSettings.json
rename to src/Antares.Service.History/Properties/launchSettings.json
index d44eaac..3482f85 100644
--- a/src/Lykke.Job.History/Properties/launchSettings.json
+++ b/src/Antares.Service.History/Properties/launchSettings.json
@@ -1,19 +1,18 @@
{
"profiles": {
- "History local dev settings": {
+ "History local test settings": {
"commandName": "Project",
"environmentVariables": {
- "ENV_INFO": "home",
- "SettingsUrl":
- "http://settingsv2.lykke-settings.svc.cluster.local/Home/RepositoryFile/c6462006-d3b2-44d9-9b47-0989b05700ea/Lykke.Service.History",
- "ASPNETCORE_ENVIRONMENT": "Development"
+ "SettingsUrl": "http://settingsv2.lykke-settings.svc.cluster.local/Home/RepositoryFile/c96b7a34-b21f-49b9-8b29-9c3cd395b584/Antares.Service.History",
+ "ASPNETCORE_ENVIRONMENT": "Staging"
}
},
- "History local test settings": {
+ "History local dev settings": {
"commandName": "Project",
"environmentVariables": {
- "SettingsUrl": "token_to_test_settings",
- "ASPNETCORE_ENVIRONMENT": "Staging"
+ "ENV_INFO": "home",
+ "SettingsUrl": "http://settingsv2.lykke-settings.svc.cluster.local/Home/RepositoryFile/79ab4c5c-fae6-480a-8742-d9b233addfd2/Lykke.Service.History",
+ "ASPNETCORE_ENVIRONMENT": "Development"
}
},
"History remote settings": {
diff --git a/src/Lykke.Service.History/Startup.cs b/src/Antares.Service.History/Startup.cs
similarity index 69%
rename from src/Lykke.Service.History/Startup.cs
rename to src/Antares.Service.History/Startup.cs
index 0852f75..008345d 100644
--- a/src/Lykke.Service.History/Startup.cs
+++ b/src/Antares.Service.History/Startup.cs
@@ -1,14 +1,18 @@
using System;
+using Antares.Sdk;
+using Antares.Service.History.AutoMapper;
+using Antares.Service.History.Core.Settings;
+using Antares.Service.History.GrpcServices;
+using Antares.Service.History.PostgresRepositories.Mappings;
+using Autofac;
using AutoMapper;
using JetBrains.Annotations;
-using Lykke.Sdk;
-using Lykke.Service.History.AutoMapper;
-using Lykke.Service.History.Core.Settings;
-using Lykke.Service.History.PostgresRepositories.Mappings;
+using Lykke.SettingsReader;
using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-namespace Lykke.Service.History
+namespace Antares.Service.History
{
[UsedImplicitly]
public class Startup
@@ -19,8 +23,21 @@ public class Startup
ApiVersion = "v1"
};
+ private LykkeServiceOptions _lykkeOptions;
+ private IReloadingManagerWithConfiguration _settings;
+
+ [UsedImplicitly]
+ public void ConfigureContainer(ContainerBuilder builder)
+ {
+ var configurationRoot = new ConfigurationBuilder()
+ .AddEnvironmentVariables()
+ .Build();
+
+ builder.ConfigureContainerBuilder(_lykkeOptions, configurationRoot, _settings);
+ }
+
[UsedImplicitly]
- public IServiceProvider ConfigureServices(IServiceCollection services)
+ public void ConfigureServices(IServiceCollection services)
{
Mapper.Initialize(cfg =>
{
@@ -28,10 +45,10 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
cfg.AddProfiles(typeof(RepositoryProfile));
});
- return services.BuildServiceProvider(options =>
+ (_lykkeOptions, _settings) = services.ConfigureServices(options =>
{
options.SwaggerOptions = _swaggerOptions;
-
+
options.Logs = logs =>
{
logs.AzureTableName = "HistoryLog";
@@ -77,7 +94,13 @@ public void Configure(IApplicationBuilder app)
app.UseLykkeConfiguration(options =>
{
options.SwaggerOptions = _swaggerOptions;
-
+ options.RegisterEndpoints = builder =>
+ {
+ builder.MapGrpcService();
+ builder.MapGrpcService();
+ builder.MapGrpcService();
+ builder.MapGrpcService();
+ };
// TODO: Configure additional middleware for eg authentication or maintenancemode checks
/*
options.WithMiddleware = x =>
diff --git a/src/Lykke.Job.History/AutoMapper/CashTransferConverter.cs b/src/Lykke.Job.History/AutoMapper/CashTransferConverter.cs
deleted file mode 100644
index f007101..0000000
--- a/src/Lykke.Job.History/AutoMapper/CashTransferConverter.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Collections.Generic;
-using AutoMapper;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-
-namespace Lykke.Job.History.AutoMapper
-{
- public class CashTransferConverter : ITypeConverter>
- {
- public IEnumerable Convert(CashTransferProcessedEvent source, IEnumerable destination,
- ResolutionContext context)
- {
- yield return new Cashout
- {
- Id = source.OperationId,
- WalletId = source.FromWalletId,
- Volume = -Math.Abs(source.Volume),
- Timestamp = source.Timestamp,
- AssetId = source.AssetId,
- FeeSize = source.FromWalletId == source.FeeSourceWalletId ? source.FeeSize : null,
- State = Service.History.Core.Domain.Enums.HistoryState.Finished
- };
-
- yield return new Cashin
- {
- Id = source.OperationId,
- WalletId = source.ToWalletId,
- Volume = Math.Abs(source.Volume),
- Timestamp = source.Timestamp,
- AssetId = source.AssetId,
- FeeSize = source.ToWalletId == source.FeeSourceWalletId ? source.FeeSize : null,
- State = Service.History.Core.Domain.Enums.HistoryState.Finished
- };
- }
- }
-}
diff --git a/src/Lykke.Job.History/AutoMapper/ExecutionConverter.cs b/src/Lykke.Job.History/AutoMapper/ExecutionConverter.cs
deleted file mode 100644
index 9559e6f..0000000
--- a/src/Lykke.Job.History/AutoMapper/ExecutionConverter.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System.Collections.Generic;
-using AutoMapper;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-
-namespace Lykke.Job.History.AutoMapper
-{
- public class ExecutionConverter : ITypeConverter>
- {
- public IEnumerable Convert(ExecutionProcessedEvent source, IEnumerable destination,
- ResolutionContext context)
- {
- foreach (var item in source.Orders)
- {
- var order = Mapper.Map(item);
-
- order.SequenceNumber = source.SequenceNumber;
-
- foreach (var trade in order.Trades)
- trade.OrderId = order.Id;
-
- yield return order;
- }
- }
- }
-}
diff --git a/src/Lykke.Job.History/AutoMapper/ServiceProfile.cs b/src/Lykke.Job.History/AutoMapper/ServiceProfile.cs
deleted file mode 100644
index 0b4de79..0000000
--- a/src/Lykke.Job.History/AutoMapper/ServiceProfile.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.Collections.Generic;
-using AutoMapper;
-using Lykke.Service.History.Contracts.Cqrs.Commands;
-using Lykke.Service.History.Contracts.History;
-using Lykke.Service.History.Core;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Models;
-using TradeModel = Lykke.Service.PostProcessing.Contracts.Cqrs.Models.TradeModel;
-
-namespace Lykke.Job.History.AutoMapper
-{
- public class ServiceProfile : Profile
- {
- public ServiceProfile()
- {
- CreateMap()
- .ForMember(x => x.Id, o => o.MapFrom(s => s.OperationId))
- .ForMember(x => x.State, o => o.UseValue(HistoryState.Finished))
- .ForMember(x => x.Volume, o => o.MapFrom(s => Math.Abs(s.Volume)));
-
- CreateMap()
- .ForMember(x => x.Id, o => o.MapFrom(s => s.OperationId))
- .ForMember(x => x.State, o => o.UseValue(HistoryState.Finished))
- .ForMember(x => x.Volume, o => o.MapFrom(s => -Math.Abs(s.Volume)));
-
- CreateMap>().ConvertUsing();
-
- CreateMap();
-
- CreateMap();
-
- CreateMap>().ConvertUsing();
-
- CreateMap()
- .ForMember(x => x.Status, o => o.UseValue(OrderStatus.Placed))
- .ForMember(x => x.Id, o => o.MapFrom(s => Utils.IncrementGuid(s.OrderId, (int)OrderStatus.Placed)))
- .ForMember(x => x.Timestamp, o => o.MapFrom(s => s.CreateDt));
-
- CreateMap()
- .ForMember(x => x.Status, o => o.UseValue(OrderStatus.Cancelled))
- .ForMember(x => x.Id, o => o.MapFrom(s => Utils.IncrementGuid(s.OrderId, (int)OrderStatus.Cancelled)));
-
- CreateMap()
- .ForMember(x => x.Id, o => o.MapFrom(s => s.OperationId))
- .ForMember(x => x.State, o => o.UseValue(HistoryState.Finished))
- .ForMember(x => x.Volume, o => o.MapFrom(s => Math.Abs(s.Volume)));
-
- CreateMap();
-
- CreateMap()
- .IncludeBase();
- CreateMap()
- .IncludeBase();
- CreateMap()
- .IncludeBase();
- CreateMap()
- .IncludeBase();
-
- CreateMap();
- }
- }
-}
diff --git a/src/Lykke.Job.History/Dockerfile b/src/Lykke.Job.History/Dockerfile
deleted file mode 100644
index 6b5a759..0000000
--- a/src/Lykke.Job.History/Dockerfile
+++ /dev/null
@@ -1,4 +0,0 @@
-FROM microsoft/dotnet:2.2-aspnetcore-runtime
-WORKDIR /app
-COPY . .
-ENTRYPOINT ["dotnet", "Lykke.Job.History.dll"]
diff --git a/src/Lykke.Job.History/StartupManager.cs b/src/Lykke.Job.History/StartupManager.cs
deleted file mode 100644
index 61fd349..0000000
--- a/src/Lykke.Job.History/StartupManager.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Threading.Tasks;
-using Lykke.Cqrs;
-using Lykke.Job.History.Workflow.ExecutionProcessing;
-using Lykke.Sdk;
-
-namespace Lykke.Job.History
-{
- public class StartupManager : IStartupManager
- {
- private readonly ICqrsEngine _cqrsEngine;
- private readonly ExecutionQueueReader _executionQueueReader;
- private readonly OrderEventQueueReader _orderEventQueueReader;
-
- public StartupManager(
- ICqrsEngine cqrsEngine,
- ExecutionQueueReader executionQueueReader,
- OrderEventQueueReader orderEventQueueReader
- )
- {
- _cqrsEngine = cqrsEngine;
- _executionQueueReader = executionQueueReader;
- _orderEventQueueReader = orderEventQueueReader;
- }
-
- public Task StartAsync()
- {
- _executionQueueReader.Start();
- _orderEventQueueReader.Start();
- _cqrsEngine.StartSubscribers();
-
- return Task.CompletedTask;
- }
- }
-}
diff --git a/src/Lykke.Job.History/Workflow/ExecutionProcessing/ExecutionQueueReader.cs b/src/Lykke.Job.History/Workflow/ExecutionProcessing/ExecutionQueueReader.cs
deleted file mode 100644
index e97508e..0000000
--- a/src/Lykke.Job.History/Workflow/ExecutionProcessing/ExecutionQueueReader.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using AutoMapper;
-using Common;
-using Lykke.Common.Log;
-using Lykke.RabbitMqBroker.Subscriber;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-using MoreLinq;
-using RabbitMQ.Client;
-using RabbitMQ.Client.Events;
-
-namespace Lykke.Job.History.Workflow.ExecutionProcessing
-{
- public class ExecutionQueueReader : BaseBatchQueueReader>
- {
- private const int TradesBulkSize = 5000;
-
- private readonly IHistoryRecordsRepository _historyRecordsRepository;
- private readonly IOrdersRepository _ordersRepository;
-
- public ExecutionQueueReader(
- ILogFactory logFactory,
- string connectionString,
- IHistoryRecordsRepository historyRecordsRepository,
- IOrdersRepository ordersRepository,
- int prefetchCount,
- int batchCount,
- IReadOnlyList walletIds)
- : base(logFactory, connectionString, prefetchCount, batchCount, walletIds)
- {
- _historyRecordsRepository = historyRecordsRepository;
- _ordersRepository = ordersRepository;
- }
-
- protected override string ExchangeName => $"lykke.{PostProcessingBoundedContext.Name}.events.exchange";
-
- protected override string QueueName => $"lykke.history.queue.{PostProcessingBoundedContext.Name}.events.execution-reader";
-
- protected override string[] RoutingKeys => new[] { nameof(ExecutionProcessedEvent) };
-
- protected override EventHandler CreateOnMessageReceivedEventHandler(IModel channel)
- {
- var deserializer = new ProtobufMessageDeserializer();
-
- void OnMessageReceived(object o, BasicDeliverEventArgs basicDeliverEventArgs)
- {
- try
- {
- var message = deserializer.Deserialize(basicDeliverEventArgs.Body);
-
- var orders = Mapper.Map>(message).ToList();
-
- foreach (var order in orders.Where(x => WalletIds.Contains(x.WalletId.ToString())))
- {
- Log.Info("Order from ME (ExecutionProcessedEvent)", context: $"order: {new {order.Id, order.Status, order.SequenceNumber}.ToJson()}");
- }
-
- Queue.Enqueue(new CustomQueueItem>(orders,
- basicDeliverEventArgs.DeliveryTag, channel));
- }
- catch (Exception e)
- {
- Log.Error(e);
-
- channel.BasicReject(basicDeliverEventArgs.DeliveryTag, false);
- }
- }
-
- return OnMessageReceived;
- }
-
- protected override async Task ProcessBatch(IList>> batch)
- {
- var orders = batch.SelectMany(x => x.Value).ToList();
- var batchId = Guid.NewGuid().ToString();
-
- foreach (var order in orders.Where(x => WalletIds.Contains(x.WalletId.ToString())))
- {
- Log.Info("Saving order (ProcessBatch)", context: $"order: {new {order.Id, order.Status, order.SequenceNumber, batchId}.ToJson()}");
- }
-
- await _ordersRepository.UpsertBulkAsync(orders);
-
- var trades = orders.SelectMany(x => x.Trades);
-
- var batched = trades.Batch(TradesBulkSize).ToList();
-
- foreach (var tradesBatch in batched)
- await _historyRecordsRepository.InsertBulkAsync(tradesBatch);
- }
-
- protected override void LogQueue()
- {
- while (Queue.Count > 0)
- {
- if (Queue.TryDequeue(out var item))
- {
- var orders = item.Value.Select(x => new {x.Id, x.Status, x.SequenceNumber}).ToList()
- .ToJson();
-
- Log.Info("Orders in queue on shutdown", context: $"orders: {orders}");
- }
- }
- }
- }
-}
diff --git a/src/Lykke.Job.History/Workflow/ExecutionProcessing/OrderEventQueueReader.cs b/src/Lykke.Job.History/Workflow/ExecutionProcessing/OrderEventQueueReader.cs
deleted file mode 100644
index 394be91..0000000
--- a/src/Lykke.Job.History/Workflow/ExecutionProcessing/OrderEventQueueReader.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using AutoMapper;
-using Common;
-using Lykke.Common.Log;
-using Lykke.RabbitMqBroker.Subscriber;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-using RabbitMQ.Client;
-using RabbitMQ.Client.Events;
-
-namespace Lykke.Job.History.Workflow.ExecutionProcessing
-{
- public class OrderEventQueueReader : BaseBatchQueueReader
- {
- private readonly IHistoryRecordsRepository _historyRecordsRepository;
-
- public OrderEventQueueReader(
- ILogFactory logFactory,
- string connectionString,
- IHistoryRecordsRepository historyRecordsRepository,
- int prefetchCount,
- int batchCount,
- IReadOnlyList walletIds)
- : base(logFactory, connectionString, prefetchCount, batchCount, walletIds)
- {
- _historyRecordsRepository = historyRecordsRepository;
- }
-
- protected override string ExchangeName => $"lykke.{PostProcessingBoundedContext.Name}.events.exchange";
-
- protected override string QueueName => $"lykke.history.queue.{PostProcessingBoundedContext.Name}.events.order-event-reader";
-
- protected override string[] RoutingKeys => new[] { nameof(OrderPlacedEvent), nameof(OrderCancelledEvent) };
-
- protected override EventHandler CreateOnMessageReceivedEventHandler(IModel channel)
- {
- var orderPlacedDeserializer = new ProtobufMessageDeserializer();
- var orderCancelledDeserializer = new ProtobufMessageDeserializer();
-
- void OnMessageReceived(object o, BasicDeliverEventArgs basicDeliverEventArgs)
- {
- try
- {
- switch (basicDeliverEventArgs.RoutingKey)
- {
- case nameof(OrderPlacedEvent):
- Queue.Enqueue(new CustomQueueItem(
- Mapper.Map(
- orderPlacedDeserializer.Deserialize(basicDeliverEventArgs.Body)),
- basicDeliverEventArgs.DeliveryTag, channel));
- break;
- case nameof(OrderCancelledEvent):
- Queue.Enqueue(new CustomQueueItem(
- Mapper.Map(
- orderCancelledDeserializer.Deserialize(basicDeliverEventArgs.Body)),
- basicDeliverEventArgs.DeliveryTag, channel));
- break;
- default:
- throw new ArgumentOutOfRangeException(basicDeliverEventArgs.RoutingKey);
- }
-
- }
- catch (Exception e)
- {
- Log.Error(e);
-
- channel.BasicReject(basicDeliverEventArgs.DeliveryTag, false);
- }
- }
-
- return OnMessageReceived;
- }
-
- protected override Task ProcessBatch(IList> batch)
- {
- return _historyRecordsRepository.InsertBulkAsync(batch.Select(x => x.Value));
- }
-
- protected override void LogQueue()
- {
- while (Queue.Count > 0)
- {
- if (Queue.TryDequeue(out var item))
- {
- var order = $"order: {new {item.Value.Id, item.Value.Status}.ToJson()}";
-
- Log.Info("Orders in queue on shutdown", context: order);
- }
- }
- }
- }
-}
diff --git a/src/Lykke.Job.History/Workflow/Projections/CashInProjection.cs b/src/Lykke.Job.History/Workflow/Projections/CashInProjection.cs
deleted file mode 100644
index e84a53b..0000000
--- a/src/Lykke.Job.History/Workflow/Projections/CashInProjection.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Threading.Tasks;
-using AutoMapper;
-using Common.Log;
-using Lykke.Common.Log;
-using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-
-namespace Lykke.Job.History.Workflow.Projections
-{
- public class CashInProjection
- {
- private readonly IHistoryRecordsRepository _historyRecordsRepository;
- private readonly ILog _logger;
-
- public CashInProjection(IHistoryRecordsRepository historyRecordsRepository, ILogFactory logFactory)
- {
- _historyRecordsRepository = historyRecordsRepository;
- _logger = logFactory.CreateLog(this);
- }
-
- public async Task Handle(CashInProcessedEvent @event)
- {
- var entity = Mapper.Map(@event);
-
- if (!await _historyRecordsRepository.TryInsertAsync(entity))
- _logger.Warning($"Skipped duplicated cashin record", context: new
- {
- id = @event.OperationId
- });
-
- return CommandHandlingResult.Ok();
- }
- }
-}
diff --git a/src/Lykke.Job.History/Workflow/Projections/CashOutProjection.cs b/src/Lykke.Job.History/Workflow/Projections/CashOutProjection.cs
deleted file mode 100644
index de9d27a..0000000
--- a/src/Lykke.Job.History/Workflow/Projections/CashOutProjection.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Threading.Tasks;
-using AutoMapper;
-using Common.Log;
-using Lykke.Common.Log;
-using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-
-namespace Lykke.Job.History.Workflow.Projections
-{
- public class CashOutProjection
- {
- private readonly IHistoryRecordsRepository _historyRecordsRepository;
- private readonly ILog _logger;
-
- public CashOutProjection(IHistoryRecordsRepository historyRecordsRepository, ILogFactory logFactory)
- {
- _historyRecordsRepository = historyRecordsRepository;
- _logger = logFactory.CreateLog(this);
- }
-
- public async Task Handle(CashOutProcessedEvent @event)
- {
- var entity = Mapper.Map(@event);
-
- if (!await _historyRecordsRepository.TryInsertAsync(entity))
- _logger.Warning($"Skipped duplicated cashout record", context: new
- {
- id = @event.OperationId
- });
-
- return CommandHandlingResult.Ok();
- }
- }
-}
diff --git a/src/Lykke.Job.History/Workflow/Projections/CashTransferProjection.cs b/src/Lykke.Job.History/Workflow/Projections/CashTransferProjection.cs
deleted file mode 100644
index 627b436..0000000
--- a/src/Lykke.Job.History/Workflow/Projections/CashTransferProjection.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using Common.Log;
-using Lykke.Common.Log;
-using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-
-namespace Lykke.Job.History.Workflow.Projections
-{
- public class CashTransferProjection
- {
- private readonly IHistoryRecordsRepository _historyRecordsRepository;
- private readonly ILog _logger;
-
- public CashTransferProjection(IHistoryRecordsRepository historyRecordsRepository, ILogFactory logFactory)
- {
- _historyRecordsRepository = historyRecordsRepository;
- _logger = logFactory.CreateLog(this);
- }
-
- public async Task Handle(CashTransferProcessedEvent @event)
- {
- var cashInOuts = Mapper.Map>(@event);
-
- foreach (var cashInOut in cashInOuts)
- if (!await _historyRecordsRepository.TryInsertAsync(cashInOut))
- _logger.Warning($"Skipped duplicated transfer record", context: new
- {
- id = @event.OperationId
- });
-
- return CommandHandlingResult.Ok();
- }
- }
-}
diff --git a/src/Lykke.Service.History/Dockerfile b/src/Lykke.Service.History/Dockerfile
deleted file mode 100644
index a8efdd2..0000000
--- a/src/Lykke.Service.History/Dockerfile
+++ /dev/null
@@ -1,4 +0,0 @@
-FROM microsoft/dotnet:2.2-aspnetcore-runtime
-WORKDIR /app
-COPY . .
-ENTRYPOINT ["dotnet", "Lykke.Service.History.dll"]
diff --git a/tests/Antares.Service.History.Tests/Antares.Service.History.Tests.csproj b/tests/Antares.Service.History.Tests/Antares.Service.History.Tests.csproj
new file mode 100644
index 0000000..95367bc
--- /dev/null
+++ b/tests/Antares.Service.History.Tests/Antares.Service.History.Tests.csproj
@@ -0,0 +1,23 @@
+
+
+ net5.0
+ 1.0.0
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Antares.Service.History.Tests/CashinTests.cs b/tests/Antares.Service.History.Tests/CashinTests.cs
new file mode 100644
index 0000000..5e3c9b7
--- /dev/null
+++ b/tests/Antares.Service.History.Tests/CashinTests.cs
@@ -0,0 +1,66 @@
+//using System;
+//using System.Threading.Tasks;
+//using Antares.Service.History.Core.Domain.History;
+//using Antares.Service.History.Tests.Init;
+//using Autofac;
+//using Lykke.Cqrs;
+//using Lykke.Service.PostProcessing.Contracts.Cqrs;
+//using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
+//using Xunit;
+
+//namespace Antares.Service.History.Tests
+//{
+// [Collection("history-tests")]
+// public class CashinTests
+// {
+// public CashinTests(TestInitialization initialization)
+// {
+// _container = initialization.Container;
+// }
+
+// private readonly IContainer _container;
+
+// private CashInProcessedEvent CreateCashinRecord()
+// {
+// var cqrs = _container.Resolve();
+
+// var id = Guid.NewGuid();
+// var clientId = Guid.NewGuid();
+// var volume = 54.31M;
+
+// var @event = new CashInProcessedEvent
+// {
+// OperationId = id,
+// WalletId = clientId,
+// Volume = volume,
+// AssetId = "EUR",
+// Timestamp = DateTime.UtcNow,
+// FeeSize = 10
+// };
+
+// cqrs.PublishEvent(@event, PostProcessingBoundedContext.Name);
+
+// return @event;
+// }
+
+// [Fact]
+// public async Task SaveCashin_Test()
+// {
+// var command = CreateCashinRecord();
+
+// await Task.Delay(3000);
+
+// var repo = _container.Resolve();
+
+// var item = await repo.GetAsync(command.OperationId, command.WalletId);
+
+// Assert.NotNull(item);
+// Assert.True(item is Cashin);
+
+// var cashin = item as Cashin;
+
+// Assert.Equal(command.FeeSize, cashin.FeeSize);
+// Assert.Equal(Math.Abs(command.Volume), cashin.Volume);
+// }
+// }
+//}
diff --git a/tests/Antares.Service.History.Tests/CashoutTests.cs b/tests/Antares.Service.History.Tests/CashoutTests.cs
new file mode 100644
index 0000000..351108b
--- /dev/null
+++ b/tests/Antares.Service.History.Tests/CashoutTests.cs
@@ -0,0 +1,61 @@
+//using System;
+//using System.Threading.Tasks;
+//using Antares.Service.History.Core.Domain.History;
+//using Antares.Service.History.Tests.Init;
+//using Autofac;
+//using Lykke.Cqrs;
+//using Lykke.Service.PostProcessing.Contracts.Cqrs;
+//using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
+//using Xunit;
+
+//namespace Antares.Service.History.Tests
+//{
+// [Collection("history-tests")]
+// public class CashoutTests
+// {
+// public CashoutTests(TestInitialization initialization)
+// {
+// _container = initialization.Container;
+// }
+
+// private readonly IContainer _container;
+
+// private CashOutProcessedEvent CreateCashoutRecord()
+// {
+// var cqrs = _container.Resolve();
+
+// var id = Guid.NewGuid();
+// var clientId = Guid.NewGuid();
+// var volume = 54.31M;
+
+// var @event = new CashOutProcessedEvent
+// {
+// OperationId = id,
+// WalletId = clientId,
+// Volume = volume,
+// AssetId = "EUR",
+// Timestamp = DateTime.UtcNow
+// };
+
+// cqrs.PublishEvent(@event, PostProcessingBoundedContext.Name);
+
+// return @event;
+// }
+
+// [Fact]
+// public async Task SaveCashout_Test()
+// {
+// var command = CreateCashoutRecord();
+
+// await Task.Delay(3000);
+
+// var repo = _container.Resolve();
+
+// var item = await repo.GetAsync(command.OperationId, command.WalletId);
+
+// Assert.NotNull(item);
+// Assert.True(item is Cashout);
+// Assert.Equal(-Math.Abs(command.Volume), (item as Cashout).Volume);
+// }
+// }
+//}
diff --git a/tests/Lykke.Service.History.Tests/ForwardWithdrawalTests.cs b/tests/Antares.Service.History.Tests/ForwardWithdrawalTests.cs
similarity index 90%
rename from tests/Lykke.Service.History.Tests/ForwardWithdrawalTests.cs
rename to tests/Antares.Service.History.Tests/ForwardWithdrawalTests.cs
index d23997a..292623b 100644
--- a/tests/Lykke.Service.History.Tests/ForwardWithdrawalTests.cs
+++ b/tests/Antares.Service.History.Tests/ForwardWithdrawalTests.cs
@@ -1,14 +1,14 @@
using System;
using System.Threading.Tasks;
+using Antares.Service.History.Contracts.Cqrs;
+using Antares.Service.History.Contracts.Cqrs.Commands;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Tests.Init;
using Autofac;
using Lykke.Cqrs;
-using Lykke.Service.History.Contracts.Cqrs;
-using Lykke.Service.History.Contracts.Cqrs.Commands;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Tests.Init;
using Xunit;
-namespace Lykke.Service.History.Tests
+namespace Antares.Service.History.Tests
{
[Collection("history-tests")]
public class ForwardWithdrawalTests
diff --git a/tests/Lykke.Service.History.Tests/Init/InMemoryHistoryRepository.cs b/tests/Antares.Service.History.Tests/Init/InMemoryHistoryRepository.cs
similarity index 96%
rename from tests/Lykke.Service.History.Tests/Init/InMemoryHistoryRepository.cs
rename to tests/Antares.Service.History.Tests/Init/InMemoryHistoryRepository.cs
index bc47ed5..6d4cb22 100644
--- a/tests/Lykke.Service.History.Tests/Init/InMemoryHistoryRepository.cs
+++ b/tests/Antares.Service.History.Tests/Init/InMemoryHistoryRepository.cs
@@ -2,11 +2,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
using AutoMapper;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-namespace Lykke.Service.History.Tests.Init
+namespace Antares.Service.History.Tests.Init
{
public class InMemoryHistoryRepository : IHistoryRecordsRepository
{
diff --git a/tests/Lykke.Service.History.Tests/Init/InMemoryOrdersRepository.cs b/tests/Antares.Service.History.Tests/Init/InMemoryOrdersRepository.cs
similarity index 93%
rename from tests/Lykke.Service.History.Tests/Init/InMemoryOrdersRepository.cs
rename to tests/Antares.Service.History.Tests/Init/InMemoryOrdersRepository.cs
index 0d55a18..1486b55 100644
--- a/tests/Lykke.Service.History.Tests/Init/InMemoryOrdersRepository.cs
+++ b/tests/Antares.Service.History.Tests/Init/InMemoryOrdersRepository.cs
@@ -2,13 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
using Common;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
using Newtonsoft.Json;
-namespace Lykke.Service.History.Tests.Init
+namespace Antares.Service.History.Tests.Init
{
public class InMemoryOrdersRepository : IOrdersRepository
{
diff --git a/tests/Lykke.Service.History.Tests/Init/TestInitialization.cs b/tests/Antares.Service.History.Tests/Init/TestInitialization.cs
similarity index 70%
rename from tests/Lykke.Service.History.Tests/Init/TestInitialization.cs
rename to tests/Antares.Service.History.Tests/Init/TestInitialization.cs
index d82762a..98a15c0 100644
--- a/tests/Lykke.Service.History.Tests/Init/TestInitialization.cs
+++ b/tests/Antares.Service.History.Tests/Init/TestInitialization.cs
@@ -1,31 +1,28 @@
using System;
using System.Collections.Generic;
+using Antares.Job.History.Workflow.Handlers;
+using Antares.Job.History.Workflow.Projections;
+using Antares.Service.History.Contracts.Cqrs;
+using Antares.Service.History.Contracts.Cqrs.Commands;
+using Antares.Service.History.Contracts.Cqrs.Events;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.Core.Settings;
+using Antares.Service.History.Modules;
+using Antares.Service.History.PostgresRepositories.Mappings;
using Autofac;
using AutoMapper;
using Lykke.Common.Log;
using Lykke.Cqrs;
using Lykke.Cqrs.Configuration;
-using Lykke.Job.History.Workflow.Handlers;
-using Lykke.Job.History.Workflow.Projections;
using Lykke.Logs;
using Lykke.Logs.Loggers.LykkeConsole;
using Lykke.Messaging;
using Lykke.Messaging.Contract;
-using Lykke.Service.History.AutoMapper;
-using Lykke.Service.History.Contracts.Cqrs;
-using Lykke.Service.History.Contracts.Cqrs.Commands;
-using Lykke.Service.History.Contracts.Cqrs.Events;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.History.Core.Settings;
-using Lykke.Service.History.Modules;
-using Lykke.Service.History.PostgresRepositories.Mappings;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
using Lykke.SettingsReader.ReloadingManager;
using Xunit;
-namespace Lykke.Service.History.Tests.Init
+namespace Antares.Service.History.Tests.Init
{
[CollectionDefinition("history-tests")]
public class TestInitializationCollection : ICollectionFixture
@@ -38,7 +35,7 @@ static TestInitialization()
{
Mapper.Initialize(cfg =>
{
- cfg.AddProfiles(typeof(Lykke.Job.History.AutoMapper.ServiceProfile));
+ cfg.AddProfiles(typeof(Antares.Job.History.AutoMapper.ServiceProfile));
cfg.AddProfiles(typeof(RepositoryProfile));
});
}
@@ -59,10 +56,6 @@ public IContainer CreateContainer()
builder.Register(context => new AutofacDependencyResolver(context)).As()
.SingleInstance();
- builder.RegisterType();
- builder.RegisterType();
- builder.RegisterType();
-
builder.RegisterType();
builder.Register(ctx =>
@@ -132,19 +125,6 @@ private CqrsEngine CreateEngine(
new DefaultEndpointProvider(),
true,
Register.DefaultEndpointResolver(new InMemoryEndpointResolver()),
- Register.BoundedContext(PostProcessingBoundedContext.Name)
- .PublishingEvents(typeof(CashInProcessedEvent))
- .With(defaultRoute)
- .WithLoopback()
- .WithProjection(typeof(CashInProjection), PostProcessingBoundedContext.Name)
- .PublishingEvents(typeof(CashOutProcessedEvent))
- .With(defaultRoute)
- .WithLoopback()
- .WithProjection(typeof(CashOutProjection), PostProcessingBoundedContext.Name)
- .PublishingEvents(typeof(CashTransferProcessedEvent))
- .With(defaultRoute)
- .WithLoopback()
- .WithProjection(typeof(CashTransferProjection), PostProcessingBoundedContext.Name),
Register.BoundedContext(HistoryBoundedContext.Name)
.ListeningCommands(typeof(CreateForwardCashinCommand), typeof(DeleteForwardCashinCommand))
diff --git a/tests/Lykke.Service.History.Tests/PostgresTests.cs b/tests/Antares.Service.History.Tests/PostgresTests.cs
similarity index 94%
rename from tests/Lykke.Service.History.Tests/PostgresTests.cs
rename to tests/Antares.Service.History.Tests/PostgresTests.cs
index 5e45e84..a504e8b 100644
--- a/tests/Lykke.Service.History.Tests/PostgresTests.cs
+++ b/tests/Antares.Service.History.Tests/PostgresTests.cs
@@ -2,15 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using Antares.Service.History.Core.Domain.Enums;
+using Antares.Service.History.Core.Domain.History;
+using Antares.Service.History.Core.Domain.Orders;
+using Antares.Service.History.Tests.Init;
using Autofac;
-using Lykke.Service.History.Core.Domain.Enums;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Core.Domain.Orders;
-using Lykke.Service.History.Tests.Init;
using MoreLinq;
using Xunit;
-namespace Lykke.Service.History.Tests
+namespace Antares.Service.History.Tests
{
[Collection("history-tests")]
public class PostgresTests
@@ -23,7 +23,7 @@ public PostgresTests(TestInitialization initialization)
private readonly IContainer _container;
- private async Task<(Guid, List)> GenerateData(string[] pairs, string[] assets)
+ private async Task<(Guid, List)> GenerateData(string[] pairs, string[] assets)
{
var walletId = Guid.NewGuid();
var random = new Random();
@@ -129,7 +129,7 @@ Trade GetTrade()
Straight = true,
Type = (OrderType) random.Next(0, 4),
WalletId = walletId,
- Trades = Enumerable.Range(1, random.Next(1, 20)).Select(x => GetTrade()).ToList()
+ Trades = Enumerable.Range(1, random.Next(1, 20)).Select(x => GetTrade()).ToArray()
};
return orderModel;
diff --git a/tests/Antares.Service.History.Tests/TransferTests.cs b/tests/Antares.Service.History.Tests/TransferTests.cs
new file mode 100644
index 0000000..95803dd
--- /dev/null
+++ b/tests/Antares.Service.History.Tests/TransferTests.cs
@@ -0,0 +1,77 @@
+//using System;
+//using System.Threading.Tasks;
+//using Antares.Service.History.Core.Domain.History;
+//using Antares.Service.History.Tests.Init;
+//using Autofac;
+//using Lykke.Cqrs;
+//using Lykke.Service.PostProcessing.Contracts.Cqrs;
+//using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
+//using Xunit;
+
+//namespace Antares.Service.History.Tests
+//{
+// [Collection("history-tests")]
+// public class TransferTests
+// {
+// public TransferTests(TestInitialization initialization)
+// {
+// _container = initialization.Container;
+// }
+
+// private readonly IContainer _container;
+
+// private CashTransferProcessedEvent CreateTransferRecord()
+// {
+// var cqrs = _container.Resolve();
+
+// var id = Guid.NewGuid();
+// var walletFrom = Guid.NewGuid();
+// var walletTo = Guid.NewGuid();
+// var volume = new Random().Next(1, 100);
+
+// var @event = new CashTransferProcessedEvent
+// {
+// OperationId = id,
+// FromWalletId = walletFrom,
+// ToWalletId = walletTo,
+// Volume = volume,
+// AssetId = "EUR",
+// Timestamp = DateTime.UtcNow,
+// FeeSize = 0.5M,
+// FeeSourceWalletId = walletTo
+// };
+
+// cqrs.PublishEvent(@event, PostProcessingBoundedContext.Name);
+
+// return @event;
+// }
+
+// [Fact]
+// public async Task SaveTransfer_Test()
+// {
+// var command = CreateTransferRecord();
+
+// await Task.Delay(3000);
+
+// var repo = _container.Resolve();
+
+// var itemFrom = await repo.GetAsync(command.OperationId, command.FromWalletId);
+// var itemTo = await repo.GetAsync(command.OperationId, command.ToWalletId);
+
+// Assert.NotNull(itemFrom);
+// Assert.NotNull(itemTo);
+
+// Assert.True(itemFrom is Cashout);
+// Assert.True(itemTo is Cashin);
+
+// var transferFrom = itemFrom as Cashout;
+// var transferTo = itemTo as Cashin;
+
+// Assert.Equal(-Math.Abs(command.Volume), transferFrom.Volume);
+// Assert.Equal(Math.Abs(command.Volume), transferTo.Volume);
+
+// Assert.Null(transferFrom.FeeSize);
+// Assert.Equal(command.FeeSize, transferTo.FeeSize);
+// }
+// }
+//}
diff --git a/tests/Lykke.Service.History.Tests/UtilsTests.cs b/tests/Antares.Service.History.Tests/UtilsTests.cs
similarity index 90%
rename from tests/Lykke.Service.History.Tests/UtilsTests.cs
rename to tests/Antares.Service.History.Tests/UtilsTests.cs
index d53c9f5..8262067 100644
--- a/tests/Lykke.Service.History.Tests/UtilsTests.cs
+++ b/tests/Antares.Service.History.Tests/UtilsTests.cs
@@ -1,11 +1,8 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Text.RegularExpressions;
-using Lykke.Service.History.Core;
+using Antares.Service.History.Core;
using Xunit;
-namespace Lykke.Service.History.Tests
+namespace Antares.Service.History.Tests
{
public class UtilsTests
{
diff --git a/tests/ConsoleTest/ConsoleTest.csproj b/tests/ConsoleTest/ConsoleTest.csproj
new file mode 100644
index 0000000..7684d2b
--- /dev/null
+++ b/tests/ConsoleTest/ConsoleTest.csproj
@@ -0,0 +1,13 @@
+
+
+
+ Exe
+ netcoreapp3.1
+
+
+
+
+
+
+
+
diff --git a/tests/ConsoleTest/Program.cs b/tests/ConsoleTest/Program.cs
new file mode 100644
index 0000000..cc18087
--- /dev/null
+++ b/tests/ConsoleTest/Program.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using Antares.Service.History.GrpcClient;
+using Antares.Service.History.GrpcContract.Common;
+using Antares.Service.History.GrpcContract.History;
+using Antares.Service.History.GrpcContract.Orders;
+using Antares.Service.History.GrpcContract.Trades;
+
+namespace ConsoleTest
+{
+ class Program
+ {
+ static async Task Main(string[] args)
+ {
+ Console.WriteLine("PRESS ENTER TO START!");
+ Console.ReadLine();
+
+ var client = new HistoryGrpcClient("http://history.lykke-service.svc.cluster.local:5001");//"http://localhost:5001");
+
+ var ordersByDates = await client.Orders.GetOrdersByDatesAsync(new GetOrdersByDatesRequest()
+ {
+ Pagination = new PaginationInt32()
+ {
+ Limit = 100,
+ Offset = 0
+ }
+ });
+
+ var walletId = ordersByDates.Items.First().WalletId;
+
+ var orders = await client.Orders.GetOrderListAsync(new GetOrderListRequest()
+ {
+ WalletId = walletId
+ });
+
+ var order = await client.Orders.GetOrderAsync(new GetOrderRequest()
+ {
+ Id = orders.Items.First().Id
+ });
+
+ //var walletId = "608138d9-f3d7-4715-a2d1-9d8f3384d6dd";
+ var history = await client.History.GetHistoryAsync(new HistoryGetHistoryRequest()
+ {
+ Pagination = new PaginationInt32()
+ {
+ Limit = 100,
+ Offset = 0
+ },
+ AssetPairId = "EURCHF",
+ WalletId = walletId
+ });
+
+ var hist1 = history.Items.First();
+ var historyItem = await client.History.GetHistoryItemAsync(new GetHistoryItemRequest() { WalletId = hist1.WalletId, Id = hist1.Id });
+
+ var activeOrders = await client.Orders.GetActiveOrdersAsync(new GetActiveOrdersRequest() {WalletId = walletId});
+
+ var trades = await client.Trades.GetTradesAsync(new GetTradesRequest() {WalletId = walletId});
+
+ var trades1 = await client.Trades.GetTradesByOrderIdAsync(new GetTradesByOrderIdRequest()
+ {
+ WalletId = walletId,
+ Id = order.Item.Id
+ });
+ }
+ }
+}
diff --git a/tests/Lykke.Service.History.Tests/CashinTests.cs b/tests/Lykke.Service.History.Tests/CashinTests.cs
deleted file mode 100644
index 53e6a70..0000000
--- a/tests/Lykke.Service.History.Tests/CashinTests.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Autofac;
-using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Tests.Init;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-using Xunit;
-
-namespace Lykke.Service.History.Tests
-{
- [Collection("history-tests")]
- public class CashinTests
- {
- public CashinTests(TestInitialization initialization)
- {
- _container = initialization.Container;
- }
-
- private readonly IContainer _container;
-
- private CashInProcessedEvent CreateCashinRecord()
- {
- var cqrs = _container.Resolve();
-
- var id = Guid.NewGuid();
- var clientId = Guid.NewGuid();
- var volume = 54.31M;
-
- var @event = new CashInProcessedEvent
- {
- OperationId = id,
- WalletId = clientId,
- Volume = volume,
- AssetId = "EUR",
- Timestamp = DateTime.UtcNow,
- FeeSize = 10
- };
-
- cqrs.PublishEvent(@event, PostProcessingBoundedContext.Name);
-
- return @event;
- }
-
- [Fact]
- public async Task SaveCashin_Test()
- {
- var command = CreateCashinRecord();
-
- await Task.Delay(3000);
-
- var repo = _container.Resolve();
-
- var item = await repo.GetAsync(command.OperationId, command.WalletId);
-
- Assert.NotNull(item);
- Assert.True(item is Cashin);
-
- var cashin = item as Cashin;
-
- Assert.Equal(command.FeeSize, cashin.FeeSize);
- Assert.Equal(Math.Abs(command.Volume), cashin.Volume);
- }
- }
-}
diff --git a/tests/Lykke.Service.History.Tests/CashoutTests.cs b/tests/Lykke.Service.History.Tests/CashoutTests.cs
deleted file mode 100644
index ff8a421..0000000
--- a/tests/Lykke.Service.History.Tests/CashoutTests.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Autofac;
-using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Tests.Init;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-using Xunit;
-
-namespace Lykke.Service.History.Tests
-{
- [Collection("history-tests")]
- public class CashoutTests
- {
- public CashoutTests(TestInitialization initialization)
- {
- _container = initialization.Container;
- }
-
- private readonly IContainer _container;
-
- private CashOutProcessedEvent CreateCashoutRecord()
- {
- var cqrs = _container.Resolve();
-
- var id = Guid.NewGuid();
- var clientId = Guid.NewGuid();
- var volume = 54.31M;
-
- var @event = new CashOutProcessedEvent
- {
- OperationId = id,
- WalletId = clientId,
- Volume = volume,
- AssetId = "EUR",
- Timestamp = DateTime.UtcNow
- };
-
- cqrs.PublishEvent(@event, PostProcessingBoundedContext.Name);
-
- return @event;
- }
-
- [Fact]
- public async Task SaveCashout_Test()
- {
- var command = CreateCashoutRecord();
-
- await Task.Delay(3000);
-
- var repo = _container.Resolve();
-
- var item = await repo.GetAsync(command.OperationId, command.WalletId);
-
- Assert.NotNull(item);
- Assert.True(item is Cashout);
- Assert.Equal(-Math.Abs(command.Volume), (item as Cashout).Volume);
- }
- }
-}
diff --git a/tests/Lykke.Service.History.Tests/Lykke.Service.History.Tests.csproj b/tests/Lykke.Service.History.Tests/Lykke.Service.History.Tests.csproj
deleted file mode 100644
index d33bc41..0000000
--- a/tests/Lykke.Service.History.Tests/Lykke.Service.History.Tests.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
- netcoreapp2.2
- 1.0.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/Lykke.Service.History.Tests/TransferTests.cs b/tests/Lykke.Service.History.Tests/TransferTests.cs
deleted file mode 100644
index 54cae22..0000000
--- a/tests/Lykke.Service.History.Tests/TransferTests.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Autofac;
-using Lykke.Cqrs;
-using Lykke.Service.History.Core.Domain.History;
-using Lykke.Service.History.Tests.Init;
-using Lykke.Service.PostProcessing.Contracts.Cqrs;
-using Lykke.Service.PostProcessing.Contracts.Cqrs.Events;
-using Xunit;
-
-namespace Lykke.Service.History.Tests
-{
- [Collection("history-tests")]
- public class TransferTests
- {
- public TransferTests(TestInitialization initialization)
- {
- _container = initialization.Container;
- }
-
- private readonly IContainer _container;
-
- private CashTransferProcessedEvent CreateTransferRecord()
- {
- var cqrs = _container.Resolve();
-
- var id = Guid.NewGuid();
- var walletFrom = Guid.NewGuid();
- var walletTo = Guid.NewGuid();
- var volume = new Random().Next(1, 100);
-
- var @event = new CashTransferProcessedEvent
- {
- OperationId = id,
- FromWalletId = walletFrom,
- ToWalletId = walletTo,
- Volume = volume,
- AssetId = "EUR",
- Timestamp = DateTime.UtcNow,
- FeeSize = 0.5M,
- FeeSourceWalletId = walletTo
- };
-
- cqrs.PublishEvent(@event, PostProcessingBoundedContext.Name);
-
- return @event;
- }
-
- [Fact]
- public async Task SaveTransfer_Test()
- {
- var command = CreateTransferRecord();
-
- await Task.Delay(3000);
-
- var repo = _container.Resolve();
-
- var itemFrom = await repo.GetAsync(command.OperationId, command.FromWalletId);
- var itemTo = await repo.GetAsync(command.OperationId, command.ToWalletId);
-
- Assert.NotNull(itemFrom);
- Assert.NotNull(itemTo);
-
- Assert.True(itemFrom is Cashout);
- Assert.True(itemTo is Cashin);
-
- var transferFrom = itemFrom as Cashout;
- var transferTo = itemTo as Cashin;
-
- Assert.Equal(-Math.Abs(command.Volume), transferFrom.Volume);
- Assert.Equal(Math.Abs(command.Volume), transferTo.Volume);
-
- Assert.Null(transferFrom.FeeSize);
- Assert.Equal(command.FeeSize, transferTo.FeeSize);
- }
- }
-}