1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Distributed executor registration using [`linkme`].
//!
//! This module provides a mechanism for registering executors at their
//! declaration site rather than centralizing all registrations in a single
//! location (e.g., the `main` function).
//!
//! # Motivation
//!
//! In large applications with many executors, the traditional approach of
//! registering all executors in one place leads to a long, hard-to-maintain
//! list of registration calls. This causes several issues:
//!
//! - **Scalability**: Adding a new query type requires modifying a central file
//! - **Coupling**: Query declarations become tightly coupled to a single
//! registration point
//! - **Maintainability**: Long registration functions are error-prone
//!
//! This module allows you to declare executor registrations alongside the
//! executor definitions themselves, using the [`linkme`] crate's distributed
//! slice feature (similar to the [`inventory`](https://crates.io/crates/inventory) crate).
//!
//! # Usage
//!
//! 1. **Define a Distributed Slice**: Create a module or library that defines
//! your program's registrations using `#[distributed_slice]`
//!
//! 2. **Register Executors at Declaration Site**: In each module where you
//! define executors, add a distributed slice entry using
//! `#[distributed_slice(REGISTRATIONS)]`
//!
//! 3. **Register All Executors at Once**: In your `main` or initialization
//! function, call [`Engine::register_program`] with your distributed slice
//!
//! # Benefits
//!
//! - **Modularity**: Executors are registered near their definitions
//! - **Scalability**: Adding new queries doesn't require modifying a central
//! file
//! - **Maintainability**: Each executor registration is self-contained
//! - **Decoupling**: Query modules don't depend on a central registry
//!
//! # Comparison with Manual Registration
//!
//! | Aspect | Manual | Distributed |
//! |--------|--------|-------------|
//! | New executor | Modify main.rs | Add line near executor |
//! | Central point of failure | Yes | No |
//! | Scalability | Poor | Good |
//! | Code organization | Centralized | Decentralized |
use Arc;
use crate::;
/// A registration entry for an executor in a distributed slice.
///
/// This struct captures the information needed to register an executor with an
/// [`Engine`] at runtime. It is designed to be used with [`linkme`]'s
/// distributed slices, allowing executor registrations to be declared
/// alongside their implementations rather than in a centralized location.
///
/// # Type Parameters
///
/// * `C` - The configuration type that implements [`Config`].