Add rBroker + wBroker pool, BrokerPayload, NamasteCore trait stub
- src/brokers/: pool manager, r_broker (rec.read), w_broker (rec.write), BrokerPayload struct, BrokerError type - src/core/: NamasteCore trait — fetch/write/update/delete interface, stubs - IPL step 6: spawns rBroker + wBroker pools after exchange declaration - tests/broker_pool_test.rs: integration tests for pool spawn (skip if broker down) - BrokerPayload unit tests + doctest in payload.rs - Added futures-lite, serde_json to Cargo.toml - README.md, CLAUDE.md, wiki updated to reflect new structure and status Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
44
claude.md
44
claude.md
@@ -28,6 +28,14 @@ This is not a greenfield project. The architecture is proven. The Rust rewrite e
|
||||
```
|
||||
rustybeds/
|
||||
├── src/
|
||||
│ ├── brokers/
|
||||
│ │ ├── mod.rs # Pool manager — spawn_r/w_broker_pool()
|
||||
│ │ ├── error.rs # BrokerError type
|
||||
│ │ ├── payload.rs # BrokerPayload — AMQP message body struct
|
||||
│ │ ├── r_broker.rs # rBroker task — rec.read consume loop
|
||||
│ │ └── w_broker.rs # wBroker task — rec.write consume loop
|
||||
│ ├── core/
|
||||
│ │ └── mod.rs # NamasteCore trait — unified CRUD interface (stub)
|
||||
│ ├── config/
|
||||
│ │ ├── mod.rs # load() + load_from() — layered TOML config
|
||||
│ │ └── structs.rs # Typed config structs (serde Deserialize)
|
||||
@@ -53,6 +61,7 @@ rustybeds/
|
||||
│ ├── example_rec.toml # Canonical self-documenting REC template
|
||||
│ └── mst_logger_rec.toml # Logger collection template (msLogs)
|
||||
├── tests/
|
||||
│ ├── broker_pool_test.rs # rBroker + wBroker pool integration tests
|
||||
│ ├── common/mod.rs # Shared test helpers — load_test_config()
|
||||
│ └── fixtures/
|
||||
│ └── beds_test.toml # Canonical test config fixture
|
||||
@@ -65,15 +74,11 @@ rustybeds/
|
||||
```
|
||||
src/
|
||||
├── core/
|
||||
│ ├── trait.rs # NamasteCore trait definition
|
||||
│ ├── factory.rs # Template name → adapter dispatch
|
||||
│ ├── factory.rs # Template name → NamasteCore dispatch
|
||||
│ └── meta.rs # Request metadata parsing
|
||||
├── adapters/
|
||||
│ ├── mysql.rs # gacPDO equivalent
|
||||
│ └── mongodb.rs # gacMongoDB equivalent
|
||||
└── brokers/
|
||||
├── pool.rs # Broker pool management
|
||||
└── broker.rs # Individual broker task
|
||||
└── adapters/
|
||||
├── mysql.rs # gacPDO equivalent
|
||||
└── mongodb.rs # gacMongoDB equivalent
|
||||
```
|
||||
|
||||
## Key Rust Mappings from PHP
|
||||
@@ -91,17 +96,30 @@ src/
|
||||
|
||||
## NamasteCore Trait Interface
|
||||
|
||||
The core CRUD interface. Every database adapter and every template must implement this:
|
||||
The core CRUD interface in `src/core/mod.rs`. Every template struct implements this:
|
||||
|
||||
```rust
|
||||
pub trait NamasteCore {
|
||||
async fn create_record(&self, payload: &Payload) -> Result<Response, BEDSError>;
|
||||
async fn fetch_records(&self, query: &Query) -> Result<Vec<Response>, BEDSError>;
|
||||
async fn update_record(&self, payload: &Payload) -> Result<Response, BEDSError>;
|
||||
async fn delete_record(&self, id: &str) -> Result<Response, BEDSError>;
|
||||
fn template_id(&self) -> &'static str;
|
||||
fn fetch(&self, params: HashMap<String, Value>) -> impl Future<Output = Result<Vec<HashMap<String, Value>>, String>> + Send;
|
||||
fn write(&self, data: HashMap<String, Value>) -> impl Future<Output = Result<HashMap<String, Value>, String>> + Send;
|
||||
fn update(&self, params: HashMap<String, Value>, data: HashMap<String, Value>) -> impl Future<Output = Result<u64, String>> + Send;
|
||||
fn delete(&self, params: HashMap<String, Value>) -> impl Future<Output = Result<u64, String>> + Send;
|
||||
}
|
||||
```
|
||||
|
||||
Data in/out is always `HashMap<String, Value>` in user-facing field names. Templates own schema translation. Callers never provide primary keys on writes — the template generates a GUID.
|
||||
|
||||
## BrokerPayload — AMQP Message Body
|
||||
|
||||
The JSON body carried by all broker messages (`src/brokers/payload.rs`):
|
||||
|
||||
```json
|
||||
{ "template": "usr", "data": { "first_name": "joe", "status": "active" } }
|
||||
```
|
||||
|
||||
The AMQP `type` message property carries the operation (`fetch`, `write`, `update`, `delete`, `ping`, `shutdown`). The body carries the template identifier and data payload.
|
||||
|
||||
## Dependencies (Cargo.toml)
|
||||
|
||||
```toml
|
||||
|
||||
Reference in New Issue
Block a user