Skip to content

Commit 052af5f

Browse files
committed
Add BLite.Client NuGet README and release publish job
1 parent 618e840 commit 052af5f

2 files changed

Lines changed: 190 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Produces:
66
# • Docker image pushed to ghcr.io/entgldb/blite-server
77
# • Docker image pushed to docker.io/mrdevrobotentgldb/blite-server
8+
# • NuGet package BLite.Client published to nuget.org
89
# • Windows installer (.exe) built with Inno Setup 6
910
# • Linux tarball (.tar.gz) with self-contained binary + install.sh
1011
# • GitHub Release with all artifacts attached
@@ -21,6 +22,41 @@ permissions:
2122
packages: write # push to ghcr.io
2223

2324
jobs:
25+
# ── NuGet package ───────────────────────────────────────────────────────────
26+
nuget-client:
27+
name: Pack & Publish BLite.Client
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout BLite.Server
32+
uses: actions/checkout@v4
33+
with:
34+
path: BLite.Server
35+
36+
- name: Extract version
37+
id: version
38+
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
39+
40+
- name: Setup .NET
41+
uses: actions/setup-dotnet@v4
42+
with:
43+
dotnet-version: "10.0.x"
44+
45+
- name: Pack BLite.Client
46+
run: >
47+
dotnet pack BLite.Server/src/BLite.Client/BLite.Client.csproj
48+
--configuration Release
49+
--output artifacts/nuget
50+
-p:Version=${{ steps.version.outputs.version }}
51+
--nologo
52+
53+
- name: Publish BLite.Client to NuGet.org
54+
run: >
55+
dotnet nuget push "artifacts/nuget/BLite.Client.${{ steps.version.outputs.version }}.nupkg"
56+
--source https://api.nuget.org/v3/index.json
57+
--api-key ${{ secrets.NUGET_API_KEY }}
58+
--skip-duplicate
59+
2460
# ── Docker image ─────────────────────────────────────────────────────────────
2561
docker:
2662
name: Build & Push Docker Image
@@ -193,7 +229,7 @@ jobs:
193229
release:
194230
name: Create GitHub Release
195231
runs-on: ubuntu-latest
196-
needs: [docker, windows-installer, linux-installer]
232+
needs: [nuget-client, docker, windows-installer, linux-installer]
197233

198234
steps:
199235
- name: Download Windows installer

src/BLite.Client/README.md

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,154 @@
1-
# BLite.Client.Net
1+
# BLite.Client
2+
3+
Official .NET SDK for BLite Server over gRPC.
4+
5+
## What You Get
6+
7+
- Typed collections (`IDocumentCollection<TId, T>`)
8+
- Dynamic BSON collections
9+
- LINQ query push-down
10+
- Transactions
11+
- Key-value API
12+
- Admin API (users and tenants)
13+
14+
## Install
15+
16+
```bash
17+
dotnet add package BLite.Client
18+
```
19+
20+
## 1. Connect To BLite Server
21+
22+
```csharp
23+
using BLite.Client;
24+
25+
await using var client = new BLiteClient(new BLiteClientOptions
26+
{
27+
Host = "localhost",
28+
Port = 2626,
29+
ApiKey = "your-api-key",
30+
UseTls = false
31+
});
32+
```
33+
34+
`Port` must point to the gRPC endpoint (`2626` by default).
35+
36+
## 2. Typed Collections (Recommended)
37+
38+
```csharp
39+
using BLite.Bson;
40+
41+
[DocumentMapper("users")]
42+
public class User
43+
{
44+
[BsonId]
45+
public ObjectId Id { get; set; }
46+
47+
public string Name { get; set; } = string.Empty;
48+
public int Age { get; set; }
49+
}
50+
```
51+
52+
Use the generated mapper (for example `UserMapper`) to get a typed collection:
53+
54+
```csharp
55+
var users = client.GetDocumentCollection<ObjectId, User>(new UserMapper());
56+
57+
await users.InsertAsync(new User
58+
{
59+
Id = ObjectId.NewObjectId(),
60+
Name = "Alice",
61+
Age = 30
62+
});
63+
64+
var adults = await users.AsQueryable()
65+
.Where(x => x.Age >= 18)
66+
.OrderBy(x => x.Name)
67+
.ToListAsync();
68+
```
69+
70+
## 3. Dynamic BSON Collections
71+
72+
```csharp
73+
using BLite.Bson;
74+
using BLite.Proto;
75+
76+
var sensors = client.GetDynamicCollection("sensors");
77+
78+
var doc = await sensors.NewDocumentAsync(["name", "temp"], b => b
79+
.AddString("name", "room-1")
80+
.AddDouble("temp", 21.5));
81+
82+
_ = await sensors.InsertAsync(doc);
83+
84+
var q = new QueryDescriptor
85+
{
86+
Collection = "sensors",
87+
Where = new BinaryFilter
88+
{
89+
Field = "temp",
90+
Op = FilterOp.Gt,
91+
Value = ScalarValue.From(20)
92+
}
93+
};
94+
95+
await foreach (var item in sensors.QueryAsync(q))
96+
{
97+
// process item
98+
}
99+
```
100+
101+
## 4. Transactions
102+
103+
```csharp
104+
await using var tx = await client.BeginTransactionAsync();
105+
106+
await users.InsertAsync(new User
107+
{
108+
Id = ObjectId.NewObjectId(),
109+
Name = "Bob",
110+
Age = 41
111+
}, tx);
112+
113+
await tx.CommitAsync();
114+
```
115+
116+
## 5. Key-Value API
117+
118+
```csharp
119+
using System.Text;
120+
121+
await client.Kv.SetAsync("session:abc", Encoding.UTF8.GetBytes("payload"));
122+
var value = await client.Kv.GetAsync("session:abc");
123+
```
124+
125+
## 6. Admin API
126+
127+
```csharp
128+
using BLite.Core.Query;
129+
130+
var createdKey = await client.Admin.CreateUserAsync(
131+
username: "reporting",
132+
namespaceName: null,
133+
databaseId: null,
134+
permissions:
135+
[
136+
new UserPermission
137+
{
138+
Collection = "reports",
139+
Ops = BLiteOperation.Query
140+
}
141+
]);
142+
```
143+
144+
## Notes
145+
146+
- BLite Server must be reachable on gRPC endpoint.
147+
- In production prefer `UseTls = true` and secure secret handling for API keys.
148+
- Unsupported LINQ operators are applied client-side after streaming.
149+
150+
## Links
151+
152+
- BLite Server: https://github.com/EntglDb/BLite.Server
153+
- BLite engine: https://github.com/EntglDb/BLite
2154

0 commit comments

Comments
 (0)