first commit
This commit is contained in:
60
scripts/multi_instance.rhai
Normal file
60
scripts/multi_instance.rhai
Normal file
@@ -0,0 +1,60 @@
|
||||
// Multi-Instance OSIRIS Example
|
||||
// Demonstrates using multiple OSIRIS instances in a single script
|
||||
|
||||
print("=== Multi-Instance OSIRIS Test ===\n");
|
||||
|
||||
// Create two OSIRIS instances
|
||||
print("Creating OSIRIS instances...");
|
||||
let freezone = osiris("freezone", "redis://localhost:6379", 1);
|
||||
let my_osiris = osiris("my_osiris", "redis://localhost:6379", 2);
|
||||
print(`✓ Created: ${freezone.name()}`);
|
||||
print(`✓ Created: ${my_osiris.name()}\n`);
|
||||
|
||||
// Create a note
|
||||
print("Creating note...");
|
||||
let my_note = note("shared_notes")
|
||||
.title("Multi-Instance Test Note")
|
||||
.content("This note will be stored in both OSIRIS instances!")
|
||||
.tag("test", "multi-instance")
|
||||
.tag("shared", "true");
|
||||
|
||||
print(`Note created: ${my_note.get_title()}\n`);
|
||||
|
||||
// Store in freezone instance
|
||||
print("Storing in freezone...");
|
||||
let freezone_id = freezone.put_note(my_note);
|
||||
print(`✓ Stored in freezone with ID: ${freezone_id}\n`);
|
||||
|
||||
// Store in my_osiris instance (same note, different storage)
|
||||
print("Storing in my_osiris...");
|
||||
let my_id = my_osiris.put_note(my_note);
|
||||
print(`✓ Stored in my_osiris with ID: ${my_id}\n`);
|
||||
|
||||
// Retrieve from freezone
|
||||
print("Retrieving from freezone...");
|
||||
let freezone_note = freezone.get_note("shared_notes", freezone_id);
|
||||
print(`✓ Retrieved from freezone: ${freezone_note.get_title()}\n`);
|
||||
|
||||
// Retrieve from my_osiris
|
||||
print("Retrieving from my_osiris...");
|
||||
let my_note_retrieved = my_osiris.get_note("shared_notes", my_id);
|
||||
print(`✓ Retrieved from my_osiris: ${my_note_retrieved.get_title()}\n`);
|
||||
|
||||
// Query both instances
|
||||
print("Querying freezone...");
|
||||
let freezone_ids = freezone.query("shared_notes", "tags:tag", "shared=true");
|
||||
print(`✓ Found in freezone:`);
|
||||
for id in freezone_ids {
|
||||
print(` - ${id}`);
|
||||
}
|
||||
print("");
|
||||
|
||||
print("Querying my_osiris...");
|
||||
let my_ids = my_osiris.query("shared_notes", "tags:tag", "shared=true");
|
||||
print(`✓ Found in my_osiris:`);
|
||||
for id in my_ids {
|
||||
print(` - ${id}`);
|
||||
}
|
||||
|
||||
print("\n=== Test Complete ===");
|
||||
print("Successfully demonstrated multi-instance OSIRIS!");
|
||||
60
scripts/predefined_instances.rhai
Normal file
60
scripts/predefined_instances.rhai
Normal file
@@ -0,0 +1,60 @@
|
||||
// Predefined Instances Example
|
||||
// Run with predefined instances:
|
||||
// cargo run --bin runner --features rhai-support -- test1 \
|
||||
// --instance freezone:redis://localhost:6379:1 \
|
||||
// --instance my:redis://localhost:6379:2 \
|
||||
// --script-file scripts/predefined_instances.rhai
|
||||
|
||||
print("=== Predefined Instances Example ===\n");
|
||||
|
||||
// freezone and my are already available - no need to create them!
|
||||
print(`Using predefined instance: ${freezone.name()}`);
|
||||
print(`Using predefined instance: ${my.name()}\n`);
|
||||
|
||||
// Create a note
|
||||
print("Creating note...");
|
||||
let my_note = note("notes")
|
||||
.title("Predefined Instance Test")
|
||||
.content("Using freezone and my instances directly!")
|
||||
.tag("type", "predefined")
|
||||
.tag("test", "true");
|
||||
|
||||
print(`Note created: ${my_note.get_title()}\n`);
|
||||
|
||||
// Store in freezone - just use it directly!
|
||||
print("Storing in freezone...");
|
||||
let freezone_id = freezone.put_note(my_note);
|
||||
print(`✓ Stored in freezone: ${freezone_id}\n`);
|
||||
|
||||
// Store in my - just use it directly!
|
||||
print("Storing in my...");
|
||||
let my_id = my.put_note(my_note);
|
||||
print(`✓ Stored in my: ${my_id}\n`);
|
||||
|
||||
// Retrieve from both
|
||||
print("Retrieving from freezone...");
|
||||
let note1 = freezone.get_note("notes", freezone_id);
|
||||
print(`✓ ${note1.get_title()}\n`);
|
||||
|
||||
print("Retrieving from my...");
|
||||
let note2 = my.get_note("notes", my_id);
|
||||
print(`✓ ${note2.get_title()}\n`);
|
||||
|
||||
// Query both
|
||||
print("Querying freezone for predefined notes...");
|
||||
let freezone_ids = freezone.query("notes", "tags:tag", "type=predefined");
|
||||
print(`✓ Found ${freezone_ids.len} notes in freezone`);
|
||||
for id in freezone_ids {
|
||||
print(` - ${id}`);
|
||||
}
|
||||
print("");
|
||||
|
||||
print("Querying my for predefined notes...");
|
||||
let my_ids = my.query("notes", "tags:tag", "type=predefined");
|
||||
print(`✓ Found ${my_ids.len} notes in my`);
|
||||
for id in my_ids {
|
||||
print(` - ${id}`);
|
||||
}
|
||||
|
||||
print("\n=== Test Complete ===");
|
||||
print("Successfully used predefined freezone and my instances!");
|
||||
34
scripts/test_event.rhai
Normal file
34
scripts/test_event.rhai
Normal file
@@ -0,0 +1,34 @@
|
||||
// Test OSIRIS Event Creation
|
||||
// Run with: cargo run --bin runner --features rhai-support -- test1 --script-file scripts/test_event.rhai
|
||||
|
||||
print("=== OSIRIS Event Test ===\n");
|
||||
|
||||
// Create an event
|
||||
print("Creating event...");
|
||||
let event = event("test_calendar", "OSIRIS Runner Test Meeting")
|
||||
.description("Testing the OSIRIS standalone runner")
|
||||
.location("Virtual")
|
||||
.category("testing")
|
||||
.all_day(false);
|
||||
|
||||
print(`Event created: ${event.get_title()}`);
|
||||
|
||||
// Store the event
|
||||
print("Storing event...");
|
||||
let id = put_event(event);
|
||||
print(`✓ Event stored with ID: ${id}\n`);
|
||||
|
||||
// Retrieve the event
|
||||
print("Retrieving event...");
|
||||
let retrieved = get_event("test_calendar", id);
|
||||
print(`✓ Retrieved: ${retrieved.get_title()}\n`);
|
||||
|
||||
// Query by category
|
||||
print("Querying events by category...");
|
||||
let ids = query("test_calendar", "category", "testing");
|
||||
print("✓ Found events:");
|
||||
for id in ids {
|
||||
print(` - ${id}`);
|
||||
}
|
||||
|
||||
print("=== Test Complete ===");
|
||||
36
scripts/test_note.rhai
Normal file
36
scripts/test_note.rhai
Normal file
@@ -0,0 +1,36 @@
|
||||
// Test OSIRIS Note Creation
|
||||
// Run with: cargo run --bin runner --features rhai-support -- test1 --script-file scripts/test_note.rhai
|
||||
|
||||
print("=== OSIRIS Note Test ===\n");
|
||||
|
||||
// Create a note
|
||||
print("Creating note...");
|
||||
let note = note("test_notes")
|
||||
.title("Test from OSIRIS Runner")
|
||||
.content("This note was created using the OSIRIS standalone runner!")
|
||||
.tag("source", "osiris-runner")
|
||||
.tag("test", "true")
|
||||
.mime("text/plain");
|
||||
|
||||
print(`Note created: ${note.get_title()}`);
|
||||
|
||||
// Store the note
|
||||
print("Storing note...");
|
||||
let id = put_note(note);
|
||||
print(`✓ Note stored with ID: ${id}\n`);
|
||||
|
||||
// Retrieve the note
|
||||
print("Retrieving note...");
|
||||
let retrieved = get_note("test_notes", id);
|
||||
print(`✓ Retrieved: ${retrieved.get_title()}`);
|
||||
print(` Content: ${retrieved.get_content()}\n`);
|
||||
|
||||
// Query by tag
|
||||
print("Querying notes by tag...");
|
||||
let ids = query("test_notes", "tags:tag", "source=osiris-runner");
|
||||
print("✓ Found notes:");
|
||||
for id in ids {
|
||||
print(` - ${id}`);
|
||||
}
|
||||
|
||||
print("=== Test Complete ===");
|
||||
Reference in New Issue
Block a user