Skip to content

Commit

Permalink
Merge pull request #3 from brianpursley/pgmq-1.2.1
Browse files Browse the repository at this point in the history
Upgrade Npgsql version
  • Loading branch information
brianpursley authored May 23, 2024
2 parents fb20f4e + 5aeabe9 commit 9bcead5
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ jobs:
- name: Build
run: dotnet build --no-restore --configuration Release /p:Version=${{ env.VERSION }} /p:CopyrightYear=$(date +%Y)

- name: Test
- name: Test (latest pgmq version)
run: Npgmq.Test/scripts/run-tests.sh

- name: Test (pgmq 1.1.1)
run: Npgmq.Test/scripts/run-tests.sh 1.1.1

- name: Test (pgmq 1.0.0)
run: Npgmq.Test/scripts/run-tests.sh 1.0.0

Expand Down
20 changes: 20 additions & 0 deletions Npgmq.Example/Npgmq.Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>ffbcfb1f-57f6-4fca-96ae-4a0e2b43c970</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Npgmq\Npgmq.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions Npgmq.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Npgmq;

var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddUserSecrets(Assembly.GetExecutingAssembly())
.Build();

var npgmq = new NpgmqClient(configuration.GetConnectionString("ExampleDB")!);

await npgmq.InitAsync();
await npgmq.CreateQueueAsync("example_queue");

var msgId = await npgmq.SendAsync("example_queue", new MyMessageType
{
Foo = "Test",
Bar = 123
});
Console.WriteLine($"Sent message with id {msgId}");

var msg = await npgmq.ReadAsync<MyMessageType>("example_queue");
if (msg != null)
{
Console.WriteLine($"Read message with id {msg.MsgId}: Foo = {msg.Message?.Foo}, Bar = {msg.Message?.Bar}");
await npgmq.ArchiveAsync("example_queue", msg.MsgId);
}

internal class MyMessageType
{
public string Foo { get; set; } = null!;
public int Bar { get; set; }
}
3 changes: 3 additions & 0 deletions Npgmq.Example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Npgmq.Example

Example project for Npgmq.
1 change: 1 addition & 0 deletions Npgmq.Test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ scripts/run-tests.sh 1.1.1
```

### Start Database Only
This can be helpful if you want to manually run tests, without having to start the database each time.

```bash
scripts/start-db.sh
Expand Down
1 change: 1 addition & 0 deletions Npgmq.Test/scripts/start-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
PGMQ_VERSION=$1

docker run -d --name npgmq_test_db -p 5432:5432 --rm quay.io/tembo/tembo-local
sleep 4

docker exec npgmq_test_db /bin/sh -c "psql -c \"CREATE DATABASE npgmq_test;\""

Expand Down
6 changes: 6 additions & 0 deletions Npgmq.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\build.yml = .github\workflows\build.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Npgmq.Example", "Npgmq.Example\Npgmq.Example.csproj", "{60A266EF-6EFA-42B0-B592-C0C50BC32C7C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -29,6 +31,10 @@ Global
{27C187EE-9298-452F-9FA7-6DF8FC381095}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27C187EE-9298-452F-9FA7-6DF8FC381095}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27C187EE-9298-452F-9FA7-6DF8FC381095}.Release|Any CPU.Build.0 = Release|Any CPU
{60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{60A266EF-6EFA-42B0-B592-C0C50BC32C7C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8C37002D-05C6-4B1F-B4FC-C2F45C5E5328} = {023319FF-914F-42F7-AE34-3BA9CF91DAEE}
Expand Down
2 changes: 1 addition & 1 deletion Npgmq/Npgmq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Npgsql" Version="7.0.6" />
<PackageReference Include="Npgsql" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ using Npgmq;

var npgmq = new NpgmqClient("<YOUR CONNECTION STRING HERE>");

await npgmq.InitAsync();

await npgmq.CreateQueueAsync("my_queue");

var msgId = await npgmq.SendAsync("my_queue", new MyMessageType
Expand All @@ -35,7 +37,7 @@ var msg = await npgmq.ReadAsync<MyMessageType>("my_queue");
if (msg != null)
{
Console.WriteLine($"Read message with id {msg.MsgId}: Foo = {msg.Message?.Foo}, Bar = {msg.Message?.Bar}");
await npgmq.ArchiveAsync("my_queue", msg!.MsgId);
await npgmq.ArchiveAsync("my_queue", msg.MsgId);
}
```

Expand All @@ -59,7 +61,7 @@ var msg = await npgmq.ReadAsync<string>("my_queue");
if (msg != null)
{
Console.WriteLine($"Read message with id {msg.MsgId}: {msg.Message}");
await npgmq.ArchiveAsync("my_queue", msg!.MsgId);
await npgmq.ArchiveAsync("my_queue", msg.MsgId);
}
```

Expand Down

0 comments on commit 9bcead5

Please sign in to comment.