2025-02-10 14:49:30 +01:00
|
|
|
import pkg/chronos
|
|
|
|
|
import pkg/questionable/results
|
|
|
|
|
|
2025-02-10 15:34:41 +01:00
|
|
|
type Component* = ref object of RootObj
|
2025-02-10 14:49:30 +01:00
|
|
|
|
2025-06-02 15:00:32 +02:00
|
|
|
method awake*(c: Component): Future[?!void] {.async: (raises: [CancelledError]), base.} =
|
2025-03-21 13:04:10 +01:00
|
|
|
# Awake is called on all components in an unspecified order.
|
|
|
|
|
# Use this method to subscribe/connect to other components.
|
|
|
|
|
return success()
|
|
|
|
|
|
2025-06-02 15:00:32 +02:00
|
|
|
method start*(c: Component): Future[?!void] {.async: (raises: [CancelledError]), base.} =
|
2025-03-21 13:04:10 +01:00
|
|
|
# Start is called on all components in an unspecified order.
|
|
|
|
|
# Is is guaranteed that all components have already successfulled handled 'awake'.
|
|
|
|
|
# Use this method to begin the work of this component.
|
|
|
|
|
return success()
|
2025-02-10 14:49:30 +01:00
|
|
|
|
2025-06-02 15:00:32 +02:00
|
|
|
method stop*(c: Component): Future[?!void] {.async: (raises: [CancelledError]), base.} =
|
2025-03-21 13:04:10 +01:00
|
|
|
# Use this method to stop, unsubscribe, and clean up any resources.
|
|
|
|
|
return success()
|