Skip to content

Commit 3cd69c3

Browse files
authored
Merge pull request #13 from DEMCON/libstored-2.0.0
Libstored 2.0.0
2 parents 1606433 + e5b66fa commit 3cd69c3

File tree

13 files changed

+356
-64
lines changed

13 files changed

+356
-64
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ flowchart TD
5757
- TerminalLayer
5858
- Crc8Layer (0xA6)
5959
- Crc16Layer (0xBAAD)
60+
- Crc32Layer (reversed 0x04c11db7)
6061
- LoggingLayer using ILogger
6162
- LoopbackLayer
6263
- BufferLayer
6364
- SegmentationLayer
6465
- ArqLayer
66+
- IdleCheckLayer
6567

6668
### Transport layers
6769
- ZeroMQ using [NetMQ](https://netmq.readthedocs.io/)
@@ -170,12 +172,15 @@ python -m libstored.gui -p 5555
170172

171173
## Compatibility
172174

173-
Tested with:
174-
- [v1.7.1](https://github.com/DEMCON/libstored/releases/tag/v1.7.1) (see note below)
175+
Tested with libstored versions:
176+
- [v2.0.0](https://github.com/DEMCON/libstored/releases/tag/v2.0.0)
175177
- [v1.8.0](https://github.com/DEMCON/libstored/releases/tag/v1.8.0)
178+
- [v1.7.1](https://github.com/DEMCON/libstored/releases/tag/v1.7.1) (see note below)
176179

177180
See [libstored changelog](https://demcon.github.io/libstored/doc/changelog.html) for the changes. There do not seem to be breaking changes from <v1.7.1 to v1.7.1 for this C# implementation.
178181

182+
Only the latest major version of libstored will be supported.
183+
179184
### libstored >v1.7.1
180185
The ZeroMQ socket type changed from `PAIR` to `DEALER` for the SyncZeroMQLayer. Make sure the exact same socket type is used at both ends of the protocol, so `PAIR` - `PAIR` or `DEALER` - `DEALER`, but not `PAIR` - `DEALER`. When connecting to libstored v1.7.1 or lower, use the `PAIR` socket type. For version v1.8 or higher of libstored, use `DEALER`.
181186

examples/Arq/LibStored.Arq/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Add ARG for libstored version
2-
ARG LIBSTORED_VERSION=1.8.0
2+
ARG LIBSTORED_VERSION=2.0.0
33

44
FROM ubuntu:22.04 as builder
55

66
# Use the ARG after FROM
77
ARG LIBSTORED_VERSION
88

9+
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
10+
911
RUN apt-get update && \
1012
apt-get install -y --no-install-recommends \
1113
build-essential \
@@ -19,6 +21,7 @@ RUN apt-get update && \
1921
plantuml \
2022
python3-venv \
2123
python3-dev \
24+
python3-tk \
2225
lsb-release \
2326
libgl1 \
2427
libegl1 \
@@ -62,4 +65,4 @@ COPY --from=builder /app /app
6265

6366
WORKDIR /app/bin
6467

65-
CMD ["./arq"]
68+
CMD ["./arq"]

examples/Arq/LibStored.Net.Arq.AppHost/AppHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var builder = DistributedApplication.CreateBuilder(args);
44

5-
const string libstoredVersion = "1.8.0";
5+
const string libstoredVersion = "2.0.0";
66
var arq = builder.AddDockerfile("libstored-arq", "../LibStored.Arq/", "Dockerfile")
77
.WithImage("demcon/libstored-arq-example")
88
.WithImageTag(libstoredVersion)

examples/Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<Import Project="..\Directory.Build.props" />
3+
<PropertyGroup>
4+
<!-- Only use a single framework for the examples -->
5+
<TargetFrameworks>net10.0</TargetFrameworks>
6+
<TargetFramework>net10.0</TargetFramework>
7+
</PropertyGroup>
8+
</Project>

examples/Sync/LibStored.Net.Example.AppHost/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Add ARG for libstored version
2-
ARG LIBSTORED_VERSION=1.8.0
2+
ARG LIBSTORED_VERSION=2.0.0
33

44
FROM ubuntu:22.04 as builder
55

66
# Use the ARG after FROM
77
ARG LIBSTORED_VERSION
88

9+
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
10+
911
RUN apt-get update && \
1012
apt-get install -y --no-install-recommends \
1113
build-essential \
@@ -19,6 +21,7 @@ RUN apt-get update && \
1921
plantuml \
2022
python3-venv \
2123
python3-dev \
24+
python3-tk \
2225
lsb-release \
2326
libgl1 \
2427
libegl1 \

examples/Sync/LibStored.Net.Example.AppHost/LibStored.Net.Example.AppHost.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Sdk Name="Aspire.AppHost.Sdk" Version="13.0.0" />
3+
<Sdk Name="Aspire.AppHost.Sdk" Version="13.0.1" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
@@ -10,9 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.0.0" />
14-
<PackageReference Include="Aspire.Hosting.Docker" Version="13.0.0-preview.1.25560.3" />
15-
<PackageReference Include="Aspire.Hosting.Python" Version="13.0.0" />
13+
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.0.1" />
14+
<PackageReference Include="Aspire.Hosting.Docker" Version="13.0.1-preview.1.25575.3" />
15+
<PackageReference Include="Aspire.Hosting.Python" Version="13.0.1" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

examples/Sync/LibStored.Net.Example.AppHost/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
builder.AddDockerComposeEnvironment("docker-compose");
1414

15-
const string libstoredVersion = "1.8.0";
15+
const string libstoredVersion = "2.0.0";
1616
var sync = builder.AddDockerfile("libstored", ".", "Dockerfile")
1717
.WithImage("demcon/libstored")
1818
.WithImageTag(libstoredVersion)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
libstored==1.7.1
1+
libstored==2.0.0

examples/Sync/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Sync Example
2+
3+
This example demonstrates cross-language synchronization between C++ and C# using the [Aspire CLI](https://aspire.dev/docs/cli/). The setup is based on the [8_sync](https://github.com/DEMCON/libstored/tree/main/examples/8_sync) example from the libstored project.
4+
5+
In this example, the C++ code runs inside a container, while the C# implementation runs natively. The `libstored.gui` Python library connects to both the C++ and C# components, allowing you to observe and interact with the synchronizated stores.
6+
7+
## Prerequisites
8+
9+
- [.NET 10 SDK](https://dotnet.microsoft.com/download)
10+
- [Aspire CLI](https://aspire.dev/docs/cli/)
11+
- [Podman](https://podman.io/) or [Docker](https://www.docker.com/products/docker-desktop)
12+
13+
## Running the Example
14+
15+
```sh
16+
aspire run
17+
```
18+
19+
## Learn More
20+
21+
- [Aspire Documentation](https://aspire.dev/docs/)

src/LibStored.Net/Protocol/Crc16Layer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public override void Decode(Span<byte> buffer)
7272
crc = Compute(buffer[i], crc);
7373
}
7474

75-
if (crc != (ushort)(buffer[buffer.Length - 2] << 8 | buffer[buffer.Length - 1]))
75+
if (crc != BinaryPrimitives.ReadUInt16BigEndian(buffer.Slice(buffer.Length - 2, 2)))
7676
{
7777
// CRC mismatch, ignore the packet
7878
_logger?.LogWarning("Invalid crc check: {Actual}, expected: {Expected}", buffer[^1], crc);

0 commit comments

Comments
 (0)