Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using Dapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
Expand All @@ -18,18 +19,17 @@
var stopwatch = Stopwatch.StartNew();
stopwatch.Start();

await using var dataSource = new YdbDataSource(
new YdbConnectionStringBuilder(connectionString)
{
CredentialsProvider = new MetadataProvider(loggerFactory: loggerFactory),
LoggerFactory = loggerFactory,
DisableDiscovery = true
}
);
await using var ydbDataSource = new YdbDataSource(new YdbConnectionStringBuilder(connectionString)
{
CredentialsProvider = new MetadataProvider(loggerFactory: loggerFactory),
LoggerFactory = loggerFactory,
DisableDiscovery = true,
EnableImplicitSession = true
});

await using var ydbCommand = dataSource.CreateCommand();
ydbCommand.CommandText = "SELECT 'Hello Serverless YDB from Yandex Cloud Serverless Container!'u";
var scalar = await ydbCommand.ExecuteScalarAsync();
await using var ydbConnection = await ydbDataSource.OpenRetryableConnectionAsync();
var scalar = await ydbConnection.ExecuteScalarAsync<string>(
"SELECT 'Hello Serverless YDB from Yandex Cloud Serverless Container!'u");
stopwatch.Stop();

logger.LogInformation("Success request! [Ms: {Ms}], {Select}", stopwatch.ElapsedMilliseconds, scalar);
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,32 @@ to [Yandex Cloud Serverless Containers](https://yandex.cloud/en/docs/serverless-
## Getting started

1. **Setup** [Yandex Container Registry](https://yandex.cloud/en/docs/container-registry/operations/registry/registry-create).
2. **Build and Push Docker Image**
2. **Configure YDB Connection String**. Update the `appsettings.json` file with your YDB connection details:
```json
{
"ConnectionStrings": {
"ServerlessYDB": "UseTls=true;Host=<your-ydb-host>;Port=2135;Database=<your-database-path>"
}
}
```
Replace `<your-ydb-host>` with your YDB endpoint host and `<your-database-path>` with your database path (e.g., `/ru-central1/b1g8ejbxxxxxxxx/etn8xxxxxxxx`).
3. **Build and Push Docker Image**
```bash
docker build . -t cr.yandex/<container-registry-id>/ado-net-app:latest
docker push cr.yandex/<container-registry-id>/ado-net-app:latest
```
Replace <container-registry-id> with your actual Container Registry ID.
3. **Grant Required Permissions**. To enable your Serverless Container to access both YDB and your container image in
4. **Grant Required Permissions**. To enable your Serverless Container to access both YDB and your container image in
the Container Registry, grant the following roles to your Service Account:

- `ydb.editor` — access to YDB,
- `container-registry.images.puller` — permission to pull images from Container Registry.

4. **Create a new revision**. After pushing your image, create a new version of the Serverless Container as described in
5. **Create a new revision**. After pushing your image, create a new version of the Serverless Container as described in
the [official guide](https://yandex.cloud/en/docs/serverless-containers/quickstart/container#create-revision).
Specify your image and the necessary environment variables and secrets.

5. **Running the Yandex Serverless Container**.
6. **Running the Yandex Serverless Container**.
After the new revision has been rolled out, you can use your container (e.g., for a health check) by executing the
following command:
```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0"/>
<PackageReference Include="NLog.Extensions.Logging" Version="5.5.0"/>
<PackageReference Include="Ydb.Sdk.Yc.Auth" Version="0.2.0"/>
<PackageReference Include="Ydb.Sdk" Version="0.18.0"/>
<PackageReference Include="Ydb.Sdk" Version="0.24.0"/>
<PackageReference Include="Dapper" Version="2.1.35"/>

<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
6 changes: 3 additions & 3 deletions examples/Ydb.Sdk.Topic.QuickStart/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.Extensions.Logging;
using Ydb.Sdk;
using Ydb.Sdk.Services.Topic;
using Ydb.Sdk.Services.Topic.Reader;
using Ydb.Sdk.Services.Topic.Writer;
using Ydb.Sdk.Topic;
using Ydb.Sdk.Topic.Reader;
using Ydb.Sdk.Topic.Writer;

const int countMessages = 100;
const string topicName = "topic_name";
Expand Down
10 changes: 5 additions & 5 deletions slo/src/TopicService/SloTopicContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using Microsoft.Extensions.Logging;
using Ydb.Sdk;
using Ydb.Sdk.Ado;
using Ydb.Sdk.Services.Topic;
using Ydb.Sdk.Services.Topic.Reader;
using Ydb.Sdk.Services.Topic.Writer;
using Ydb.Sdk.Topic;
using Ydb.Sdk.Topic.Reader;
using Ydb.Sdk.Topic.Writer;

namespace TopicService;

Expand Down Expand Up @@ -332,7 +332,7 @@ int partitionId
}

private static void CheckMessage(ConcurrentDictionary<long, ConcurrentQueue<string>> localStore,
Ydb.Sdk.Services.Topic.Reader.Message<string> message)
Ydb.Sdk.Topic.Reader.Message<string> message)
{
if (localStore.TryGetValue(message.PartitionId, out var partition))
{
Expand Down Expand Up @@ -363,7 +363,7 @@ private static string PrintLocalStore(ConcurrentDictionary<long, ConcurrentQueue
string.Join("\n", localStore.Select(pair => pair.Key + ": " + string.Join(", ", pair.Value))) +
"]";

private static void AssertMessage(Ydb.Sdk.Services.Topic.Reader.Message<string> message, string expectedMessageData)
private static void AssertMessage(Ydb.Sdk.Topic.Reader.Message<string> message, string expectedMessageData)
{
if (expectedMessageData == message.Data)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Ydb.Sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- **Breaking Change**: `Ydb.Sdk.Services.Topic` moved to `Ydb.Sdk.Topic`.

## v0.24.0

- **Breaking Change**: Renamed properties in `YdbConnectionStringBuilder`:
Expand All @@ -18,7 +20,7 @@
- Fixed bug ADO.NET/PoolManager: `SemaphoreSlim.WaitAsync` over-release on cancellation.
- Feat ADO.NET: Mark `YdbConnection.State` as `Broken` when the underlying session is broken, including background deactivation.
- Feat ADO.NET: Added YdbDataSource `ExecuteAsync` and `ExecuteInTransaction` convenience methods.
- **Breaking Change**: moved and renamed `Ydb.Sdk.Services.Query.TxMode` -> `Ydb.Sdk.Ado.TransactionMode`.
- **Breaking Change**: `Ydb.Sdk.Services.Query.TxMode` moved to `Ydb.Sdk.Ado.TransactionMode`.
- Feat ADO.NET: Cache gRPC transport by `gRPCConnectionString` to reuse channels.
- Fixed bug wrap-around ADO.NET: Big parameterized Decimal — `((ulong)bits[1] << 32)` -> `((ulong)(uint)bits[1] << 32)`.
- Feat ADO.NET: Parameterized Decimal overflow check: `Precision` and `Scale`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;

namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

public interface IDeserializer<out TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

public class WriterException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Ydb.Sdk.Services.Topic.Reader;
using Ydb.Sdk.Topic.Reader;

namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

public interface IReader<TValue> : IAsyncDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Ydb.Sdk.Services.Topic.Writer;
using Ydb.Sdk.Topic.Writer;

namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

public interface IWriter<TValue> : IAsyncDisposable
{
Expand All @@ -13,7 +13,7 @@ public interface IWriter<TValue> : IAsyncDisposable
/// A Task which will complete with a delivery report corresponding to the produce request,
/// or an exception if an error occured.
/// </returns>
/// <exception cref="T:Ydb.Sdk.Services.Topic.WriterException">
/// <exception cref="Ydb.Sdk.Topic.WriterException">
/// Thrown in response to any write request that was unsuccessful for any reason.
/// </exception>
public Task<WriteResult> WriteAsync(TValue data, CancellationToken cancellationToken = default);
Expand All @@ -27,7 +27,7 @@ public interface IWriter<TValue> : IAsyncDisposable
/// A Task which will complete with a delivery report corresponding to the produce request,
/// or an exception if an error occured.
/// </returns>
/// <exception cref="T:Ydb.Sdk.Services.Topic.WriterException">
/// <exception cref="Ydb.Sdk.Topic.WriterException">
/// Thrown in response to any write request that was unsuccessful for any reason.
/// </exception>
public Task<WriteResult> WriteAsync(Message<TValue> message, CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

public record Metadata(string Key, byte[] Value);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using Ydb.Topic;

namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

internal class InternalBatchMessages<TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Immutable;
using Ydb.Topic;

namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

public class Message<TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Concurrent;
using Microsoft.Extensions.Logging;

namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

internal class PartitionSession
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Ydb.Topic.V1;
using static Ydb.Topic.StreamReadMessage.Types.FromServer;

namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

using MessageFromClient = StreamReadMessage.Types.FromClient;
using MessageFromServer = StreamReadMessage.Types.FromServer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;

namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

public class ReaderBuilder<TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;

namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

internal class ReaderConfig
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Ydb.Sdk.Services.Topic.Reader;
namespace Ydb.Sdk.Topic.Reader;

internal static class Utils
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;

namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

public interface ISerializer<in TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

/// <summary>
/// Create topic request sent from client to server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Ydb.Topic;
using Ydb.Topic.V1;

namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

/// <summary>
/// Client for YDB Topic service operations.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;

namespace Ydb.Sdk.Services.Topic;
namespace Ydb.Sdk.Topic;

internal abstract class TopicSession<TFromClient, TFromServer> : IAsyncDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Ydb.Sdk.Services.Topic.Writer;
namespace Ydb.Sdk.Topic.Writer;

public class Message<TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Ydb.Topic;

namespace Ydb.Sdk.Services.Topic.Writer;
namespace Ydb.Sdk.Topic.Writer;

public class WriteResult
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Ydb.Topic;
using Ydb.Topic.V1;

namespace Ydb.Sdk.Services.Topic.Writer;
namespace Ydb.Sdk.Topic.Writer;

using MessageData = StreamWriteMessage.Types.WriteRequest.Types.MessageData;
using MessageFromClient = StreamWriteMessage.Types.FromClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Ydb.Sdk.Services.Topic.Writer;
namespace Ydb.Sdk.Topic.Writer;

public class WriterBuilder<TValue>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text;

namespace Ydb.Sdk.Services.Topic.Writer;
namespace Ydb.Sdk.Topic.Writer;

internal class WriterConfig
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Xunit;
using Ydb.Sdk.Services.Topic;
using Ydb.Sdk.Services.Topic.Reader;
using Ydb.Sdk.Services.Topic.Writer;
using Ydb.Sdk.Topic.Reader;
using Ydb.Sdk.Topic.Writer;

namespace Ydb.Sdk.Topic.Tests;

Expand Down
3 changes: 1 addition & 2 deletions src/Ydb.Sdk/test/Ydb.Sdk.Topic.Tests/ReaderUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
using Xunit;
using Ydb.Issue;
using Ydb.Sdk.Ado;
using Ydb.Sdk.Services.Topic;
using Ydb.Sdk.Services.Topic.Reader;
using Ydb.Sdk.Topic.Reader;
using Ydb.Topic;
using Range = Moq.Range;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Xunit;
using Ydb.Sdk.Services.Topic;

namespace Ydb.Sdk.Topic.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Google.Protobuf.WellKnownTypes;
using Xunit;
using Ydb.Sdk.Services.Topic;
using Ydb.Sdk.Services.Topic.Writer;
using Ydb.Sdk.Topic.Writer;
using Ydb.Topic;
using Ydb.Topic.V1;
using Consumer = Ydb.Sdk.Services.Topic.Consumer;

namespace Ydb.Sdk.Topic.Tests;

Expand Down
4 changes: 1 addition & 3 deletions src/Ydb.Sdk/test/Ydb.Sdk.Topic.Tests/WriterUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using Xunit;
using Ydb.Issue;
using Ydb.Sdk.Ado;
using Ydb.Sdk.Services.Topic;
using Ydb.Sdk.Services.Topic.Writer;
using Ydb.Sdk.Topic.Writer;
using Ydb.Topic;
using Codec = Ydb.Sdk.Services.Topic.Codec;
using Range = Moq.Range;

namespace Ydb.Sdk.Topic.Tests;
Expand Down
Loading