Skip to content

refactor: extract ES-compat handler logic into reusable functions#6271

Merged
congx4 merged 1 commit intomainfrom
cong/refactor-es-compat-extract-handler-fns
Apr 7, 2026
Merged

refactor: extract ES-compat handler logic into reusable functions#6271
congx4 merged 1 commit intomainfrom
cong/refactor-es-compat-extract-handler-fns

Conversation

@congx4
Copy link
Copy Markdown
Contributor

@congx4 congx4 commented Apr 7, 2026

Summary

  • Extract JSON construction from warp handlers into standalone pub(crate) functions callable without HTTP
  • Enable non-HTTP consumers (e.g., gRPC passthrough) to reuse ES-compatible logic directly
  • Make model and rest_handler modules pub(crate) in mod.rs

Motivation

Downstream consumers need to call ES-compatible handler logic directly (without a network round-trip through warp). This refactoring extracts the core logic into reusable functions while keeping existing HTTP handlers working identically.

Changes

Extracted new functions:

  • es_compat_cluster_info — cluster info JSON
  • es_compat_nodes_info — nodes info JSON
  • es_compat_search_shards — search shards JSON
  • es_compat_aliases — empty aliases object
  • es_compat_cluster_health_check — cluster health check
  • es_compat_delete_scroll — scroll delete response

Made pub(crate): es_compat_index_mapping, es_compat_index_search, es_compat_index_count, es_compat_index_stats, es_compat_cat_indices, es_compat_index_cat_indices, es_compat_resolve_index, es_compat_index_field_capabilities, es_compat_index_multi_search, es_scroll, ElasticsearchCountResponse

Test plan

  • All 64 existing ES API tests pass
  • cargo +nightly fmt clean
  • No behavior changes — pure refactoring

🤖 Generated with Claude Code

…nctions

Extract JSON construction from warp handlers into standalone functions
that can be called directly without HTTP, enabling non-HTTP consumers
(e.g., gRPC passthrough) to reuse the ES-compatible logic.

Extracted functions:
- es_compat_cluster_info, es_compat_nodes_info, es_compat_search_shards,
  es_compat_aliases, es_compat_cluster_health_check, es_compat_delete_scroll

Made pub(crate): es_compat_index_mapping, es_compat_index_search,
es_compat_index_count, es_compat_index_stats, es_compat_cat_indices,
es_compat_index_cat_indices, es_compat_resolve_index,
es_compat_index_field_capabilities, es_compat_index_multi_search, es_scroll

Also made model and rest_handler modules pub(crate) in mod.rs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@congx4 congx4 requested a review from guilload April 7, 2026 18:27
@congx4 congx4 merged commit 65d97fc into main Apr 7, 2026
8 checks passed
@congx4 congx4 deleted the cong/refactor-es-compat-extract-handler-fns branch April 7, 2026 18:54
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.

2 participants