Skip to content

Fix hosted service registration ambiguity in channel runtime#314

Merged
eanzhao merged 1 commit into
devfrom
fix/2026-04-22_hosted-service-registration-adapter
Apr 22, 2026
Merged

Fix hosted service registration ambiguity in channel runtime#314
eanzhao merged 1 commit into
devfrom
fix/2026-04-22_hosted-service-registration-adapter

Conversation

@eanzhao
Copy link
Copy Markdown
Contributor

@eanzhao eanzhao commented Apr 22, 2026

Summary

  • replace the factory-based IHostedService registration for the Lark inbox runtime
  • add a thin hosted-service adapter that delegates to the shared runtime singleton
  • keep ILarkConversationInbox and hosted startup bound to the same runtime instance

Problem

.NET 10 rejects TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService>(factory)) for IHostedService because the implementation type is indistinguishable from other hosted-service registrations. AddChannelRuntime(...) hit that path during startup and the host failed before serving traffic.

Solution

  • keep LarkConversationInboxRuntime as the concrete singleton
  • keep ILarkConversationInbox resolving to that singleton
  • introduce LarkConversationInboxHostedService as a small adapter implementing IHostedService
  • register the adapter via TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, LarkConversationInboxHostedService>())

Verification

  • dotnet build src/Aevatar.Mainnet.Host.Api/Aevatar.Mainnet.Host.Api.csproj --nologo

@eanzhao eanzhao merged commit 7722add into dev Apr 22, 2026
11 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.74%. Comparing base (1d749ac) to head (f85fc3c).
⚠️ Report is 2 commits behind head on dev.

@@           Coverage Diff           @@
##              dev     #314   +/-   ##
=======================================
  Coverage   69.73%   69.74%           
=======================================
  Files        1139     1139           
  Lines       81170    81170           
  Branches    10619    10619           
=======================================
+ Hits        56605    56612    +7     
+ Misses      20469    20463    -6     
+ Partials     4096     4095    -1     
Flag Coverage Δ
ci 69.74% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant