-
Notifications
You must be signed in to change notification settings - Fork 0
CLI Usage
Ksql.Linq.Cli is a .NET tool that can generate KSQL DDL scripts and Avro schemas from your design-time context (KsqlContext / IDesignTimeKsqlContextFactory).
Example: install as a global tool
dotnet tool install -g Ksql.Linq.Cli
Generate KSQL DDL scripts (including CREATE STREAM/TABLE and CSAS/CTAS) from a design-time KsqlContext.
dotnet ksql script ^
--project ./src/MyApp/MyApp.csproj ^
--output ./ksql/generated.sql ^
--verbose- Loads the target assembly and obtains a
KsqlContextviaIDesignTimeKsqlContextFactory. - Uses
DefaultKsqlScriptBuilderto generate DDL. -
WITH (...)clauses includeKAFKA_TOPIC,VALUE_FORMAT,PARTITIONS,REPLICAS,RETENTION_MS,VALUE_SCHEMA_SUBJECT, and more.
Generate value Avro schemas for entities registered in the design-time KsqlContext and write them as .avsc files.
dotnet ksql avro ^
--project ./src/MyApp/MyApp.csproj ^
--output ./schemas/ ^
--verbose- Internally calls
DefaultAvroSchemaExporter.ExportValueSchemas(context)to obtain aDictionary<string, string>
(key: entity type name, value: Avro schema JSON). - Writes files under the directory specified by
--outputusing<TypeName>.avscnaming,
e.g.Examples_DesigntimeKsqlScript_OrderEvent.avsc.
The following options apply to Ksql.Linq.Cli 1.0.0 and later (earlier 0.9.x versions are mostly compatible unless otherwise noted).
-
-p, --project(required)
Path to the target project or DLL.
This assembly must contain a design-timeKsqlContextand anIDesignTimeKsqlContextFactory. -
-c, --context
Name of theKsqlContextclass to use when multiple design-time contexts/factories are available in the same assembly. -
-o, --output- For
script: file path to write the generated KSQL script. - For
avro(required): directory where generated.avscfiles are written; created if it does not already exist. - If omitted (where allowed), results are written to standard output.
- For
-
--config
Path to anappsettings.jsonfile to use for configuration instead of the default location. -
-v, --verbose
Outputs detailed logs about CLI processing (target assembly, selected context, entities, output paths, etc.).
Ksql.Linq.Cli also provides an ai-assist command that helps you use modern AI coding assistants (ChatGPT, Claude, Gemini, Copilot, etc.) together with Ksql.Linq.
Basic flow:
- Ensure the CLI is installed (v1.0.0 or later):
dotnet tool install --global Ksql.Linq.Cli --version 1.0.0
- Copy the AI Assistant Guide (
AI_ASSISTANT_GUIDE.md) to your clipboard:dotnet ksql ai-assist --copy
- Paste it into your AI console and ask the assistant to act as a design partner for your Ksql.Linq project (schema design, windowing strategy, CLI usage, etc.).
The guide contains prompt patterns, recommended workflows, and anti-patterns tailored to Ksql.Linq, so AI suggestions stay aligned with the library’s model and conventions.
- Prepare a dedicated design-time
KsqlContext(for example, withIsDesignTime = trueandSkipSchemaRegistration = true) separate from the runtime context. - Implement
IDesignTimeKsqlContextFactorysimilarly to theexamples/designtime-ksql-*samples. - Run
dotnet ksql scriptanddotnet ksql avroin CI/CD or local development to continuously generate and manage DDL and Avro schemas.
You can see end-to-end usage of a design-time KsqlContext and factory in the following examples from the main repository:
-
examples/designtime-ksql-script
Minimal design-time context (OrdersKsqlContext+OrdersDesignTimeKsqlContextFactory) that produces KSQL DDL for a simple event and summary view.
Example: generate a KSQL script from this sample:cd path/to/Ksql.Linq dotnet ksql script ^ --project ./examples/designtime-ksql-script/DesigntimeKsqlScript.csproj ^ --output ./ksql/designtime-orders.sql ^ --verbose -
examples/designtime-ksql-tumbling
Design-time context (TumblingKsqlContext+TumblingDesignTimeKsqlContextFactory) that focuses on Tumbling-window aggregations (usingTumbling(...),GroupBy,WindowStart(), etc.).
Example: generate a KSQL script (including the Tumbling view) from this sample:cd path/to/Ksql.Linq dotnet ksql script ^ --project ./examples/designtime-ksql-tumbling/DesigntimeKsqlTumbling.csproj ^ --output ./ksql/designtime-tumbling.sql ^ --verbose
Guide
Core Concepts
Tumbling
- Tumbling-Overview
- Tumbling-Definition
- Tumbling-Consumption
- Tumbling-Topics-Config
- Tumbling-State-Store
- Tumbling-Schedule-Last
- Tumbling-Migration
Operations
- Produce-Consume-and-DLQ
- Operations-Startup-and-Monitoring (Index)
- Operations-Startup
- Operations-Startup-Warmup
- Lag-Monitoring-and-Tuning
- Streamiz-Clear
- Appsettings
- Appsettings-Kafka
- Examples
- CLI-Usage
Operations (Runtime)
Reference