[Architecture] Split EntglDb.Network into transport layer (EntglDb.Network) and sync algorithm (EntglDb.Sync)#20
Conversation
…f transport layer Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com>
mrdevrobot
left a comment
There was a problem hiding this comment.
useHostedService is not necessary anymore in the AddEntglDbNetwork, this could be a small breaking change that we can afford (it won't impact too much the users)
There was a problem hiding this comment.
Pull request overview
Splits EntglDb’s networking stack into a transport-only assembly (EntglDb.Network) and a sync-algorithm assembly (EntglDb.Sync), reducing coupling between the transport layer and Core storage services while keeping sync features available via a dedicated package.
Changes:
- Introduces
EntglDb.Syncproject containing the sync orchestrator, node lifecycle hosted service, and the six sync message handlers. - Refactors
EntglDb.Networkto remove the Core project reference and adds transport-facing abstractions (ILocalInterestsProvider,IRemotePeerListProvider). - Updates
EntglDb.Coreinterfaces and consumer projects/samples to useAddEntglDbNetwork(...).AddEntglDbSync().
Reviewed changes
Copilot reviewed 29 out of 48 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/EntglDb.Network.Tests/EntglDb.Network.Tests.csproj | Adds reference to EntglDb.Sync for tests that depend on moved sync components. |
| src/EntglDb.Sync/SyncOrchestrator.cs | Adds sync orchestration implementation into the new sync assembly. |
| src/EntglDb.Sync/SyncExtensions.cs | Adds DI extension AddEntglDbSync() to register sync handlers + orchestrator/node. |
| src/EntglDb.Sync/ISyncOrchestrator.cs | Adds sync orchestrator interface in sync assembly. |
| src/EntglDb.Sync/IEntglDbNode.cs | Adds node abstraction interface in sync assembly. |
| src/EntglDb.Sync/Handlers/PushChangesHandler.cs | Implements PushChanges request handler in sync assembly. |
| src/EntglDb.Sync/Handlers/PullChangesHandler.cs | Implements PullChanges request handler in sync assembly. |
| src/EntglDb.Sync/Handlers/GetVectorClockHandler.cs | Implements GetVectorClock request handler in sync assembly. |
| src/EntglDb.Sync/Handlers/GetSnapshotHandler.cs | Implements snapshot streaming handler in sync assembly. |
| src/EntglDb.Sync/Handlers/GetClockHandler.cs | Implements GetClock request handler in sync assembly. |
| src/EntglDb.Sync/Handlers/GetChainRangeHandler.cs | Implements GetChainRange request handler in sync assembly. |
| src/EntglDb.Sync/EntglDbNodeService.cs | Adds hosted service that starts/stops the node via IEntglDbNode. |
| src/EntglDb.Sync/EntglDbNode.cs | Updates node implementation after move into sync assembly. |
| src/EntglDb.Sync/EntglDb.Sync.csproj | New sync project definition and dependencies. |
| src/EntglDb.Network/UdpDiscoveryService.cs | Replaces IDocumentStore dependency with optional ILocalInterestsProvider. |
| src/EntglDb.Network/TcpSyncServer.cs | Uses ILocalInterestsProvider (instead of IDocumentStore) for handshake interest advertisement. |
| src/EntglDb.Network/PeerDbNetworkExtensions.cs | Updates AddEntglDbNetwork to register transport services only. |
| src/EntglDb.Network/IRemotePeerListProvider.cs | Adds transport-facing abstraction for persisted peer list retrieval. |
| src/EntglDb.Network/ILocalInterestsProvider.cs | Adds transport-facing abstraction for local collection interests. |
| src/EntglDb.Network/EntglDb.Network.csproj | Removes Core reference and adjusts netstandard dependencies + protobuf itemgroup. |
| src/EntglDb.Network/CoreTypes/VectorClock.cs | Moves vector clock type into Network assembly while keeping Core namespace. |
| src/EntglDb.Network/CoreTypes/OplogEntry.cs | Adjusts moved oplog entry type (removes annotations dependency). |
| src/EntglDb.Network/CoreTypes/HlcTimestamp.cs | Moves HLC timestamp type into Network assembly while keeping Core namespace. |
| src/EntglDb.Network/CoreNetwork/StaticPeerNodeConfigurationProvider.cs | Adds static configuration provider to Network assembly (Core namespace preserved). |
| src/EntglDb.Network/CoreNetwork/RemotePeerConfiguration.cs | Moves remote peer configuration type into Network assembly. |
| src/EntglDb.Network/CoreNetwork/PeerType.cs | Adds peer classification enum. |
| src/EntglDb.Network/CoreNetwork/PeerNodeConfiguration.cs | Adds/moves peer node configuration types. |
| src/EntglDb.Network/CoreNetwork/PeerNode.cs | Adds/moves peer node model and interest list. |
| src/EntglDb.Network/CoreNetwork/OAuth2Configuration.cs | Adds OAuth2 config model for cloud peers. |
| src/EntglDb.Network/CoreNetwork/NodeRole.cs | Adds node role enum for cloud gateway scenarios. |
| src/EntglDb.Network/CoreNetwork/IPeerNodeConfigurationProvider.cs | Moves configuration provider contract into Network assembly. |
| src/EntglDb.Network/CompositeDiscoveryService.cs | Refactors to use IRemotePeerListProvider instead of Core storage interface. |
| src/EntglDb.Core/Storage/IPeerConfigurationStore.cs | Extends IRemotePeerListProvider to preserve behavior without breaking implementations. |
| src/EntglDb.Core/Storage/IDocumentStore.cs | Extends ILocalInterestsProvider and removes duplicated InterestedCollection member. |
| src/EntglDb.Core/EntglDb.Core.csproj | Adds project reference to EntglDb.Network for moved shared types. |
| src/EntglDb.AspNet/EntglDb.AspNet.csproj | References EntglDb.Sync to align with split and DI registration. |
| samples/EntglDb.Test.Maui/MauiProgram.cs | Updates DI wiring to AddEntglDbNetwork(...).AddEntglDbSync(). |
| samples/EntglDb.Test.Maui/EntglDb.Test.Maui.csproj | Adds EntglDb.Sync project reference. |
| samples/EntglDb.Test.Avalonia/EntglDb.Test.Avalonia.csproj | Adds EntglDb.Sync project reference. |
| samples/EntglDb.Test.Avalonia/App.axaml.cs | Updates DI wiring to AddEntglDbNetwork(...).AddEntglDbSync(). |
| samples/EntglDb.Sample.Console/Program.cs | Updates DI wiring to AddEntglDbNetwork(...).AddEntglDbSync(). |
| samples/EntglDb.Sample.Console/EntglDb.Sample.Console.csproj | Adds EntglDb.Sync project reference. |
| samples/EntglDb.Sample.AspNetCore/Program.cs | Updates DI wiring to split transport vs hosted sync service registration. |
| samples/EntglDb.Sample.AspNetCore/EntglDb.Sample.AspNetCore.csproj | Adds EntglDb.Sync project reference. |
| samples/EntglDb.Demo.Game/Program.cs | Updates DI wiring to AddEntglDbNetwork(...).AddEntglDbSync(). |
| samples/EntglDb.Demo.Game/EntglDb.Demo.Game.csproj | Adds EntglDb.Sync project reference. |
| samples/EntglDb.Demo.Game.MonoGame/Program.cs | Updates DI wiring to AddEntglDbNetwork(...).AddEntglDbSync(). |
| EntglDb.Net.sln | Adds the new EntglDb.Sync project to the solution. |
Comments suppressed due to low confidence (1)
src/EntglDb.Network/PeerDbNetworkExtensions.cs:33
AddEntglDbNetworkstill exposesuseHostedService, but the parameter is no longer used (the hosted node service moved toAddEntglDbSync). This is misleading for callers. Consider marking the parameter as obsolete/ignored in docs, or remove it in the next major version; at minimum, document that it's kept only for backward compatibility and has no effect.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| /// <param name="handlers"> | ||
| /// All registered <see cref="INetworkMessageHandler"/> instances injected via DI. | ||
| /// This includes the built-in core handlers registered by <c>AddEntglDbNetwork</c> | ||
| /// as well as any user-defined handlers. When two handlers target the same | ||
| /// <see cref="MessageType"/>, the last one registered takes precedence. |
Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com>
Done in 723c837 — removed |
EntglDb.Networkmixed transport concerns with sync algorithm logic, coupling the TCP/UDP layer directly toIOplogStore,IDocumentStore, andISnapshotService. This splits it into two focused assemblies.Post-split dependency graph
Changes
EntglDb.Network (transport only)
<ProjectReference>toEntglDb.Core— zero Core dependencyHlcTimestamp,VectorClock,OplogEntry,OperationType(CoreTypes/, namespace unchanged); allEntglDb.Core.Networktypes —PeerNode,IPeerNodeConfigurationProvider,RemotePeerConfiguration, etc. (CoreNetwork/, namespace unchanged)ILocalInterestsProvider— replacesIDocumentStoreinTcpSyncServer/UdpDiscoveryService(now optional)IRemotePeerListProvider— replacesIPeerConfigurationStoreinCompositeDiscoveryServiceAddEntglDbNetwork<T>()registers transport only (config, auth, discovery, server, telemetry) — no parameters (theuseHostedServiceparameter has been removed as it was unused)EntglDb.Sync (new project)
SyncOrchestrator,EntglDbNode,EntglDbNodeService, all 6 message handlersAddEntglDbSync()registers handlers + orchestrator + hosted node serviceEntglDb.Core
<ProjectReference>toEntglDb.Networkfor the moved shared typesIDocumentStoreextendsILocalInterestsProvider;IPeerConfigurationStoreextendsIRemotePeerListProvider— no breaking changes for existing implementationsMigration for consumers
Type of change
How Has This Been Tested?
EntglDb.Network.Testspass unchanged (includingSnapshotReconnectRegressionTestswhich subclassesSyncOrchestratorvia reflection)EntglDb.Core.Testspass unchangedEntglDb.Network.csprojcarries no reference toEntglDb.Core(verified via grep)Console,AspNetCore,Avalonia,Demo.Game,Maui) build with 0 errors after DI call-site updateChecklist:
Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.