Skip to content

Commit 3a3def8

Browse files
authored
Merge branch 'main' into feat-update-slo
2 parents 23710bd + 37e9696 commit 3a3def8

22 files changed

+1552
-261
lines changed

.github/scripts/publish.sh

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,50 @@ then
88
exit 1;
99
fi;
1010

11-
MAJOR=$(cat $VERSION_FILE | grep Major | grep -Eo '[0-9]*');
12-
MINOR=$(cat $VERSION_FILE | grep Minor | grep -Eo '[0-9]*');
13-
PATCH=$(cat $VERSION_FILE | grep Patch | grep -Eo '[0-9]*');
11+
LAST_TAG=$(git tag | tail -n 1);
12+
MAJOR=$(echo $LAST_TAG | sed -E 's/v([0-9]+)\..*/\1/');
13+
MINOR=$(echo $LAST_TAG | sed -E 's/v[0-9]+\.([0-9]+)\..*/\1/');
14+
PATCH=$(echo $LAST_TAG | sed -E 's/v[0-9]+\.[0-9]+\.([0-9]+)-rc[0-9]+/\1/');
15+
RC=0;
1416

15-
VERSION="$MAJOR.$MINOR.$PATCH"
16-
17-
LAST_TAG="v$MAJOR.$MINOR.$PATCH";
18-
if [ "$VERSION_CHANGE" = "MINOR" ]
17+
if [ "$RELEASE_CANDIDATE" = true ]
18+
then
19+
RC=$(git tag | grep "v$MAJOR.$MINOR.$PATCH-rc" | wc -l | xargs || true);
20+
fi
21+
if [ "$VERSION_CHANGE" = "MINOR" ] && [ $RC = 0 ]
1922
then
2023
MINOR=$((MINOR+1));
2124
PATCH=0;
2225
fi;
23-
if [ "$VERSION_CHANGE" = "PATCH" ]
26+
if [ "$VERSION_CHANGE" = "PATCH" ] && [ $RC = 0 ]
2427
then
2528
PATCH=$((PATCH+1));
2629
fi;
2730
if [ "$RELEASE_CANDIDATE" = true ]
2831
then
29-
RC=$(git tag | grep "v$MAJOR.$MINOR.$PATCH-rc" | wc -l);
30-
TAG="v$MAJOR.$MINOR.$PATCH-rc$RC";
32+
VERSION="$MAJOR.$MINOR.$PATCH-rc$RC";
3133
else
3234
sed -e "s/Minor = [0-9]*/Minor = $MINOR/g" -i $VERSION_FILE
3335
sed -e "s/Patch = [0-9]*/Patch = $PATCH/g" -i $VERSION_FILE
3436
git add $VERSION_FILE;
35-
echo "## v$MAJOR.$MINOR.$PATCH" >> $CHANGELOG_FILE.tmp
36-
cat $CHANGELOG_FILE >> $CHANGELOG_FILE.tmp
37-
mv $CHANGELOG_FILE.tmp $CHANGELOG_FILE;
38-
git add $CHANGELOG_FILE;
39-
git config --global user.email "robot@umbrella";
40-
git config --global user.name "robot";
41-
git commit -m "Release v$MAJOR.$MINOR.$PATCH";
42-
TAG="v$MAJOR.$MINOR.$PATCH";
37+
VERSION="$MAJOR.$MINOR.$PATCH";
4338
fi;
39+
TAG="v$VERSION"
40+
echo "## v$VERSION" >> $CHANGELOG_FILE.tmp
41+
cat $CHANGELOG_FILE >> $CHANGELOG_FILE.tmp
42+
mv $CHANGELOG_FILE.tmp $CHANGELOG_FILE;
43+
git add $CHANGELOG_FILE;
44+
git config --global user.email "robot@umbrella";
45+
git config --global user.name "robot";
46+
git commit -m "Release v$VERSION";
4447
git tag $TAG
4548
git push --tags && git push
4649
CHANGELOG="$CHANGELOG
4750
4851
Full Changelog: [$LAST_TAG...$TAG](https://github.com/ydb-platform/ydb-dotnet-sdk/compare/$LAST_TAG...$TAG)"
49-
if [ "$RELEASE_CANDIDATE" = true ]
50-
then
51-
gh release create -d $TAG -t "$TAG" --notes "$CHANGELOG"
52-
else
53-
VERSION=$MAJOR.$MINOR.$PATCH
54-
cd src
55-
dotnet pack -c Release -o out /p:Version=$VERSION
56-
gh release create $TAG -t "$TAG" --notes "$CHANGELOG"
57-
dotnet nuget push out/Ydb.Sdk.$VERSION.nupkg --skip-duplicate --api-key $NUGET_TOKEN --source https://api.nuget.org/v3/index.json
58-
fi;
52+
53+
cd src
54+
dotnet pack -c Release -o out /p:Version=$VERSION
55+
gh release create $TAG -t "$TAG" --notes "$CHANGELOG"
56+
dotnet nuget push out/Ydb.Sdk.$VERSION.nupkg --skip-duplicate --api-key $NUGET_TOKEN --source https://api.nuget.org/v3/index.json
57+

.github/workflows/tests.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
os: [ ubuntu-22.04, windows-2022, macos-12 ]
17+
os: [ ubuntu-22.04, windows-2022, macos-15 ]
1818
dotnet-version: [ 6.0.x, 7.0.x ]
1919
include:
2020
- dotnet-version: 6.0.x
@@ -33,7 +33,6 @@ jobs:
3333
run: |
3434
cd src
3535
dotnet test --filter "Category=Unit" -f ${{ matrix.dotnet-target-framework }}
36-
3736
ado-net-tests:
3837
runs-on: ubuntu-22.04
3938
strategy:
@@ -74,7 +73,46 @@ jobs:
7473
docker cp ydb-local:/ydb_certs/ca.pem ~/
7574
cd src
7675
dotnet test --filter "(FullyQualifiedName~Ado) | (FullyQualifiedName~Dapper)" -l "console;verbosity=normal"
77-
76+
topic-tests:
77+
runs-on: ubuntu-22.04
78+
strategy:
79+
fail-fast: false
80+
matrix:
81+
ydb-version: [ 'trunk' ]
82+
dotnet-version: [ 6.0.x, 7.0.x ]
83+
include:
84+
- dotnet-version: 6.0.x
85+
dotnet-target-framework: net6.0
86+
- dotnet-version: 7.0.x
87+
dotnet-target-framework: net7.0
88+
services:
89+
ydb:
90+
image: cr.yandex/yc/yandex-docker-local-ydb:${{ matrix.ydb-version }}
91+
ports:
92+
- 2135:2135
93+
- 2136:2136
94+
- 8765:8765
95+
env:
96+
YDB_LOCAL_SURVIVE_RESTART: true
97+
YDB_USE_IN_MEMORY_PDISKS: true
98+
options: '--name ydb-local -h localhost'
99+
env:
100+
OS: ubuntu-22.04
101+
YDB_VERSION: ${{ matrix.ydb-version }}
102+
YDB_CONNECTION_STRING: grpc://localhost:2136/local
103+
YDB_CONNECTION_STRING_SECURE: grpcs://localhost:2135/local
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v4
107+
- name: Install Dotnet
108+
uses: actions/setup-dotnet@v4
109+
with:
110+
dotnet-version: ${{ matrix.dotnet-version }}
111+
- name: Run Topic tests
112+
run: |
113+
docker cp ydb-local:/ydb_certs/ca.pem ~/
114+
cd src
115+
dotnet test --filter "FullyQualifiedName~Topic" -l "console;verbosity=normal"
78116
integration-tests:
79117
runs-on: ubuntu-22.04
80118
strategy:
@@ -154,4 +192,4 @@ jobs:
154192
- name: Run Dapper example
155193
run: |
156194
cd ./examples/src/DapperExample
157-
dotnet run
195+
dotnet run

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
## v0.9.0-rc1
2+
- Topic Writer updated release candidate:
3+
* Do not send messages that have a timeout by cancelToken.
4+
* If your value serializer throws an exception, this will be wrapped in a WriterException with unspecified status.
5+
* Added BufferOverflowRetryTimeoutMs to the next try write.
6+
* Rename _disposeTokenSource -> _disposeCts.
7+
* Optimize write worker: if (_toSendBuffer.IsEmpty) continue.
8+
* On RPC errors create DummyWriterSession.
9+
* Message has been skipped because its sequence number is less than or equal to the last processed server's SeqNo.
10+
* Calculate the next sequence number from the calculated previous messages.
11+
12+
## v0.9.0-rc0
13+
- Topic Writer release candidate:
14+
* Updated CAS semantics for enqueuing in the buffer.
15+
* Processed buffer overflow on WriteAsync.
16+
* Setting NotStartedWriterSession with a fail reason on RPC and more errors.
17+
* New initialization strategy for WriterSession (background task).
18+
* Supported cancellation token for sending tasks.
19+
* Fixed setting the SeqNo field in the message (in-flight buffer already has a seqNo) and added a check on canceled TCS.
20+
* Using BitConverter for Serializer / Deserializer.
21+
- Fixed: grpc requests go via proxy on Grpc.NET.Client >= 2.44
22+
123
## v0.8.0
224
- Fixed bug on commit with fail, no set failed flag for rollback invocation
325
- Supported UUID (Guid)

src/Ydb.Sdk/src/IDriver.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ namespace Ydb.Sdk;
66

77
public interface IDriver : IAsyncDisposable, IDisposable
88
{
9-
internal Task<TResponse> UnaryCall<TRequest, TResponse>(
9+
public Task<TResponse> UnaryCall<TRequest, TResponse>(
1010
Method<TRequest, TResponse> method,
1111
TRequest request,
1212
GrpcRequestSettings settings)
1313
where TRequest : class
1414
where TResponse : class;
1515

16-
internal ServerStream<TResponse> ServerStreamCall<TRequest, TResponse>(
16+
public ServerStream<TResponse> ServerStreamCall<TRequest, TResponse>(
1717
Method<TRequest, TResponse> method,
1818
TRequest request,
1919
GrpcRequestSettings settings)
2020
where TRequest : class
2121
where TResponse : class;
2222

23-
internal BidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TRequest, TResponse>(
23+
public IBidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TRequest, TResponse>(
2424
Method<TRequest, TResponse> method,
2525
GrpcRequestSettings settings)
2626
where TRequest : class
@@ -29,6 +29,15 @@ internal BidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TReque
2929
ILoggerFactory LoggerFactory { get; }
3030
}
3131

32+
public interface IBidirectionalStream<in TRequest, out TResponse> : IDisposable
33+
{
34+
public Task Write(TRequest request);
35+
36+
public ValueTask<bool> MoveNextAsync();
37+
38+
public TResponse Current { get; }
39+
}
40+
3241
public abstract class BaseDriver : IDriver
3342
{
3443
protected readonly DriverConfig Config;
@@ -95,7 +104,7 @@ public ServerStream<TResponse> ServerStreamCall<TRequest, TResponse>(
95104
return new ServerStream<TResponse>(call, e => { OnRpcError(endpoint, e); });
96105
}
97106

98-
public BidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TRequest, TResponse>(
107+
public IBidirectionalStream<TRequest, TResponse> BidirectionalStreamCall<TRequest, TResponse>(
99108
Method<TRequest, TResponse> method,
100109
GrpcRequestSettings settings)
101110
where TRequest : class
@@ -213,7 +222,7 @@ public async ValueTask<bool> MoveNextAsync()
213222
}
214223
}
215224

216-
public sealed class BidirectionalStream<TRequest, TResponse> : IDisposable
225+
public class BidirectionalStream<TRequest, TResponse> : IBidirectionalStream<TRequest, TResponse>
217226
{
218227
private readonly AsyncDuplexStreamingCall<TRequest, TResponse> _stream;
219228
private readonly Action<RpcException> _rpcErrorAction;

src/Ydb.Sdk/src/Pool/ChannelPool.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public GrpcChannel CreateChannel(string endpoint)
134134

135135
return true;
136136
};
137+
// https://github.com/grpc/grpc-dotnet/issues/2312#issuecomment-1790661801
138+
httpHandler.Properties["__GrpcLoadBalancingDisabled"] = true;
137139

138140
channelOptions.HttpHandler = httpHandler;
139141
channelOptions.DisposeHttpClient = true;

src/Ydb.Sdk/src/Services/Topic/Deserializer.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,15 @@ private class Int64Deserializer : IDeserializer<long>
5555
{
5656
public long Deserialize(byte[] data)
5757
{
58-
if (data.Length != 8)
59-
{
60-
throw new ArgumentException(
61-
$"Deserializer<Long> encountered data of length ${data.Length}. Expecting data length to be 8");
62-
}
63-
64-
return ((long)data[0] << 56) | ((long)data[1] << 48) | ((long)data[2] << 40) | ((long)data[3] << 32) |
65-
((long)data[4] << 24) | ((long)data[5] << 16) | ((long)data[6] << 8) | data[7];
58+
return BitConverter.ToInt64(data);
6659
}
6760
}
6861

6962
private class Int32Deserializer : IDeserializer<int>
7063
{
7164
public int Deserialize(byte[] data)
7265
{
73-
if (data.Length != 4)
74-
{
75-
throw new ArgumentException(
76-
$"Deserializer<Int32> encountered data of length ${data.Length}. Expecting data length to be 4");
77-
}
78-
79-
return (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
66+
return BitConverter.ToInt32(data);
8067
}
8168
}
8269

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
namespace Ydb.Sdk.Services.Topic;
22

3-
public class YdbTopicException : Exception
3+
public class WriterException : Exception
44
{
5-
protected YdbTopicException(string message) : base(message)
5+
public WriterException(string message) : base(message)
66
{
77
}
8-
}
98

10-
public class YdbWriterException : YdbTopicException
11-
{
12-
public YdbWriterException(string message) : base(message)
9+
public WriterException(string message, Status status) : base(message + ": " + status)
10+
{
11+
}
12+
13+
public WriterException(string message, Exception inner) : base(message, inner)
1314
{
1415
}
1516
}
1617

17-
public class YdbReaderException : YdbTopicException
18+
public class ReaderException : Exception
1819
{
19-
protected YdbReaderException(string message) : base(message)
20+
protected ReaderException(string message) : base(message)
2021
{
2122
}
2223
}

src/Ydb.Sdk/src/Services/Topic/IWriter.cs

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

33
namespace Ydb.Sdk.Services.Topic;
44

5-
public interface IWriter<TValue>
5+
public interface IWriter<TValue> : IDisposable
66
{
7-
public Task<WriteResult> WriteAsync(TValue data);
7+
public Task<WriteResult> WriteAsync(TValue data, CancellationToken cancellationToken = default);
88

9-
public Task<WriteResult> WriteAsync(Message<TValue> message);
9+
public Task<WriteResult> WriteAsync(Message<TValue> message, CancellationToken cancellationToken = default);
1010
}

src/Ydb.Sdk/src/Services/Topic/Reader/ReaderBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Task<IReader<TValue>> Build()
2222
// Deserializer ?? (IDeserializer<TValue>)(
2323
// Deserializers.DefaultDeserializers.TryGetValue(typeof(TValue), out var deserializer)
2424
// ? deserializer
25-
// : throw new YdbWriterException("The serializer is not set")
25+
// : throw new WriterException("The serializer is not set")
2626
// )
2727
// );
2828
//

src/Ydb.Sdk/src/Services/Topic/Serializer.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,15 @@ private class Int64Serializer : ISerializer<long>
4949
{
5050
public byte[] Serialize(long data)
5151
{
52-
return new[]
53-
{
54-
(byte)(data >> 56),
55-
(byte)(data >> 48),
56-
(byte)(data >> 40),
57-
(byte)(data >> 32),
58-
(byte)(data >> 24),
59-
(byte)(data >> 16),
60-
(byte)(data >> 8),
61-
(byte)data
62-
};
52+
return BitConverter.GetBytes(data);
6353
}
6454
}
6555

6656
private class Int32Serializer : ISerializer<int>
6757
{
6858
public byte[] Serialize(int data)
6959
{
70-
return new[]
71-
{
72-
(byte)(data >> 24),
73-
(byte)(data >> 16),
74-
(byte)(data >> 8),
75-
(byte)data
76-
};
60+
return BitConverter.GetBytes(data);
7761
}
7862
}
7963

0 commit comments

Comments
 (0)