sal/service_manager/examples
Mahmoud-Emad a63cbe2bd9 Fix service manager examples to use production-ready API
- 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
2025-07-02 10:46:47 +03:00
..
README.md service manager add examples and improvements 2025-07-02 05:50:18 +02:00
service_spaghetti.rs Fix service manager examples to use production-ready API 2025-07-02 10:46:47 +03:00
simple_service.rs Fix service manager examples to use production-ready API 2025-07-02 10:46:47 +03:00

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:

  1. Creates a new service definition.
  2. Starts the newly created service.
  3. Checks its status to confirm it's running.
  4. Stops the service.
  5. Checks its status again to confirm it's stopped.
  6. 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:

  1. Creates a service.
  2. Starts the service.
  3. Tries to start the same service again (which should fail as it's already running).
  4. Removes the service without stopping it first (the manager should handle this gracefully).
  5. Tries to stop the already removed service (which should fail).
  6. Tries to remove the service again (which should also fail).

Run it:

cargo run --example service_spaghetti