Skip to content

[2/5] VSA: Collapse Gateway+Usecase into *Service per feature#3335

Merged
Mpdreamz merged 2 commits into
refactor/merge-api-projectsfrom
refactor/collapse-gateway-usecase-to-service
May 19, 2026
Merged

[2/5] VSA: Collapse Gateway+Usecase into *Service per feature#3335
Mpdreamz merged 2 commits into
refactor/merge-api-projectsfrom
refactor/collapse-gateway-usecase-to-service

Conversation

@Mpdreamz
Copy link
Copy Markdown
Member

@Mpdreamz Mpdreamz commented May 18, 2026

Why

The ports-and-adapters split required three types per feature (interface, gateway impl, usecase orchestrator) where the usecase added only ~5 lines of logging and DTO mapping over a single implementation. This made every feature harder to navigate and contributed no reuse benefit since all three layers lived in the same project.

What

Each feature now has a single interface and implementation that owns the full request/response flow — logging, Elasticsearch calls, response mapping, and cursor encode/decode where applicable:

  • IFullSearchService / FullSearchService (was IFullSearchGateway + FullSearchGateway + FullSearchUsecase)
  • INavigationSearchService / NavigationSearchService
  • IChangesService / ChangesService
  • IOtlpService / AdotOtlpService
  • IAskAiService / IAskAiMessageFeedbackService (renamed from Gateway variants)

AddElasticDocsApiUsecases is renamed to AddElasticDocsApiServices throughout. Interfaces are kept for test seams (mocks updated to MockSearchService).


Part of a move to vertical slice architecture to be able to cleanly lift search contract:

  1. [1/5] VSA: Merge Elastic.Documentation.Api.* into single project #3333 — Merge Elastic.Documentation.Api.* into single project
  2. [2/5] VSA: Collapse Gateway+Usecase into *Service per feature #3335 — Collapse Gateway+Usecase into *Service per feature
  3. [3/5] VSA: Slim Elastic.Documentation, extract heavy deps to Tooling #3345 — Slim Elastic.Documentation, extract heavy deps to Tooling
  4. [4/5] VSA: Slim Configuration to YAML schema; organize root namespaces #3347 — Slim Configuration to YAML schema; organize root namespaces
  5. [5/5] VSA: Extract Elastic.Documentation.Search.Contract as zero-dep library #3350 — Extract Elastic.Documentation.Search.Contract as zero-dep library

Removes the ports-and-adapters boilerplate that required three types
(interface + gateway impl + usecase orchestrator) for each feature.
Each feature now has a single interface and implementation:
- IFullSearchService / FullSearchService (was IGateway + Gateway + Usecase)
- INavigationSearchService / NavigationSearchService
- IChangesService / ChangesService
- IOtlpService / AdotOtlpService

IAskAiService/IAskAiMessageFeedbackService renamed from Gateway variants;
AddElasticDocsApiUsecases → AddElasticDocsApiServices throughout.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Mpdreamz Mpdreamz requested a review from a team as a code owner May 18, 2026 11:09
@Mpdreamz Mpdreamz requested a review from reakaleek May 18, 2026 11:09
@Mpdreamz Mpdreamz added the chore label May 18, 2026
@Mpdreamz Mpdreamz force-pushed the refactor/collapse-gateway-usecase-to-service branch from d0b8b56 to 709b247 Compare May 18, 2026 16:13
@Mpdreamz Mpdreamz changed the title Collapse Gateway+Usecase layering into *Service per feature [2/3] VSA: Collapse Gateway+Usecase into *Service per feature May 18, 2026
@Mpdreamz Mpdreamz changed the title [2/3] VSA: Collapse Gateway+Usecase into *Service per feature [2/5] VSA: Collapse Gateway+Usecase into *Service per feature May 19, 2026
…3345)

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@Mpdreamz Mpdreamz merged commit 90965e5 into refactor/merge-api-projects May 19, 2026
17 of 19 checks passed
@Mpdreamz Mpdreamz deleted the refactor/collapse-gateway-usecase-to-service branch May 19, 2026 09:22
Mpdreamz added a commit that referenced this pull request May 19, 2026
* Merge Elastic.Documentation.Api.* into single project

Three projects (Api.Core, Api.Infrastructure, Api.App) collapsed into
Elastic.Documentation.Api. Mcp.Remote no longer references any Api.*
project — its only deps are ServiceDefaults, services/Search, and
services/Assembler.

Key moves:
- EuidSpanProcessor + EuidLogProcessor → ServiceDefaults (shared)
- AddEuidEnrichment helper added to ServiceDefaults
- Search gateway interfaces (IFullSearchGateway, INavigationSearchGateway,
  IChangesGateway) → services/Elastic.Documentation.Search
- McpToolSourceName constant inlined into Mcp.Remote

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix C# import ordering and name simplification after Api merge

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix Dockerfile publish RID to use TARGETARCH/TARGETOS instead of linux-x64

Enables arm64 image builds to publish and copy the correct architecture
artifact rather than always using the amd64 binary.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Address PR review: OTel source registration, assembly version, env var key

- Register McpTools ActivitySource in Mcp.Remote TracerProvider so MCP
  spans are captured
- Use GetEntryAssembly() over GetCallingAssembly() for service.version so
  the host service's version is reported rather than ServiceDefaults
- OtlpProxyOptions now checks OTEL_EXPORTER_OTLP_ENDPOINT first then
  OTLP_PROXY_ENDPOINT as backward-compatible fallback, matching the
  documented priority order

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix import ordering in Mcp.Remote Program.cs

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* [2/5] VSA: Collapse Gateway+Usecase into *Service per feature (#3335)

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
groman92 pushed a commit that referenced this pull request May 20, 2026
* Merge Elastic.Documentation.Api.* into single project

Three projects (Api.Core, Api.Infrastructure, Api.App) collapsed into
Elastic.Documentation.Api. Mcp.Remote no longer references any Api.*
project — its only deps are ServiceDefaults, services/Search, and
services/Assembler.

Key moves:
- EuidSpanProcessor + EuidLogProcessor → ServiceDefaults (shared)
- AddEuidEnrichment helper added to ServiceDefaults
- Search gateway interfaces (IFullSearchGateway, INavigationSearchGateway,
  IChangesGateway) → services/Elastic.Documentation.Search
- McpToolSourceName constant inlined into Mcp.Remote

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix C# import ordering and name simplification after Api merge

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix Dockerfile publish RID to use TARGETARCH/TARGETOS instead of linux-x64

Enables arm64 image builds to publish and copy the correct architecture
artifact rather than always using the amd64 binary.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Address PR review: OTel source registration, assembly version, env var key

- Register McpTools ActivitySource in Mcp.Remote TracerProvider so MCP
  spans are captured
- Use GetEntryAssembly() over GetCallingAssembly() for service.version so
  the host service's version is reported rather than ServiceDefaults
- OtlpProxyOptions now checks OTEL_EXPORTER_OTLP_ENDPOINT first then
  OTLP_PROXY_ENDPOINT as backward-compatible fallback, matching the
  documented priority order

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* Fix import ordering in Mcp.Remote Program.cs

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

* [2/5] VSA: Collapse Gateway+Usecase into *Service per feature (#3335)

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant