- Updated simple_service.rs to use start(config) instead of create() + start(name) - Updated service_spaghetti.rs to use the same unified API - Fixed factory function calls to use create_service_manager() without parameters - All examples now compile and work with the production-ready synchronous API - Maintains backward compatibility while providing cleaner interface
Service Manager Examples
This directory contains examples demonstrating the usage of the sal-service-manager crate.
Running Examples
To run any example, use the following command structure from the service_manager crate's root directory:
cargo run --example <EXAMPLE_NAME>
1. simple_service
This example demonstrates the ideal, clean lifecycle of a service using the separated create and start steps.
Behavior:
- Creates a new service definition.
 - Starts the newly created service.
 - Checks its status to confirm it's running.
 - Stops the service.
 - Checks its status again to confirm it's stopped.
 - Removes the service definition.
 
Run it:
cargo run --example simple_service
2. service_spaghetti
This example demonstrates how the service manager handles "messy" or improper sequences of operations, showcasing its error handling and robustness.
Behavior:
- Creates a service.
 - Starts the service.
 - Tries to start the same service again (which should fail as it's already running).
 - Removes the service without stopping it first (the manager should handle this gracefully).
 - Tries to stop the already removed service (which should fail).
 - Tries to remove the service again (which should also fail).
 
Run it:
cargo run --example service_spaghetti