guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[shepherd] 05/06: service: Re-purpose ‘action’ to create a new action.


From: Ludovic Courtès
Subject: [shepherd] 05/06: service: Re-purpose ‘action’ to create a new action.
Date: Sun, 24 Mar 2024 17:11:35 -0400 (EDT)

civodul pushed a commit to branch devel
in repository shepherd.

commit a2446951d8d4b639e7fa56807b25736c1fa972ae
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Sun Mar 24 22:02:14 2024 +0100

    service: Re-purpose ‘action’ to create a new action.
    
    * modules/shepherd/service.scm (action): New procedure, replacing the
    generic function.
    Export <action> accessors.
    * doc/shepherd.texi (Defining Services): Document ‘action’.
---
 doc/shepherd.texi            | 10 ++++++++--
 modules/shepherd/service.scm | 24 +++++++++++-------------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/doc/shepherd.texi b/doc/shepherd.texi
index 8593ad0..2e340b5 100644
--- a/doc/shepherd.texi
+++ b/doc/shepherd.texi
@@ -853,8 +853,14 @@ format, such as 
@uref{https://github.com/jrfonseca/xdot.py, xdot}:
 herd graph | xdot -
 @end example
 
-Service actions are defined using the @code{actions} macro, as
-shown below.
+Service actions are defined using the @code{action} procedure or the
+@code{actions} (plural) macro, as shown below.
+
+@deffn {Procedure} action @var{name} @var{proc} [@var{doc}]
+Return a new action with the given @var{name}, a symbol, that executes
+@var{proc}, a one-argument procedure that is passed the service's running
+value.  Use @var{doc} as the documentation of that action.
+@end deffn
 
 @defmac actions (name proc) @dots{}
 Create a value for the @code{#:actions} parameter of @code{service}.
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 5530edd..e358bf1 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -81,7 +81,12 @@
             service-name-count
             current-service
 
+            action
             action?
+            action-name
+            action-procedure
+            action-documentation
+            actions
 
             enable-service
             disable-service
@@ -150,8 +155,6 @@
             missing-service-error?
             missing-service-name
 
-            actions
-
             &unknown-action-error
             unknown-action-error?
             unknown-action-name
@@ -183,7 +186,6 @@
             disable
             start
             stop
-            action
             action-list
             make-actions
             lookup-action
@@ -227,6 +229,12 @@
   (proc action-procedure)
   (doc  action-documentation))
 
+(define* (action name proc #:optional (doc "[No documentation.]"))
+  "Return a new action with the given @var{name}, a symbol, that executes
+@var{proc}, a one-argument procedure that is passed the service's running
+value.  Use @var{doc} as the documentation of that action."
+  (make-action name proc doc))
+
 ;; Conveniently create a list of <action> objects containing the actions for a
 ;; <service> object.
 (define-syntax actions
@@ -3009,16 +3017,6 @@ deprecated in favor of procedure '~a'"
 (define-deprecated-method (defines-action? (service <service>) action)
   service-defines-action?)
 
-(define-deprecated-method/rest (action (service <service>))
-  perform-service-action)
-(define-method (action (name <symbol>) the-action . args)
-  "Perform THE-ACTION on all the services named OBJ.  Return the list of
-results."
-  (match (lookup-service name)
-    (#f
-     (raise (condition (&missing-service-error (name name)))))
-    (service
-     (list (apply action service the-action args)))))
 (define-deprecated-method/rest (start (service <service>))
   start-service)
 (define-method (start (name <symbol>) . args)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]