-
Notifications
You must be signed in to change notification settings - Fork 0
feat: implement channel adapter #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99614bd
feat: implement channel adapter
Garfield550 95dc86b
chore: code review change and add agent file
Garfield550 ac255d8
fix: build error
Garfield550 b65bff6
chore: code review change
Garfield550 38ed3d1
chore: code review change
Garfield550 443f2ec
chore: code style update
Garfield550 fcdc0e8
chore: code style update
Garfield550 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Repository Guidelines | ||
|
|
||
| ## Project Structure & Module Organization | ||
|
|
||
| This is a .NET 10 solution centered on `Eventa.slnx`. Core library code lives in `src/Eventa`, and transport/adapter code lives in `src/Eventa.Adapters` with channel adapter types under `Channels`. Tests mirror that split in `tests/Eventa.Tests` and `tests/Eventa.Adapters.Tests`. `examples/Eventa.Example` is the console sample used to validate public API ergonomics. Design notes and RFCs belong in `docs`; generated build output belongs in `artifacts` and should not be edited by hand. | ||
|
|
||
| ## Build, Test, and Development Commands | ||
|
|
||
| Use the .NET 10 SDK. Common commands: | ||
|
|
||
| ```text | ||
| dotnet restore Eventa.slnx --locked-mode | ||
| dotnet build Eventa.slnx --configuration Release --no-restore | ||
| dotnet test --project tests/Eventa.Tests/Eventa.Tests.csproj --configuration Release --no-build | ||
| dotnet test --project tests/Eventa.Adapters.Tests/Eventa.Adapters.Tests.csproj --configuration Release --no-build | ||
| dotnet run --project examples/Eventa.Example/Eventa.Example.csproj --configuration Release --no-restore | ||
| ``` | ||
|
|
||
| Restore first, build the full solution, then run the two xUnit test projects as separate `dotnet test --project ...` commands. This repository uses Microsoft.Testing.Platform, so agents should not rely on repo-wide `dotnet test` discovery when narrowing scope. Run the example after API or behavior changes that affect user-facing flows. | ||
|
|
||
| ## Coding Style & Naming Conventions | ||
|
|
||
| Follow `.editorconfig`: spaces only, 4-space indentation for C#, 2-space indentation for project/XML/JSON files. C# uses nullable reference types and implicit usings. Prefer explicit types over `var`, file-scoped namespaces, braces for blocks, sorted `System` usings first, and static local functions where practical. Public types, methods, and properties use PascalCase; interfaces use `I` + PascalCase; type parameters use `T` + PascalCase. | ||
|
|
||
| ## Testing Guidelines | ||
|
|
||
| Tests use xUnit v3 with Microsoft.Testing.Platform, configured by `global.json`. Always pass `--project` when invoking tests from the CLI in this repo. For targeted validation, use Microsoft.Testing.Platform/xUnit v3 switches such as `--filter-class Eventa.Tests.AsyncSignalQueueTests`, and prefer fully qualified class names even when the simple class name appears unique. | ||
|
|
||
| ```text | ||
| dotnet test --project tests/Eventa.Tests/Eventa.Tests.csproj --configuration Release --no-build --filter-class Eventa.Tests.AsyncSignalQueueTests | ||
| ``` | ||
|
|
||
| Do not use VSTest-style `--filter "..."` expressions here; they are the wrong syntax for this setup and will commonly return zero tests. Filtering by class is the most reliable narrow validation path in this repo. Keep tests close to the behavior they cover and name methods in the existing `MethodOrScenario_Condition_ExpectedResult` style, for example `InvokeAsync_WithPreCanceledToken_EmitsAbortOnlyOnce`. Add regression coverage for cancellation, streaming, adapter faulting, and concurrency changes. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
|
|
||
| History uses Conventional Commit prefixes such as `feat:`, `fix:`, `docs:`, `chore:`, and scoped forms like `feat(example):`. Keep commits focused and imperative. Pull requests should describe the behavior change, list validation commands run, link related issues or RFCs, and call out public API or protocol compatibility impact. | ||
|
|
||
| ## Agent-Specific Notes | ||
|
|
||
| Keep plans concise and list unresolved questions at the end. When sharing runnable PowerShell commands, prefer fenced `text` blocks rather than inline command formatting. For targeted validation, prefer explicit `dotnet test --project ...` commands and `--filter-class <FullyQualifiedClassName>` over generic single-test tooling or VSTest filter expressions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| using System.Threading.Channels; | ||
|
|
||
| using Eventa; | ||
|
|
||
| namespace Eventa.Adapters.Channels; | ||
|
|
||
| /// <summary> | ||
| /// Mirrors locally sent Eventa envelopes to an outbound channel writer. | ||
| /// </summary> | ||
| internal sealed class ChannelAdapter(ChannelWriter<ChannelMessage> outbound) : IEventaAdapter | ||
| { | ||
| private int _disposed; | ||
|
|
||
| /// <inheritdoc /> | ||
| public void OnSent(string eventId, object? envelope, object? options = null) | ||
| { | ||
| if (Volatile.Read(ref _disposed) != 0) | ||
| { | ||
| throw new ChannelClosedException("Channel endpoint closed."); | ||
| } | ||
|
|
||
| if (envelope is not IEventEnvelope eventEnvelope) | ||
| { | ||
| throw new InvalidOperationException( | ||
| $"Event '{eventId}' was sent with an envelope that does not implement {nameof(IEventEnvelope)}."); | ||
| } | ||
|
|
||
| if (!outbound.TryWrite(new ChannelMessage(eventEnvelope, options))) | ||
| { | ||
| throw new ChannelClosedException("Channel endpoint closed."); | ||
| } | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void OnReceived(string eventId, object? envelope, object? options = null) { } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void Dispose() | ||
| { | ||
| Interlocked.Exchange(ref _disposed, 1); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.