Skip to content

Commit 96f11ad

Browse files
authored
Merge pull request #116 from progaudi/migrate/netstandard2.0
Migrate/netstandard2.0
2 parents eda7d85 + e7080db commit 96f11ad

21 files changed

+171
-94
lines changed

.travis.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@ matrix:
33
- os: linux # Ubuntu 14.04
44
dist: trusty
55
sudo: required
6-
- os: linux # Ubuntu 14.04
7-
dist: trusty
8-
env: BUILD_DOCKER=true
96
- os: osx # OSX 10.12
107
osx_image: xcode8.3
118

129
before_install:
13-
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$BUILD_DOCKER" != true ]]; then sudo ./scripts/ubuntu-prereqs.sh ; fi
10+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./scripts/ubuntu-prereqs.sh ; fi
1411
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./scripts/mac-prereqs.sh ; fi
1512

1613
install:
17-
- if [[ "$BUILD_DOCKER" != true ]]; then ./scripts/dotnet-install.sh ; fi
18-
- if [[ "$BUILD_DOCKER" != true ]]; then PATH=$PATH:$HOME/.dotnet && export PATH ; fi
14+
- ./scripts/dotnet-install.sh
15+
- PATH=$PATH:$HOME/.dotnet && export PATH
1916
- if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then docker-compose -f docker-compose.yml up -d ; fi
2017
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tarantool tarantool/tarantool.lua ; fi
2118
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then redis-server --daemonize yes ; fi
2219

2320
script:
24-
- if [[ "$BUILD_DOCKER" != true ]]; then ./scripts/build-netcore.sh ; fi
25-
- if [[ "$BUILD_DOCKER" != true ]]; then ./scripts/test-netcore.sh ; fi
26-
- if [[ "$BUILD_DOCKER" == true ]]; then docker-compose -f docker-compose.yml -f docker-compose.tests.yml up --build tarantool-client ; fi
21+
- ./scripts/build-netcore.sh
22+
- ./scripts/test-netcore.sh

appveyor.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "1.0.0"
3+
"version": "2.0.0"
44
}
55
}

progaudi.tarantool.sln

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26228.9
4+
VisualStudioVersion = 15.0.26730.12
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "progaudi.tarantool", "src\progaudi.tarantool\progaudi.tarantool.csproj", "{DD007E9F-FB2D-4351-AAB7-F2D367B295C4}"
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "progaudi.tarantool.tests", "tests\progaudi.tarantool.tests\progaudi.tarantool.tests.csproj", "{4C681801-9A6B-4CE9-8EAA-23F80917F046}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{14BAEDF1-BEFC-4FB2-AAC9-08D397191216}"
11+
ProjectSection(SolutionItems) = preProject
12+
global.json = global.json
13+
EndProjectSection
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "progaudi.tarantool.benchmark", "src\progaudi.tarantool.benchmark\progaudi.tarantool.benchmark.csproj", "{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}"
16+
EndProject
1017
Global
1118
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1219
Debug|Any CPU = Debug|Any CPU
@@ -41,8 +48,23 @@ Global
4148
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x64.Build.0 = Release|Any CPU
4249
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x86.ActiveCfg = Release|Any CPU
4350
{4C681801-9A6B-4CE9-8EAA-23F80917F046}.Release|x86.Build.0 = Release|Any CPU
51+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
53+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x64.ActiveCfg = Debug|Any CPU
54+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x64.Build.0 = Debug|Any CPU
55+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x86.ActiveCfg = Debug|Any CPU
56+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Debug|x86.Build.0 = Debug|Any CPU
57+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
58+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|Any CPU.Build.0 = Release|Any CPU
59+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x64.ActiveCfg = Release|Any CPU
60+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x64.Build.0 = Release|Any CPU
61+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x86.ActiveCfg = Release|Any CPU
62+
{CD96AC2D-505F-4FDF-82FB-76F51CC28FF4}.Release|x86.Build.0 = Release|Any CPU
4463
EndGlobalSection
4564
GlobalSection(SolutionProperties) = preSolution
4665
HideSolutionNode = FALSE
4766
EndGlobalSection
67+
GlobalSection(ExtensibilityGlobals) = postSolution
68+
SolutionGuid = {ADF03192-56BA-4020-9654-59533D08C629}
69+
EndGlobalSection
4870
EndGlobal
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM progaudi/dotnet:1.0.1-xenial
1+
FROM microsoft/dotnet:2.0.0-sdk
22

33
WORKDIR /app
44
ADD dotnet.csproj /app/dotnet.csproj
5-
RUN /root/.dotnet/dotnet restore
5+
RUN dotnet restore
66

77
ADD . /app
8-
RUN /root/.dotnet/dotnet build -c Release -f netcoreapp1.1 /app/dotnet.csproj
8+
RUN dotnet build -c Release -f netcoreapp2.0 /app/dotnet.csproj
99

1010
EXPOSE 5000/tcp
1111

12-
CMD ["/root/.dotnet/dotnet", "run", "--server.urls", "http://*:5000"]
12+
CMD ["dotnet", "run", "--server.urls", "http://*:5000"]

samples/docker-compose/dotnet/Program.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.Extensions.Configuration;
44

@@ -10,13 +10,12 @@ public static void Main(string[] args)
1010
{
1111
var config = new ConfigurationBuilder()
1212
.AddCommandLine(args)
13-
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
13+
.AddEnvironmentVariables("ASPNETCORE_")
1414
.Build();
1515

16-
var host = new WebHostBuilder()
16+
var host = WebHost
17+
.CreateDefaultBuilder(args)
1718
.UseConfiguration(config)
18-
.UseKestrel()
19-
.UseContentRoot(Directory.GetCurrentDirectory())
2019
.UseStartup<Startup>()
2120
.Build();
2221

samples/docker-compose/dotnet/Views/Home/DogTablePartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</tbody>
2525
<tfoot>
2626
<tr>
27-
<td colspan="3">@Model.Dogs.Count dogs total</td>
27+
<td colspan="4">@Model.Dogs.Count dogs total</td>
2828
</tr>
2929
</tfoot>
3030
</table>

samples/docker-compose/dotnet/Views/Home/Index.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
ViewData["Title"] = "Tarantool demo page";
55
}
66

7+
<h1>Render time is @DateTimeOffset.Now.ToString("F")</h1>
8+
79
@Html.Partial("DogTablePartial", new DogTable(Model[0], "All dogs in Tarantool"))
810

911
@Html.Partial("DogTablePartial", new DogTable(Model[1], "Senior dogs in Tarantool"))
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<OutputType>Exe</OutputType>
4-
<TargetFramework>netcoreapp1.1</TargetFramework>
5-
<PreserveCompilationContext>true</PreserveCompilationContext>
3+
<TargetFramework>netcoreapp2.0</TargetFramework>
64
</PropertyGroup>
75
<ItemGroup>
8-
<Folder Include="wwwroot\" />
6+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
7+
<PackageReference Include="progaudi.tarantool" Version="0.9.0" />
98
</ItemGroup>
109
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.0" />
12-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
13-
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.0" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
15-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
16-
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
17-
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
18-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
19-
<PackageReference Include="msgpack.light" Version="1.3.0" />
20-
<PackageReference Include="progaudi.tarantool" Version="0.8.0" />
10+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
2111
</ItemGroup>
22-
</Project>
12+
</Project>

scripts/build-netcore.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ cd ..
88

99
dotnet restore
1010
dotnet build -c Release -f netstandard1.4 src/progaudi.tarantool/progaudi.tarantool.csproj
11+
dotnet build -c Release -f netstandard2.0 src/progaudi.tarantool/progaudi.tarantool.csproj
1112
dotnet build -c Release -f netcoreapp1.0 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
1213
dotnet build -c Release -f netcoreapp1.1 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
14+
dotnet build -c Release -f netcoreapp2.0 tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj
1315

1416
popd

scripts/dotnet-install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ set -ev
44

55
curl -o ./dotnet-install.sh -fL https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh
66
chmod +x ./dotnet-install.sh
7-
version=$(jq -r .sdk.version global.json)
8-
./dotnet-install.sh --version $version
7+
./dotnet-install.sh --version 1.0.4
8+
./dotnet-install.sh --version 2.0.0
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using BenchmarkDotNet.Columns;
2+
using BenchmarkDotNet.Configs;
3+
using BenchmarkDotNet.Diagnosers;
4+
using BenchmarkDotNet.Environments;
5+
using BenchmarkDotNet.Exporters;
6+
using BenchmarkDotNet.Exporters.Csv;
7+
using BenchmarkDotNet.Jobs;
8+
using BenchmarkDotNet.Toolchains.CsProj;
9+
10+
namespace progaudi.tarantool.benchmark
11+
{
12+
internal class BenchmarkConfig : ManualConfig
13+
{
14+
public BenchmarkConfig()
15+
{
16+
Add(StatisticColumn.P95);
17+
18+
Add(MemoryDiagnoser.Default);
19+
20+
// https://github.com/dotnet/BenchmarkDotNet/issues/500
21+
//Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X86).With(Runtime.Clr));
22+
//Add(Job.ShortRun.With(Jit.LegacyJit).With(Platform.X64).With(Runtime.Clr));
23+
24+
//Add(Job.ShortRun.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Clr));
25+
26+
// RyuJit for .NET Core 1.1
27+
Add(Job.Default.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp11).WithId("netcore1.1"));
28+
29+
// RyuJit for .NET Core 2.0
30+
Add(Job.Default.With(Jit.RyuJit).With(Platform.X64).With(Runtime.Core).With(CsProjCoreToolchain.NetCoreApp20).WithId("netcore2.0"));
31+
32+
Add(MarkdownExporter.GitHub);
33+
Add(CsvMeasurementsExporter.Default);
34+
}
35+
}
36+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Threading.Tasks;
2+
using BenchmarkDotNet.Attributes;
3+
using ProGaudi.Tarantool.Client;
4+
using ProGaudi.Tarantool.Client.Model.Responses;
5+
using StackExchange.Redis;
6+
7+
namespace progaudi.tarantool.benchmark
8+
{
9+
[Config(typeof(BenchmarkConfig))]
10+
public class IncrementBenchmark
11+
{
12+
private readonly Box _box;
13+
private readonly IDatabaseAsync _redis;
14+
15+
public IncrementBenchmark()
16+
{
17+
_box = Box.Connect("localhost", 3301).GetAwaiter().GetResult();
18+
_redis = ConnectionMultiplexer.Connect("localhost:6379").GetDatabase();
19+
}
20+
21+
[Benchmark(Baseline = true)]
22+
public async Task<long> Redis() => await _redis.StringIncrementAsync("test_for_benchmarking");
23+
24+
[Benchmark]
25+
public async Task<DataResponse<int[]>> Tarantool() => await _box.Call<int>("test_for_benchmarking");
26+
}
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using BenchmarkDotNet.Running;
2+
3+
namespace progaudi.tarantool.benchmark
4+
{
5+
public static class Program
6+
{
7+
public static void Main() => BenchmarkRunner.Run<IncrementBenchmark>();
8+
}
9+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
6+
<WarningsAsErrors>true</WarningsAsErrors>
7+
8+
<AssemblyName>progaudi.tarantool.benchmark</AssemblyName>
9+
<RootNamespace>ProGaudi.Tarantool.Benchmark</RootNamespace>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="BenchmarkDotNet" Version="0.10.9" />
14+
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\progaudi.tarantool\progaudi.tarantool.csproj" />
19+
</ItemGroup>
20+
</Project>

src/progaudi.tarantool/IRequestWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ internal interface IRequestWriter : IDisposable
99

1010
bool IsConnected { get; }
1111

12-
Task Write(ArraySegment<byte> header, ArraySegment<byte> body);
12+
void Write(ArraySegment<byte> header, ArraySegment<byte> body);
1313
}
1414
}

src/progaudi.tarantool/LogicalConnection.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ private async Task<TResponse> SendRequestImpl<TRequest, TResponse>(TRequest requ
140140
var requestId = _requestIdCounter.GetRequestId();
141141
var responseTask = _responseReader.GetResponseTask(requestId);
142142

143-
var headerBuffer = CreateAndSerializeBuffer(request, requestId, bodyBuffer, out var headerLength);
144-
await _requestWriter.Write(
145-
new ArraySegment<byte>(headerBuffer, 0, Constants.PacketSizeBufferSize + (int) headerLength),
143+
var headerBuffer = CreateAndSerializeHeader(request, requestId, bodyBuffer);
144+
_requestWriter.Write(
145+
headerBuffer,
146146
new ArraySegment<byte>(bodyBuffer, 0, bodyBuffer.Length));
147147

148148
try
@@ -175,11 +175,15 @@ private static string ToReadableString(byte[] bytes)
175175
return string.Join(" ", bytes.Select(b => b.ToString("X2")));
176176
}
177177

178-
private byte[] CreateAndSerializeBuffer<TRequest>(
178+
private static string ToReadableString(ArraySegment<byte> bytes)
179+
{
180+
return string.Join(" ", bytes.Select(b => b.ToString("X2")));
181+
}
182+
183+
private ArraySegment<byte> CreateAndSerializeHeader<TRequest>(
179184
TRequest request,
180185
RequestId requestId,
181-
byte[] serializedRequest,
182-
out long headerLength) where TRequest : IRequest
186+
byte[] serializedRequest) where TRequest : IRequest
183187
{
184188
var packetSizeBuffer = new byte[Constants.PacketSizeBufferSize + Constants.MaxHeaderLength];
185189
var stream = new MemoryStream(packetSizeBuffer);
@@ -188,11 +192,12 @@ private byte[] CreateAndSerializeBuffer<TRequest>(
188192
stream.Seek(Constants.PacketSizeBufferSize, SeekOrigin.Begin);
189193
MsgPackSerializer.Serialize(requestHeader, stream, _msgPackContext);
190194

191-
headerLength = stream.Position - Constants.PacketSizeBufferSize;
195+
var lengthAndHeaderLengthByteCount = (int)stream.Position;
196+
var headerLength = lengthAndHeaderLengthByteCount - Constants.PacketSizeBufferSize;
192197
var packetLength = new PacketSize((uint) (headerLength + serializedRequest.Length));
193198
stream.Seek(0, SeekOrigin.Begin);
194199
MsgPackSerializer.Serialize(packetLength, stream, _msgPackContext);
195-
return packetSizeBuffer;
200+
return new ArraySegment<byte>(packetSizeBuffer, 0, lengthAndHeaderLengthByteCount);
196201
}
197202
}
198203
}

0 commit comments

Comments
 (0)