Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
44 changes: 42 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
timeout-minutes: 5
outputs:
code: ${{ github.event_name != 'pull_request' && 'true' || steps.filter.outputs.code }}
docs: ${{ github.event_name != 'pull_request' && 'true' || steps.filter.outputs.docs }}
steps:
- name: Filter changed paths
id: filter
Expand Down Expand Up @@ -73,6 +74,45 @@ jobs:
- 'nuget.config'
- '.editorconfig'
- '.gitattributes'
docs:
- 'README.md'
- 'docs/docs/**'
- 'src/**'
- 'tests/Dekaf.DocTests/**'
- 'Directory.Build.props'
- 'Directory.Build.targets'
- 'Directory.Packages.props'
Comment on lines +77 to +84

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run the docs gate when its workflow changes

The inspected doc-snippets job is controlled by this docs output, but .github/workflows/ci.yml is absent from the allowlist. Consequently, a PR that changes only the job's command or setup marks doc-snippets as skipped; the separate code filter runs the full solution, which does not include Dekaf.DocTests, and ci-passed explicitly accepts skipped jobs. Include this workflow among the docs inputs so changes to the gate itself are exercised.

Useful? React with 👍 / 👎.


doc-snippets:
name: Documentation Snippets
needs: changes
if: needs.changes.outputs.docs == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-quality: 'preview'

- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/Directory.Packages.props', '**/Directory.Build.props', '**/Directory.Build.targets') }}
restore-keys: nuget-${{ runner.os }}-

- name: Compile documentation snippets
run: dotnet run --project tests/Dekaf.DocTests --configuration Release --framework net10.0 -- --repository-root .

nuget-audit:
name: NuGet Vulnerability Audit
Expand Down Expand Up @@ -122,7 +162,7 @@ jobs:
if-no-files-found: warn
retention-days: 30

# The ONLY job that compiles the solution. Runs net10.0 unit tests inline and
# The ONLY job that compiles the full solution. Runs net10.0 unit tests inline and
# ships the built test binaries to every downstream test job as one tarball
# (tar preserves the apphost executable bit; single-file upload is fast).
build:
Expand Down Expand Up @@ -785,7 +825,7 @@ jobs:
# release-only jobs skip on PR runs).
ci-passed:
name: CI Passed
needs: [changes, build, unit-net8, leak-gates-debug, integration, eventhubs-integration, aot-smoke, aot-integration-publish, aot-integration-smoke, release-matrix, release-matrix-aot, publish, code-quality, nuget-audit]
needs: [changes, doc-snippets, build, unit-net8, leak-gates-debug, integration, eventhubs-integration, aot-smoke, aot-integration-publish, aot-integration-smoke, release-matrix, release-matrix-aot, publish, code-quality, nuget-audit]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/compression.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ using Dekaf;
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.UseLz4Compression()
.WithLingerMs(5) // Wait up to 5ms to fill batches
.WithLinger(TimeSpan.FromMilliseconds(5)) // Wait up to 5ms to fill batches
.WithBatchSize(65536) // 64KB batches
.BuildAsync();
```
Expand Down
9 changes: 4 additions & 5 deletions docs/docs/configuration/consumer-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ builder.Services.AddDekaf(dekaf =>
dekaf.AddConsumer<string, Order>(
builder.Configuration.GetSection("Kafka:Consumers:Orders"),
consumer => consumer
.WithValueDeserializer(new JsonDeserializer<Order>())
.WithValueDeserializer(new JsonSerializer<Order>())
.SubscribeTo("orders"));
});
```
Expand Down Expand Up @@ -273,8 +273,7 @@ it is the sole reservation. Coordinator responses do not consume this budget. Ob
How long before consumer is considered dead:

```csharp
.WithSessionTimeout(45000) // 45 seconds (default)
.WithSessionTimeout(TimeSpan.FromSeconds(45)) // Same, using TimeSpan
.WithSessionTimeout(TimeSpan.FromSeconds(45)) // Default
```

## Subscription
Expand Down Expand Up @@ -407,8 +406,8 @@ Setting a callback enables TLS for the connection.
Custom deserializers:

```csharp
.WithKeyDeserializer(new JsonDeserializer<OrderKey>())
.WithValueDeserializer(new JsonDeserializer<Order>())
.WithKeyDeserializer(new JsonSerializer<OrderKey>())
.WithValueDeserializer(new JsonSerializer<Order>())
```

## Advanced Settings
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/configuration/presets.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForHighThroughput()
.WithAcks(Acks.All) // Override: want reliability too
.WithLingerMs(10) // Override: even more batching
.WithLinger(TimeSpan.FromMilliseconds(10)) // Override: even more batching
.BuildAsync();
```

Expand Down Expand Up @@ -181,7 +181,7 @@ public static class DekafPresets
return builder
.ForReliability()
.UseLz4Compression()
.WithLingerMs(1); // Slight batching for efficiency
.WithLinger(TimeSpan.FromMilliseconds(1)); // Slight batching for efficiency
}

public static ConsumerBuilder<TKey, TValue> ForOrderProcessing<TKey, TValue>(
Expand Down Expand Up @@ -224,9 +224,9 @@ using Dekaf;
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithAcks(Acks.All)
.WithLingerMs(2)
.WithLinger(TimeSpan.FromMilliseconds(2))
.WithBatchSize(32768)
.EnableIdempotence()
.WithIdempotence(true)
.UseZstdCompression()
.BuildAsync();
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/consumer/dead-letter-queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ builder.Services.AddDekaf(dekaf =>
consumer => consumer
.WithBootstrapServers("localhost:9092")
.WithGroupId("orders-service")
.WithValueDeserializer(new JsonDeserializer<Order>()),
.WithValueDeserializer(new JsonSerializer<Order>()),
dlq => dlq
.WithMaxFailures(3));
});
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/dependency-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ builder.Services.AddDekaf(dekaf =>
"orders",
builder.Configuration.GetSection("Kafka:Consumers:Orders"),
consumer => consumer
.WithValueDeserializer(new JsonDeserializer<Order>())
.WithValueDeserializer(new JsonSerializer<Order>())
.SubscribeTo("orders"));
});
```
Expand Down Expand Up @@ -301,7 +301,7 @@ builder.Services.AddDekaf(dekaf =>
dekaf.AddConsumer<string, Order>(
kafka.GetSection("Consumers:Orders"),
consumer => consumer
.WithValueDeserializer(new JsonDeserializer<Order>())
.WithValueDeserializer(new JsonSerializer<Order>())
.SubscribeTo("orders"));

dekaf.AddAdminClient(kafka.GetSection("Admin"));
Expand Down Expand Up @@ -333,7 +333,7 @@ builder.Services.AddDekaf(dekaf =>
GroupId = "orders"
},
consumer => consumer
.WithValueDeserializer(new JsonDeserializer<Order>())
.WithValueDeserializer(new JsonSerializer<Order>())
.SubscribeTo("orders"));

dekaf.AddAdminClient(
Expand Down Expand Up @@ -400,7 +400,7 @@ builder.Services.AddDekaf(dekaf =>
dekaf.AddConsumerService<OrderProcessorService, string, Order>(consumer => consumer
.WithBootstrapServers(kafkaConfig["BootstrapServers"]!)
.WithGroupId(kafkaConfig["GroupId"]!)
.WithValueDeserializer(new JsonDeserializer<Order>()));
.WithValueDeserializer(new JsonSerializer<Order>()));
});

var app = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/hosted-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ builder.Services.AddDekaf(dekaf =>
dekaf.AddConsumerService<OrderProcessorService, string, Order>(consumer => consumer
.WithBootstrapServers(builder.Configuration["Kafka:BootstrapServers"]!)
.WithGroupId("orders-service")
.WithValueDeserializer(new JsonDeserializer<Order>()));
.WithValueDeserializer(new JsonSerializer<Order>()));
});
```

Expand Down
12 changes: 6 additions & 6 deletions docs/docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ var producer = await Kafka.CreateProducer<string, string>()
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithAcks(Acks.Leader) // Don't wait for all replicas
.WithLingerMs(5) // Batch for 5ms
.WithLinger(TimeSpan.FromMilliseconds(5)) // Batch for 5ms
.WithBatchSize(65536) // 64KB batches
.WithCompression(CompressionType.Lz4) // Fast compression
.UseCompression(CompressionType.Lz4) // Fast compression
.BuildAsync();
```

Expand All @@ -157,7 +157,7 @@ var producer = await Kafka.CreateProducer<string, string>()
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithAcks(Acks.Leader)
.WithLingerMs(0) // Send immediately
.WithLinger(TimeSpan.Zero) // Send immediately
.WithBatchSize(16384) // Smaller batches
.BuildAsync();
```
Expand Down Expand Up @@ -255,7 +255,7 @@ using Dekaf;
// LZ4 for balanced performance
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithCompression(CompressionType.Lz4)
.UseCompression(CompressionType.Lz4)
.BuildAsync();
```

Expand Down Expand Up @@ -383,11 +383,11 @@ The default batch settings are conservative. If you can tolerate some latency, b

```csharp
// High latency tolerance, maximize throughput
.WithLingerMs(100)
.WithLinger(TimeSpan.FromMilliseconds(100))
.WithBatchSize(1048576)

// Low latency required
.WithLingerMs(0)
.WithLinger(TimeSpan.Zero)
.WithBatchSize(16384)
```

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/producer/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ using Dekaf;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithLingerMs(5) // Wait up to 5ms to collect more messages
.WithLinger(TimeSpan.FromMilliseconds(5)) // Wait up to 5ms to collect more messages
.WithBatchSize(65536) // Maximum batch size in bytes
.BuildAsync();
```
Expand Down Expand Up @@ -147,7 +147,7 @@ using Dekaf;

var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.EnableIdempotence()
.WithIdempotence(true)
.BuildAsync();
```

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/producer/fire-and-forget.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ using Dekaf;
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.ForHighThroughput() // Preset with good defaults
.WithLingerMs(10) // Allow more time for batching
.WithLinger(TimeSpan.FromMilliseconds(10)) // Allow more time for batching
.WithBatchSize(131072) // Larger batches (128KB)
.UseLz4Compression() // Compress batches
.BuildAsync();
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/producer/partitioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ using Dekaf;
var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithPartitioner(PartitionerType.Sticky)
.WithLingerMs(5)
.WithLinger(TimeSpan.FromMilliseconds(5))
.BuildAsync();

// These will likely batch together in one partition
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/producer/topic-producer.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using Dekaf;
await using var producer = await Kafka.CreateProducer<string, string>()
.WithBootstrapServers("localhost:9092")
.WithAcks(Acks.All)
.EnableIdempotence()
.WithIdempotence(true)
.BuildForTopicAsync("orders");

await producer.ProduceAsync("order-123", orderJson);
Expand Down
16 changes: 16 additions & 0 deletions docs/docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ description: "Dekaf.Testing provides in-memory producers and consumers for fast

The cluster stores serialized bytes, not typed values, so custom serializers and deserializers still run during tests.

## Documentation snippet gate

CI extracts every C# fence from this documentation and the README, then compiles each snippet against the current source projects. Shell examples are checked against packable package IDs and existing project paths. New C# fences compile by default.

Run the gate locally with:

```bash
dotnet run --project tests/Dekaf.DocTests --configuration Release --framework net10.0 -- --repository-root .
```

Dekaf's existing documentation contains many legacy snippets that are not yet standalone. Their exact source and compiler diagnostics are pinned by `KnownFailures.sha256`; any source or API change invalidates the baseline and requires review. Prefer making a fragment standalone. When application-specific context would obscure the example, exclude it explicitly with a reason immediately before the fence:

```markdown
<!-- doc-test-ignore: Application transport implementation is omitted. -->
```

## Direct use

```csharp
Expand Down
22 changes: 22 additions & 0 deletions tests/Dekaf.DocTests/Dekaf.DocTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\**\*.csproj"
Exclude="..\..\src\Dekaf.SchemaRegistry.Avro.Poco.Generator\*.csproj" />
</ItemGroup>

</Project>
Loading
Loading