Production deployment with zinit config
This commit is contained in:
258
OSIRIS_INTEGRATION.md
Normal file
258
OSIRIS_INTEGRATION.md
Normal file
@@ -0,0 +1,258 @@
|
||||
# ✅ OSIRIS Rhai Integration - ACTIVATED
|
||||
|
||||
The OSIRIS Rhai engine is now **fully integrated and working** in runner_rust!
|
||||
|
||||
## 🎉 Status: ACTIVE
|
||||
|
||||
```
|
||||
✓ Dependency added to Cargo.toml
|
||||
✓ Engine code activated in src/engine/osiris.rs
|
||||
✓ Rhai support enabled in OSIRIS crate
|
||||
✓ Test example running successfully
|
||||
```
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Run the Test
|
||||
|
||||
```bash
|
||||
cargo run --example test_osiris
|
||||
```
|
||||
|
||||
**Output:**
|
||||
```
|
||||
🧪 Testing OSIRIS Rhai Engine
|
||||
|
||||
Test 1: Creating OSIRIS engine...
|
||||
✓ Engine created successfully
|
||||
|
||||
Test 2: Running simple script...
|
||||
Hello from OSIRIS Rhai!
|
||||
Note created: Test Note
|
||||
✓ Script executed successfully
|
||||
```
|
||||
|
||||
## 📝 Usage Example
|
||||
|
||||
### Create and Store a Note
|
||||
|
||||
```rhai
|
||||
// Create a note with fluent builder pattern
|
||||
let note = note("notes")
|
||||
.title("My Note")
|
||||
.content("This is the content")
|
||||
.tag("project", "osiris")
|
||||
.tag("priority", "high")
|
||||
.mime("text/plain");
|
||||
|
||||
// Store it
|
||||
let id = put_note(note);
|
||||
print(`Stored with ID: ${id}`);
|
||||
|
||||
// Retrieve it
|
||||
let retrieved = get_note("notes", id);
|
||||
print(`Title: ${retrieved.get_title()}`);
|
||||
```
|
||||
|
||||
### Create and Store an Event
|
||||
|
||||
```rhai
|
||||
// Create an event
|
||||
let event = event("calendar", "Team Meeting")
|
||||
.description("Weekly sync")
|
||||
.location("Conference Room A")
|
||||
.category("meetings")
|
||||
.all_day(false);
|
||||
|
||||
// Store it
|
||||
let id = put_event(event);
|
||||
print(`Event stored: ${id}`);
|
||||
```
|
||||
|
||||
### Query by Index
|
||||
|
||||
```rhai
|
||||
// Query notes by tag
|
||||
let ids = query("notes", "tags:tag", "project=osiris");
|
||||
print(`Found ${ids.len()} notes`);
|
||||
|
||||
for note_id in ids {
|
||||
let n = get_note("notes", note_id);
|
||||
print(` - ${n.get_title()}`);
|
||||
}
|
||||
```
|
||||
|
||||
## 🔧 Integration Details
|
||||
|
||||
### Files Modified
|
||||
|
||||
1. **`Cargo.toml`**
|
||||
```toml
|
||||
osiris = { path = "../osiris", features = ["rhai-support"] }
|
||||
```
|
||||
|
||||
2. **`src/engine/osiris.rs`**
|
||||
- Activated full OSIRIS integration
|
||||
- Removed placeholder code
|
||||
- Using `OsirisRhaiEngine`, `register_note_api`, `register_event_api`
|
||||
|
||||
3. **`src/engine/mod.rs`**
|
||||
- Exported `create_osiris_engine` and `run_osiris_script`
|
||||
|
||||
### OSIRIS Rhai Support
|
||||
|
||||
Located in `osiris/src/rhai_support/`:
|
||||
|
||||
- **`note_rhai.rs`** - Note CustomType and builder API
|
||||
- **`event_rhai.rs`** - Event CustomType and builder API
|
||||
- **`engine.rs`** - OsirisRhaiEngine wrapper (async → sync bridge)
|
||||
|
||||
## 📚 Available Functions
|
||||
|
||||
### Note API
|
||||
|
||||
| Function | Description |
|
||||
|----------|-------------|
|
||||
| `note(ns)` | Create new note in namespace |
|
||||
| `.title(s)` | Set title (chainable) |
|
||||
| `.content(s)` | Set content (chainable) |
|
||||
| `.tag(k, v)` | Add tag (chainable) |
|
||||
| `.mime(s)` | Set MIME type (chainable) |
|
||||
| `put_note(note)` | Store note, returns ID |
|
||||
| `get_note(ns, id)` | Retrieve note by ID |
|
||||
| `.get_id()` | Get note ID |
|
||||
| `.get_title()` | Get note title |
|
||||
| `.get_content()` | Get note content |
|
||||
| `.to_json()` | Serialize to JSON |
|
||||
|
||||
### Event API
|
||||
|
||||
| Function | Description |
|
||||
|----------|-------------|
|
||||
| `event(ns, title)` | Create new event |
|
||||
| `.description(s)` | Set description (chainable) |
|
||||
| `.location(s)` | Set location (chainable) |
|
||||
| `.category(s)` | Set category (chainable) |
|
||||
| `.all_day(b)` | Set all-day flag (chainable) |
|
||||
| `put_event(event)` | Store event, returns ID |
|
||||
| `get_event(ns, id)` | Retrieve event by ID |
|
||||
| `.get_id()` | Get event ID |
|
||||
| `.get_title()` | Get event title |
|
||||
| `.to_json()` | Serialize to JSON |
|
||||
|
||||
### Query API
|
||||
|
||||
| Function | Description |
|
||||
|----------|-------------|
|
||||
| `query(ns, field, value)` | Query by indexed field, returns array of IDs |
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────┐
|
||||
│ Rhai Script │
|
||||
│ note("notes").title("Hi").tag("x","y") │
|
||||
└────────────────┬────────────────────────┘
|
||||
│
|
||||
┌────────────────▼────────────────────────┐
|
||||
│ runner_rust/src/engine/osiris.rs │
|
||||
│ create_osiris_engine() │
|
||||
└────────────────┬────────────────────────┘
|
||||
│
|
||||
┌────────────────▼────────────────────────┐
|
||||
│ osiris/src/rhai_support/ │
|
||||
│ ├── note_rhai.rs (CustomType) │
|
||||
│ ├── event_rhai.rs (CustomType) │
|
||||
│ └── engine.rs (OsirisRhaiEngine) │
|
||||
└────────────────┬────────────────────────┘
|
||||
│
|
||||
┌────────────────▼────────────────────────┐
|
||||
│ osiris/src/store/GenericStore │
|
||||
│ Automatic indexing via #[index] │
|
||||
└────────────────┬────────────────────────┘
|
||||
│
|
||||
┌────────────────▼────────────────────────┐
|
||||
│ HeroDB (Redis-compatible) │
|
||||
└─────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## 🎯 Key Features
|
||||
|
||||
1. **Fluent Builder Pattern** - Chain method calls for clean code
|
||||
2. **Type Safety** - Rhai's type system ensures correctness
|
||||
3. **Async Bridge** - Sync Rhai scripts use async OSIRIS operations seamlessly
|
||||
4. **Automatic Indexing** - Objects indexed based on `#[index]` attributes
|
||||
5. **Zero Boilerplate** - Derive macro generates all indexing code
|
||||
|
||||
## 📖 Examples
|
||||
|
||||
### Full Examples Available
|
||||
|
||||
1. **`examples/test_osiris.rs`** - Quick integration test
|
||||
2. **`examples/osiris_example.rs`** - Comprehensive Rust example
|
||||
3. **`examples/osiris_script.rhai`** - Complete Rhai script
|
||||
|
||||
### Running with HeroDB
|
||||
|
||||
```bash
|
||||
# Terminal 1: Start HeroDB
|
||||
cd ../herodb
|
||||
cargo run --release -- --dir ./data --admin-secret mysecret --port 6379
|
||||
|
||||
# Terminal 2: Run OSIRIS script
|
||||
cd ../runner_rust
|
||||
cargo run --example test_osiris
|
||||
```
|
||||
|
||||
## 🔍 Testing
|
||||
|
||||
```bash
|
||||
# Build check
|
||||
cargo check
|
||||
|
||||
# Build examples
|
||||
cargo build --examples
|
||||
|
||||
# Run test
|
||||
cargo run --example test_osiris
|
||||
|
||||
# Run with HeroDB integration
|
||||
# (requires HeroDB running on localhost:6379)
|
||||
cargo run --example osiris_example
|
||||
```
|
||||
|
||||
## 📊 Performance
|
||||
|
||||
- **Sync Rhai → Async OSIRIS**: Bridged via Tokio runtime
|
||||
- **Connection Pooling**: HeroDB client maintains connection pool
|
||||
- **Automatic Indexing**: Generated at compile-time, zero runtime overhead
|
||||
- **Type Safety**: All type checks at compile-time
|
||||
|
||||
## 🎨 Extending
|
||||
|
||||
To add new OSIRIS object types:
|
||||
|
||||
1. Create the object in `osiris/src/objects/`
|
||||
2. Add `#[derive(DeriveObject)]` and mark fields with `#[index]`
|
||||
3. Create `{object}_rhai.rs` in `osiris/src/rhai_support/`
|
||||
4. Implement `CustomType` and builder methods
|
||||
5. Register in `create_osiris_engine()`
|
||||
|
||||
## ✅ Verification
|
||||
|
||||
Run this to verify everything works:
|
||||
|
||||
```bash
|
||||
cargo run --example test_osiris
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
✓ Engine created successfully
|
||||
✓ Script executed successfully
|
||||
✅ Tests completed!
|
||||
```
|
||||
|
||||
## 🎉 Success!
|
||||
|
||||
The OSIRIS Rhai engine is **fully operational** and ready for use in production scripts!
|
||||
Reference in New Issue
Block a user