Skip to content

Feature/remove restrictions #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
"isBuildCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
},
{
"taskName": "test",
"args": [ "tests/progaudi.tarantool.tests/progaudi.tarantool.tests.csproj"],
"isTestCommand": true,
"showOutput": "silent",
"problemMatcher": "$msCompile"
}
]
}
62 changes: 62 additions & 0 deletions T4Templates/SystemTupleConverters.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
using System;
using ProGaudi.MsgPack.Light;
using ProGaudi.Tarantool.Client.Utils;

namespace ProGaudi.Tarantool.Client.Converters{
<#
var maxParametersCount = 8;
var typeParameters = new Func<int, string>(count => string.Join(", ", System.Linq.Enumerable.Range(1, count).Select(num => $"T{num}")));
for(int i=1;i < maxParametersCount; i++){
#>
public class SystemTupleConverter<<#= typeParameters(i)#>> :IMsgPackConverter<Tuple<<#= typeParameters(i)#>>>
{
private IMsgPackConverter<object> _nullConverter;
<# for (int j= 1; j <= i; j++){#>
private IMsgPackConverter<T<#= j #>> _t<#= j #>Converter;
<#}#>
public void Initialize(MsgPackContext context)
{
_nullConverter = context.NullConverter;
<# for (int j= 1; j <= i; j++){#>
_t<#= j #>Converter = context.GetConverter<T<#= j #>>();<#}#>
}

public void Write(Tuple<<#= typeParameters(i)#>> value, IMsgPackWriter writer)
{
if (value == null)
{
_nullConverter.Write(null, writer);
return;
}

writer.WriteArrayHeader(<#= i #>);
<# for (int j= 1; j <= i; j++){#>
_t<#= j #>Converter.Write(value.Item<#= j #>, writer);<#}#>
}

public Tuple<<#= typeParameters(i)#>> Read(IMsgPackReader reader)
{
var actual = reader.ReadArrayLength();
if (actual == null)
{
return null;
}

const uint expected = <#= i #>;
if (actual != expected)
{
throw ExceptionHelper.InvalidArrayLength(expected, actual);
}
<# for (int j= 1; j <= i; j++){#>
var item<#= j #> = _t<#= j #>Converter.Read(reader);<#}#>

return Tuple.Create(<# for (int j= 1; j <= i; j++){#>
item<#= j #><#= j==i?"":"," #><#}#>
);
}
}
<#
}#>
}
52 changes: 52 additions & 0 deletions T4Templates/ValueTupleConverters.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
using System;
using ProGaudi.MsgPack.Light;
using ProGaudi.Tarantool.Client.Utils;

namespace ProGaudi.Tarantool.Client.Converters{
<#
var maxParametersCount = 8;
var typeParameters = new Func<int, string>(count => string.Join(", ", System.Linq.Enumerable.Range(1, count).Select(num => $"T{num}")));
for(int i=1;i < maxParametersCount; i++){
#>
public class ValueTupleConverter<<#= typeParameters(i)#>> :IMsgPackConverter<ValueTuple<<#= typeParameters(i)#>>>
{<# for (int j= 1; j <= i; j++){#>
private IMsgPackConverter<T<#= j #>> _t<#= j #>Converter;
<#}#>
public void Initialize(MsgPackContext context)
{<# for (int j= 1; j <= i; j++){#>
_t<#= j #>Converter = context.GetConverter<T<#= j #>>();<#}#>
}

public void Write(ValueTuple<<#= typeParameters(i)#>> value, IMsgPackWriter writer)
{
writer.WriteArrayHeader(<#= i #>);
<# for (int j= 1; j <= i; j++){#>
_t<#= j #>Converter.Write(value.Item<#= j #>, writer);<#}#>
}

public ValueTuple<<#= typeParameters(i)#>> Read(IMsgPackReader reader)
{
var actual = reader.ReadArrayLength();
if (actual == null)
{
return default(ValueTuple<<#= typeParameters(i)#>>);
}

const uint expected = <#= i #>;
if (actual != expected)
{
throw ExceptionHelper.InvalidArrayLength(expected, actual);
}
<# for (int j= 1; j <= i; j++){#>
var item<#= j #> = _t<#= j #>Converter.Read(reader);<#}#>

return ValueTuple.Create(<# for (int j= 1; j <= i; j++){#>
item<#= j #><#= j==i?"":"," #><#}#>
);
}
}
<#
}#>
}

This file was deleted.

1 change: 0 additions & 1 deletion _T4Awesome/config.t4ac

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/mac-prereqs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ev

brew update
brew install openssl jq
brew install tarantool --HEAD
brew install tarantool
brew install redis

mkdir -p /usr/local/lib
Expand Down
7 changes: 0 additions & 7 deletions src/progaudi.tarantool/Box.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,16 @@ public async Task Call_1_6(string functionName)
}

public async Task Call_1_6<TTuple>(string functionName, TTuple parameters)
where TTuple : ITarantoolTuple
{
await Call_1_6<TTuple, TarantoolTuple>(functionName, parameters).ConfigureAwait(false);
}

public Task<DataResponse<TResponse[]>> Call_1_6<TResponse>(string functionName)
where TResponse : ITarantoolTuple
{
return Call_1_6<TarantoolTuple, TResponse>(functionName, TarantoolTuple.Empty);
}

public async Task<DataResponse<TResponse[]>> Call_1_6<TTuple, TResponse>(string functionName, TTuple parameters)
where TTuple : ITarantoolTuple
where TResponse : ITarantoolTuple
{
var callRequest = new CallRequest<TTuple>(functionName, parameters, false);
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest).ConfigureAwait(false);
Expand All @@ -94,7 +90,6 @@ public async Task Call(string functionName)
}

public async Task Call<TTuple>(string functionName, TTuple parameters)
where TTuple : ITarantoolTuple
{
await Call<TTuple, TarantoolTuple>(functionName, parameters).ConfigureAwait(false);
}
Expand All @@ -105,14 +100,12 @@ public Task<DataResponse<TResponse[]>> Call<TResponse>(string functionName)
}

public async Task<DataResponse<TResponse[]>> Call<TTuple, TResponse>(string functionName, TTuple parameters)
where TTuple : ITarantoolTuple
{
var callRequest = new CallRequest<TTuple>(functionName, parameters);
return await _logicalConnection.SendRequest<CallRequest<TTuple>, TResponse>(callRequest).ConfigureAwait(false);
}

public async Task<DataResponse<TResponse[]>> Eval<TTuple, TResponse>(string expression, TTuple parameters)
where TTuple : ITarantoolTuple
{
var evalRequest = new EvalRequest<TTuple>(expression, parameters);
return await _logicalConnection.SendRequest<EvalRequest<TTuple>, TResponse>(evalRequest).ConfigureAwait(false);
Expand Down
1 change: 0 additions & 1 deletion src/progaudi.tarantool/Converters/CallPacketConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace ProGaudi.Tarantool.Client.Converters
{
internal class CallPacketConverter<T> : IMsgPackConverter<CallRequest<T>>
where T : ITarantoolTuple
{
private IMsgPackConverter<Key> _keyConverter;
private IMsgPackConverter<string> _stringConverter;
Expand Down
1 change: 0 additions & 1 deletion src/progaudi.tarantool/Converters/DeletePacketConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace ProGaudi.Tarantool.Client.Converters
{
internal class DeletePacketConverter<T> : IMsgPackConverter<DeleteRequest<T>>
where T: ITarantoolTuple
{
private IMsgPackConverter<Key> _keyConverter;
private IMsgPackConverter<uint> _uintConverter;
Expand Down
1 change: 0 additions & 1 deletion src/progaudi.tarantool/Converters/EvalPacketConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace ProGaudi.Tarantool.Client.Converters
{
internal class EvalPacketConverter<T> : IMsgPackConverter<EvalRequest<T>>
where T:ITarantoolTuple
{
private IMsgPackConverter<Key> _keyConverter;
private IMsgPackConverter<string> _stringConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace ProGaudi.Tarantool.Client.Converters
{
internal class InsertReplacePacketConverter<T> : IMsgPackConverter<InsertReplaceRequest<T>>
where T : ITarantoolTuple
{
private IMsgPackConverter<Key> _keyConverter;
private IMsgPackConverter<uint> _uintConverter;
Expand Down
1 change: 0 additions & 1 deletion src/progaudi.tarantool/Converters/SelectPacketConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace ProGaudi.Tarantool.Client.Converters
{
internal class SelectPacketConverter<T> : IMsgPackConverter<SelectRequest<T>>
where T : ITarantoolTuple
{
private IMsgPackConverter<T> _selectKeyConverter;
private IMsgPackConverter<Key> _keyConverter;
Expand Down
Loading