Skip to content

Commit b780484

Browse files
committed
Merge branch 'main' of https://github.com/RayTale/Vertex into main
2 parents b689e3e + 2428d7d commit b780484

25 files changed

Lines changed: 229 additions & 129 deletions

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ updates:
99
directory: "/" # Location of package manifests
1010
schedule:
1111
interval: "daily"
12+
13+
target-branch: "develop"

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: "*"
6+
pull_request:
7+
branches: "*"
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup .NET Core
19+
uses: actions/setup-dotnet@v1
20+
with:
21+
dotnet-version: 5.0.100-rc.2.20479.15
22+
23+
- name: Install dependencies
24+
run: dotnet restore
25+
- name: Build
26+
run: dotnet build --configuration Release --no-restore
27+
- name: Test
28+
run: dotnet test --configuration Release --no-build --verbosity normal --logger:trx
29+
- name: Upload Test Results
30+
uses: actions/upload-artifact@v2.2.0
31+
with:
32+
# Artifact name
33+
name: Test Results
34+
# A file, directory or wildcard pattern that describes what to upload
35+
path: "**/*.trx"

.github/workflows/dotnet-core.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: publish nuget
2+
3+
on:
4+
push:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Setup .NET Core
17+
uses: actions/setup-dotnet@v1
18+
with:
19+
dotnet-version: 5.0.100
20+
21+
- uses: dotnet/nbgv@master
22+
with:
23+
setAllVars: true
24+
- run: echo "NuGetPackageVersion $NBGV_NuGetPackageVersion"
25+
26+
- name: Install dependencies
27+
run: dotnet restore
28+
- name: Build
29+
run: dotnet build --configuration Release --no-restore
30+
31+
- name: Pack the NuGets
32+
run: dotnet pack --configuration Release --no-build --output nupkgs -p:PackageVersion=$NBGV_NuGetPackageVersion
33+
34+
- name: Publish NuGet
35+
run: dotnet nuget push nupkgs/*.*nupkg --api-key ${{ secrets.NUGETKEY }} --skip-duplicate --source https://api.nuget.org/v3/index.json

Directory.Build.props

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,34 @@
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
99
<PackageProjectUrl>https://github.com/RayTale/Vertex</PackageProjectUrl>
1010
<RepositoryUrl>https://github.com/RayTale/Vertex.git</RepositoryUrl>
11-
<PackageIconUrl>https://raw.githubusercontent.com/RayTale/Vertex/main/logo.png</PackageIconUrl>
11+
<PackageIcon>logo.png</PackageIcon>
1212
<PackageTags>orleans,event-sourcing,actor,Vertex</PackageTags>
1313
<PublishRepositoryUrl>true</PublishRepositoryUrl>
14-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1514
<IncludeSymbols>true</IncludeSymbols>
1615
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1716
<RepositoryType>git</RepositoryType>
17+
<Company>RayTale</Company>
18+
<Product>Vertex</Product>
19+
<Authors>uless</Authors>
1820
<NoWarn>1701;1702;1705;1591</NoWarn>
1921
</PropertyGroup>
20-
22+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
23+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
24+
<Deterministic>true</Deterministic>
25+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
26+
</PropertyGroup>
2127
<PropertyGroup>
22-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2328
<DebugSymbols>true</DebugSymbols>
2429
<DebugType>portable</DebugType>
2530
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
2631
</PropertyGroup>
32+
<ItemGroup Condition=" '$(IsPackable)' != 'false' ">
33+
<None Include="$(MSBuildThisFileDirectory)logo.png" Pack="true" PackagePath=""/>
34+
</ItemGroup>
2735
<ItemGroup>
2836
<PackageReference Include="Lindhart.Analyser.MissingAwaitWarning" />
29-
<PackageReference Include="Microsoft.CodeQuality.Analyzers" />
37+
<!-- <PackageReference Include="Microsoft.CodeQuality.Analyzers" /> -->
3038
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" />
31-
<PackageReference Include="Nerdbank.GitVersioning" />
3239
<PackageReference Include="StyleCop.Analyzers" />
3340
</ItemGroup>
3441
</Project>

Packages.props

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
44
<ItemGroup>
5-
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="5.0.0-rc.2.20475.5" />
6-
<PackageReference Update="Microsoft.Extensions.Logging" Version="5.0.0-rc.2.20475.5" />
7-
<PackageReference Update="Microsoft.Extensions.Logging.Debug" Version="5.0.0-rc.2.20475.5" />
8-
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="5.0.0-rc.2.20475.5" />
9-
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0-rc.2.20475.5" />
10-
<PackageReference Update="Microsoft.Extensions.ObjectPool" Version="5.0.0-rc.2.20475.17" />
11-
<PackageReference Update="Microsoft.Extensions.Options" Version="5.0.0-rc.2.20475.5" />
12-
<PackageReference Update="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0-rc.2.20475.5" />
5+
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="5.0.0" />
6+
<PackageReference Update="Microsoft.Extensions.Logging" Version="5.0.0" />
7+
<PackageReference Update="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
8+
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="5.0.0" />
9+
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
10+
<PackageReference Update="Microsoft.Extensions.ObjectPool" Version="5.0.0" />
11+
<PackageReference Update="Microsoft.Extensions.Options" Version="5.0.0" />
12+
<PackageReference Update="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
1313
<PackageReference Update="BenchmarkDotNet" Version="0.12.1" />
1414

1515
<PackageReference Update="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.3.0">
@@ -32,12 +32,12 @@
3232
<PackageReference Update="Confluent.Kafka" Version="1.5.2" />
3333
<PackageReference Update="RabbitMQ.Client" Version="6.2.1" />
3434
<PackageReference Update="System.Reactive" Version="4.4.1" />
35-
<PackageReference Update="linq2db" Version="3.1.5" />
35+
<PackageReference Update="linq2db" Version="3.1.6" />
3636
<PackageReference Update="IdGen" Version="3.0.0" />
3737

3838
<PackageReference Update="Lindhart.Analyser.MissingAwaitWarning" Version="2.0.0-beta2" PrivateAssets="All" />
3939
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="3.6.0" PrivateAssets="All" />
40-
<PackageReference Update="Microsoft.Data.Sqlite" Version="5.0.0-rc.2.20475.6" />
40+
<PackageReference Update="Microsoft.Data.Sqlite" Version="5.0.0" />
4141
<PackageReference Update="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="All" />
4242
<PackageReference Update="Microsoft.CodeQuality.Analyzers" Version="3.3.1">
4343
<PrivateAssets>all</PrivateAssets>
@@ -47,7 +47,7 @@
4747
<PrivateAssets>all</PrivateAssets>
4848
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4949
</PackageReference>
50-
<PackageReference Update="StyleCop.Analyzers" Version="1.2.0-beta.205">
50+
<PackageReference Update="StyleCop.Analyzers" Version="1.2.0-beta.261">
5151
<PrivateAssets>all</PrivateAssets>
5252
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5353
</PackageReference>

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# Vertex
2-
This is a high-performance distributed framework that integrates Actor, Event Sourcing.
1+
## Vertex是一个基于Orleans开发的分布式、最终一致性、事件溯源的跨平台框架,用于构建高性能、高吞吐、低延时、可扩展的分布式应用程序
2+
3+
[![license](https://img.shields.io/github/license/RayTale/Vertex)](https://github.com/RayTale/Vertex/blob/main/LICENSE)
4+
[![NuGet](https://img.shields.io/nuget/v/Vertex.Runtime.svg?style=flat)](https://www.nuget.org/profiles/uless)
5+
[![Join the chat at https://gitter.im/RayTale/Ray](https://badges.gitter.im/RayTale/Ray.svg)](https://gitter.im/RayTale/Ray?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6+
---
7+
* 框架采用Event sourcing来解决分布式事务问题,除了提供超高吞吐的分布式事务能力之外,还提供状态变化的详细事件日志,易于追踪溯源,在某些领域有着天然的优势。
8+
9+
* 基于. Net 5.0和Orleans开发,支持从单个本地服务器扩展到多服务器集群,提供高可用能力。
10+
---
11+
12+
### 项目起源
13+
14+
Vertex是Ray框架的3.0版本,Ray诞生之初是为虚拟币交易引擎提供一个全内存、高吞吐、低延时、可追溯、分布式的事务框架。
15+
16+
*__虚拟币交易引擎的指标要求比股票交易系统高很多,有一些硬性指标要求:__*
17+
18+
* 极高吞吐:大量搬砖机器人在下单撤单,对系统的吞吐要求非常高。
19+
20+
* 极低延时:虚拟币价格波动非常大,用户和挂单机器人都需要低延时来保证灵敏度,不然很容易亏损。
21+
22+
* 稳定性:7*24小时开放交易,对系统的高可用和伸缩性要求非常高。
23+
24+
* 横向拓展:大量的新增交易对,需要能够随时进行横向扩容。
25+
26+
* 可追溯性:要求对每一次金额变化和交易都有日志可追溯
27+
28+
*__遇到的困难__*
29+
30+
* 事务流程较长:安全校验,金额变化,订单生成,撮合交易,订单更新,金额更新,账单生成,K线生成,挂单深度更新,触发计划订单...
31+
32+
> 如果按照传统的解决方案,如果要满足上述要求,除了巨大的复杂性之外还需要巨大的硬件成本
33+
34+
经过一段时间的研究和试验之后,决定使用saga + event sourcing结合来进行业务开发,但传统的各种类似的框架都存在各种问题,特别是性能问题。所以我决定基于Orleans来开发一个通用框架,经过半年多优化改良,框架达到了交易引擎要求的各项指标,单交易对能达到5000/s的订单能力,一次订单的提交延时控制在10ms以下,多交易对的处理能力可以通过增加集群节点来提高。
35+
36+
### 核心功能
37+
38+
* 高性能分布式Actor
39+
* 事件溯源
40+
* 事件存储
41+
* 事件分发与订阅
42+
* 最终一致性编程模型
43+
* 强一致性编程模型
44+
45+

examples/Packages.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="..\Packages.props" />
44
<ItemGroup>
5-
<PackageReference Update="Microsoft.Extensions.Hosting" Version="5.0.0-rc.2.20475.5" />
6-
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="5.0.0-rc.2.20475.5" />
7-
<PackageReference Update="Microsoft.Data.Sqlite" Version="5.0.0-rc.2.20475.6" />
8-
<PackageReference Update="MySqlConnector" Version="1.1.0-beta.1" />
5+
<PackageReference Update="Microsoft.Extensions.Hosting" Version="5.0.0" />
6+
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
7+
<PackageReference Update="Microsoft.Data.Sqlite" Version="5.0.0" />
8+
<PackageReference Update="MySqlConnector" Version="1.1.0" />
99
<PackageReference Update="Npgsql" Version="5.0.0-preview1" />
1010
</ItemGroup>
1111
</Project>

examples/Transfer.Server/Program.cs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Transfer.IGrains.DTx;
1616
using Vertex.Runtime;
1717
using Vertex.Runtime.InnerService;
18+
using Vertex.Runtime.Options;
1819
using Vertex.Storage.Linq2db;
1920
using Vertex.Storage.Linq2db.Core;
2021
using Vertex.Stream.InMemory;
@@ -66,25 +67,25 @@ private static IHost CreateHost()
6667
// serviceCollection.AddSingleton(memorySQLiteConnection);
6768
config.Connections = new Vertex.Storage.Linq2db.Options.ConnectionOptions[]
6869
{
69-
new Vertex.Storage.Linq2db.Options.ConnectionOptions
70-
{
71-
Name = Consts.CoreDbName,
72-
ProviderName = "PostgreSQL",
73-
ConnectionString = "Server=localhost;Port=5432;Database=Vertex;User Id=postgres;Password=postgres;Pooling=true;MaxPoolSize=20;",
74-
},
70+
// new Vertex.Storage.Linq2db.Options.ConnectionOptions
71+
// {
72+
// Name = Consts.CoreDbName,
73+
// ProviderName = "PostgreSQL",
74+
// ConnectionString = "Server=localhost;Port=5432;Database=Vertex;User Id=postgres;Password=postgres;Pooling=true;MaxPoolSize=20;",
75+
// },
7576

7677
// new Vertex.Storage.Linq2db.Options.ConnectionOptions
7778
// {
78-
// Name = Consts.core_db_Name,
79+
// Name = Consts.CoreDbName,
7980
// ProviderName = "MySql",
8081
// ConnectionString = "Server=localhost;Database=Vertex;UserId=root;Password=root;pooling=true;maxpoolsize=50;ConnectionLifeTime=30;"
8182
// },
82-
// new Vertex.Storage.Linq2db.Options.ConnectionOptions
83-
// {
84-
// Name = Consts.core_db_Name,
85-
// ProviderName = "SQLite.MS",
86-
// ConnectionString = "Data Source=InMemorySample;Mode=Memory;Cache=Shared"
87-
// }
83+
new Vertex.Storage.Linq2db.Options.ConnectionOptions
84+
{
85+
Name = Consts.CoreDbName,
86+
ProviderName = "SQLite.MS",
87+
ConnectionString = "Data Source=Vertex.SQLite.db;"
88+
}
8889
};
8990
}, new EventArchivePolicy("month", (name, time) => $"Vertex_Archive_{name}_{DateTimeOffset.FromUnixTimeSeconds(time).ToString("yyyyMM")}".ToLower(), table => table.StartsWith("Vertex_Archive".ToLower())));
9091

@@ -109,6 +110,14 @@ private static IHost CreateHost()
109110
{
110111
options.CollectionAge = TimeSpan.FromMinutes(5);
111112
});
113+
serviceCollection.ConfigureAll<SubActorOptions>(options =>
114+
{
115+
options.SnapshotVersionInterval = 1;
116+
});
117+
serviceCollection.Configure<SubActorOptions>(typeof(AccountFlow).FullName, options =>
118+
{
119+
options.SnapshotVersionInterval = 10;
120+
});
112121
})
113122
.ConfigureLogging(logging =>
114123
{

src/Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Import Project="..\Directory.Build.props" />
33

44
<ItemGroup>
5+
<PackageReference Include="Nerdbank.GitVersioning" />
56
<PackageReference Include="Microsoft.SourceLink.GitHub"/>
67
</ItemGroup>
78
</Project>

0 commit comments

Comments
 (0)