Skip to content

Commit

Permalink
Simplified NATS client (#607)
Browse files Browse the repository at this point in the history
* Simplified NATS client

Moved functionality from NATS.Client package into NATS.Client.Simplified since
We can't use NATS.Client package as it belongs to v1.

* Build fix

* dotnet format
  • Loading branch information
mtmk authored Aug 23, 2024
1 parent 41b1778 commit 23d8169
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ jobs:
steps:
- name: Install nats
run: |
rel=$(curl -s https://api.github.com/repos/nats-io/natscli/releases/latest | jq -r .tag_name | sed s/v//)
rel=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s https://api.github.com/repos/nats-io/natscli/releases/latest | jq -r .tag_name | sed s/v//)
wget https://github.com/nats-io/natscli/releases/download/v$rel/nats-$rel-linux-amd64.zip
unzip nats-$rel-linux-amd64.zip
sudo mv nats-$rel-linux-amd64/nats /usr/local/bin
gh_api_url="https://api.github.com/repos/nats-io/nats-server/releases"
branch="${{ matrix.config.branch }}"
if [[ $branch == "v"* ]]; then
branch=$(curl -s $gh_api_url | jq -r '.[].tag_name' | grep $branch | sort -V | tail -1)
branch=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s $gh_api_url | jq -r '.[].tag_name' | grep $branch | sort -V | tail -1)
elif [[ $branch == "latest" ]]; then
branch=$(curl -s $gh_api_url/latest | jq -r .tag_name)
branch=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s $gh_api_url/latest | jq -r .tag_name)
fi
for i in 1 2 3
do
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
gh_api_url="https://api.github.com/repos/nats-io/nats-server/releases"
branch="${{ matrix.config.branch }}"
if [[ $branch == "v"* ]]; then
branch=$(curl -s $gh_api_url | jq -r '.[].tag_name' | grep $branch | sort -V | tail -1)
branch=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s $gh_api_url | jq -r '.[].tag_name' | grep $branch | sort -V | tail -1)
elif [[ $branch == "latest" ]]; then
branch=$(curl -s $gh_api_url/latest | jq -r .tag_name)
branch=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s $gh_api_url/latest | jq -r .tag_name)
fi
for i in 1 2 3
do
Expand Down Expand Up @@ -122,9 +122,9 @@ jobs:
gh_api_url="https://api.github.com/repos/nats-io/nats-server/releases"
branch="${{ matrix.config.branch }}"
if [[ $branch == "v"* ]]; then
branch=$(curl -s $gh_api_url | jq -r '.[].tag_name' | grep $branch | sort -V | tail -1)
branch=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s $gh_api_url | jq -r '.[].tag_name' | grep $branch | sort -V | tail -1)
elif [[ $branch == "latest" ]]; then
branch=$(curl -s $gh_api_url/latest | jq -r .tag_name)
branch=$(curl -H 'Authorization: token ${{ secrets.AUTH_TOKEN_FOR_GITHUB_API }}' -s $gh_api_url/latest | jq -r .tag_name)
fi
for i in 1 2 3
do
Expand Down
16 changes: 8 additions & 8 deletions NATS.Client.sln
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Net.OpenTelemetry.Test
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Platform.Windows.Tests", "tests\NATS.Client.Platform.Windows.Tests\NATS.Client.Platform.Windows.Tests.csproj", "{A37994CC-A23A-415E-8B61-9468C7178A55}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client", "src\NATS.Client\NATS.Client.csproj", "{48F1F736-3D87-4453-B497-BD9C203B2385}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Client", "sandbox\Example.Client\Example.Client.csproj", "{A15CCDD5-B707-4142-B99A-64F0AB62318A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Tests", "tests\NATS.Client.Tests\NATS.Client.Tests.csproj", "{6DAAAA87-8DDF-4E60-81CE-D8900327DE33}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Simplified.Tests", "tests\NATS.Client.Simplified.Tests\NATS.Client.Simplified.Tests.csproj", "{6DAAAA87-8DDF-4E60-81CE-D8900327DE33}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NATS.Client.Simplified", "src\NATS.Client.Simplified\NATS.Client.Simplified.csproj", "{227C88B1-0510-4010-B142-C44725578FCD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -297,10 +297,6 @@ Global
{A37994CC-A23A-415E-8B61-9468C7178A55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A37994CC-A23A-415E-8B61-9468C7178A55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A37994CC-A23A-415E-8B61-9468C7178A55}.Release|Any CPU.Build.0 = Release|Any CPU
{48F1F736-3D87-4453-B497-BD9C203B2385}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{48F1F736-3D87-4453-B497-BD9C203B2385}.Debug|Any CPU.Build.0 = Debug|Any CPU
{48F1F736-3D87-4453-B497-BD9C203B2385}.Release|Any CPU.ActiveCfg = Release|Any CPU
{48F1F736-3D87-4453-B497-BD9C203B2385}.Release|Any CPU.Build.0 = Release|Any CPU
{A15CCDD5-B707-4142-B99A-64F0AB62318A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A15CCDD5-B707-4142-B99A-64F0AB62318A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A15CCDD5-B707-4142-B99A-64F0AB62318A}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -309,6 +305,10 @@ Global
{6DAAAA87-8DDF-4E60-81CE-D8900327DE33}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DAAAA87-8DDF-4E60-81CE-D8900327DE33}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DAAAA87-8DDF-4E60-81CE-D8900327DE33}.Release|Any CPU.Build.0 = Release|Any CPU
{227C88B1-0510-4010-B142-C44725578FCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{227C88B1-0510-4010-B142-C44725578FCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{227C88B1-0510-4010-B142-C44725578FCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{227C88B1-0510-4010-B142-C44725578FCD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -359,9 +359,9 @@ Global
{474BA453-9CFF-41C2-B2E7-ADD92CC93E86} = {95A69671-16CA-4133-981C-CC381B7AAA30}
{B8554582-DE19-41A2-9784-9B27C9F22429} = {C526E8AB-739A-48D7-8FC4-048978C9B650}
{A37994CC-A23A-415E-8B61-9468C7178A55} = {C526E8AB-739A-48D7-8FC4-048978C9B650}
{48F1F736-3D87-4453-B497-BD9C203B2385} = {4827B3EC-73D8-436D-AE2A-5E29AC95FD0C}
{A15CCDD5-B707-4142-B99A-64F0AB62318A} = {95A69671-16CA-4133-981C-CC381B7AAA30}
{6DAAAA87-8DDF-4E60-81CE-D8900327DE33} = {C526E8AB-739A-48D7-8FC4-048978C9B650}
{227C88B1-0510-4010-B142-C44725578FCD} = {4827B3EC-73D8-436D-AE2A-5E29AC95FD0C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8CBB7278-D093-448E-B3DE-B5991209A1AA}
Expand Down
2 changes: 1 addition & 1 deletion sandbox/Example.Client/Example.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\NATS.Client\NATS.Client.csproj" />
<ProjectReference Include="..\..\src\NATS.Net\NATS.Net.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion sandbox/Example.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// See https://aka.ms/new-console-template for more information

using System.Text;
using NATS.Client;
using NATS.Net;

CancellationTokenSource cts = new();

Expand Down
23 changes: 23 additions & 0 deletions src/NATS.Client.Simplified/NATS.Client.Simplified.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<!-- NuGet Packaging -->
<PackageTags>pubsub;messaging</PackageTags>
<Description>NATS simplified client for .NET</Description>

<IsPackable>true</IsPackable>
<RootNamespace>NATS.Net</RootNamespace>

</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\NATS.Client.Core\NATS.Client.Core.csproj" />
<ProjectReference Include="..\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Threading.Channels;
using NATS.Client.Core;

namespace NATS.Client;
namespace NATS.Net;

/// <summary>
/// Represents a NATS client that provides methods for interacting with NATS server.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NATS.Client.Core;
using NATS.Client.Serializers.Json;

namespace NATS.Client;
namespace NATS.Net;

/// <summary>
/// Default serializer interface for NATS messages.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using NATS.Client.Core;

namespace NATS.Client;
namespace NATS.Net;

/// <summary>
/// Default implementation of the INatsSerializerRegistry interface.
Expand Down
25 changes: 0 additions & 25 deletions src/NATS.Client/NATS.Client.csproj

This file was deleted.

4 changes: 3 additions & 1 deletion src/NATS.Net/NATS.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<!-- NuGet Packaging -->
<PackageTags>pubsub;messaging</PackageTags>
<Description>NATS client for modern .NET.</Description>
<Description>NATS client for modern .NET</Description>
<IsPackable>true</IsPackable>
</PropertyGroup>

Expand All @@ -19,7 +19,9 @@
<ProjectReference Include="..\NATS.Client.JetStream\NATS.Client.JetStream.csproj" />
<ProjectReference Include="..\NATS.Client.KeyValueStore\NATS.Client.KeyValueStore.csproj" />
<ProjectReference Include="..\NATS.Client.ObjectStore\NATS.Client.ObjectStore.csproj" />
<ProjectReference Include="..\NATS.Client.Serializers.Json\NATS.Client.Serializers.Json.csproj" />
<ProjectReference Include="..\NATS.Client.Services\NATS.Client.Services.csproj" />
<ProjectReference Include="..\NATS.Client.Simplified\NATS.Client.Simplified.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Text;
using NATS.Client.Core.Tests;
using NATS.Net;

// ReSharper disable AccessToDisposedClosure
namespace NATS.Client.Tests;
namespace NATS.Client.Simplified.Tests;

public class ClientTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<ItemGroup>
<ProjectReference Include="..\NATS.Client.TestUtilities\NATS.Client.TestUtilities.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client\NATS.Client.csproj"/>
<ProjectReference Include="..\..\src\NATS.Client.Simplified\NATS.Client.Simplified.csproj"/>
</ItemGroup>

</Project>

0 comments on commit 23d8169

Please sign in to comment.