From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Kost Subject: [PATCH 2/4] Rename 'dmd-command' to 'shepherd-command'. Date: Fri, 22 Jan 2016 22:44:30 +0300 Message-ID: <1453491872-6129-3-git-send-email-alezost@gmail.com> References: <1453491872-6129-1-git-send-email-alezost@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMhdd-0004xX-2I for guix-devel@gnu.org; Fri, 22 Jan 2016 14:44:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMhdZ-0003Jy-Sy for guix-devel@gnu.org; Fri, 22 Jan 2016 14:44:52 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:34428) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMhdZ-0003Jq-Fo for guix-devel@gnu.org; Fri, 22 Jan 2016 14:44:49 -0500 Received: by mail-lf0-x243.google.com with SMTP id n70so4651190lfn.1 for ; Fri, 22 Jan 2016 11:44:49 -0800 (PST) Received: from localhost.localdomain ([217.107.192.146]) by smtp.gmail.com with ESMTPSA id kv3sm1057630lbc.39.2016.01.22.11.44.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jan 2016 11:44:48 -0800 (PST) In-Reply-To: <1453491872-6129-1-git-send-email-alezost@gmail.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org * modules/shepherd/comm.scm (): Rename record type and its accessors to... (): ... this. (read-command, write-command): Adjust accordingly. * modules/halt.scm (main): Likewise. * modules/herd.scm (run-command): Likewise. * modules/reboot.scm (main): Likewise. * modules/shepherd.scm (process-command, process-textual-commands): Likewise. * tests/status-sexp.sh: Likewise. * shepherd.texi (Communication): Likewise. --- modules/halt.scm | 2 +- modules/herd.scm | 2 +- modules/reboot.scm | 2 +- modules/shepherd.scm | 10 +++---- modules/shepherd/comm.scm | 66 +++++++++++++++++++++++------------------------ shepherd.texi | 15 ++++++----- tests/status-sexp.sh | 4 +-- 7 files changed, 51 insertions(+), 50 deletions(-) diff --git a/modules/halt.scm b/modules/halt.scm index 96da176..0f4a814 100644 --- a/modules/halt.scm +++ b/modules/halt.scm @@ -50,7 +50,7 @@ (with-system-error-handling (let ((sock (open-connection socket-file))) ;; Send the command without further ado. - (write-command (dmd-command 'power-off 'dmd) sock) + (write-command (shepherd-command 'power-off 'dmd) sock) ;; Receive output. (setvbuf sock _IOLBF) diff --git a/modules/herd.scm b/modules/herd.scm index 40bd10a..3b330cb 100644 --- a/modules/herd.scm +++ b/modules/herd.scm @@ -104,7 +104,7 @@ the daemon via SOCKET-FILE." 'status action))) ;; Send the command. - (write-command (dmd-command action* service #:arguments args) + (write-command (shepherd-command action* service #:arguments args) sock) ;; Receive output. diff --git a/modules/reboot.scm b/modules/reboot.scm index d92f2de..df21c7f 100644 --- a/modules/reboot.scm +++ b/modules/reboot.scm @@ -50,7 +50,7 @@ (with-system-error-handling (let ((sock (open-connection socket-file))) ;; Send the command without further ado. - (write-command (dmd-command 'stop 'dmd) sock) + (write-command (shepherd-command 'stop 'dmd) sock) ;; Receive output. (setvbuf sock _IOLBF) diff --git a/modules/shepherd.scm b/modules/shepherd.scm index 2104848..1a14f09 100644 --- a/modules/shepherd.scm +++ b/modules/shepherd.scm @@ -222,9 +222,9 @@ (define (process-command command port) "Interpret COMMAND, a command sent by the user, represented as a - object. Send the reply to PORT." + object. Send the reply to PORT." (match command - (($ the-action service-symbol (args ...) dir) + (($ the-action service-symbol (args ...) dir) (chdir dir) ;; We have to catch `quit' so that we can send the terminator @@ -281,9 +281,9 @@ would write them on the 'herd' command line." (begin (match (string-tokenize line) ((action service arguments ...) - (process-command (dmd-command (string->symbol action) - (string->symbol service) - #:arguments arguments) + (process-command (shepherd-command (string->symbol action) + (string->symbol service) + #:arguments arguments) port)) (_ (local-output "invalid command line" line))) diff --git a/modules/shepherd/comm.scm b/modules/shepherd/comm.scm index b7bfc8c..79983b4 100644 --- a/modules/shepherd/comm.scm +++ b/modules/shepherd/comm.scm @@ -25,13 +25,13 @@ #:use-module (ice-9 match) #:export (open-connection - - dmd-command? - dmd-command - dmd-command-directory - dmd-command-action - dmd-command-service - dmd-command-arguments + + shepherd-command? + shepherd-command + shepherd-command-directory + shepherd-command-action + shepherd-command-service + shepherd-command-arguments command-reply @@ -53,19 +53,19 @@ shepherd-output-port)) -;; Command for dmd. -(define-record-type - (%dmd-command action service args directory) - dmd-command? - (action dmd-command-action) ; symbol - (service dmd-command-service) ; symbol - (args dmd-command-arguments) ; list of strings - (directory dmd-command-directory)) ; directory name - -(define* (dmd-command action service - #:key (arguments '()) (directory (getcwd))) +;; Command for shepherd. +(define-record-type + (%shepherd-command action service args directory) + shepherd-command? + (action shepherd-command-action) ; symbol + (service shepherd-command-service) ; symbol + (args shepherd-command-arguments) ; list of strings + (directory shepherd-command-directory)) ; directory name + +(define* (shepherd-command action service + #:key (arguments '()) (directory (getcwd))) "Return a new command for ACTION on SERVICE." - (%dmd-command action service arguments directory)) + (%shepherd-command action service arguments directory)) (define* (open-connection #:optional (file default-socket-file)) "Open a connection to the daemon, using the Unix-domain socket at FILE, and @@ -89,24 +89,24 @@ return the socket." (define (read-command port) "Receive a command from PORT." (match (read port) - (('dmd-command ('version 0 _ ...) - ('action action) - ('service service) - ('arguments args ...) - ('directory directory)) - (dmd-command action service - #:arguments args - #:directory directory)))) + (('shepherd-command ('version 0 _ ...) + ('action action) + ('service service) + ('arguments args ...) + ('directory directory)) + (shepherd-command action service + #:arguments args + #:directory directory)))) (define (write-command command port) "Write COMMAND to PORT." (match command - (($ action service (arguments ...) directory) - (write `(dmd-command (version 0) ; protocol version - (action ,action) - (service ,service) - (arguments ,@arguments) - (directory ,directory)) + (($ action service (arguments ...) directory) + (write `(shepherd-command (version 0) ; protocol version + (action ,action) + (service ,service) + (arguments ,@arguments) + (directory ,directory)) port)))) diff --git a/shepherd.texi b/shepherd.texi index b980254..105155f 100644 --- a/shepherd.texi +++ b/shepherd.texi @@ -1066,16 +1066,17 @@ as @command{herd} to connect to @command{shepherd} and send it commands to control or change its behavior (@pxref{Slots of services, actions of services}). -@tindex +@tindex Currently, clients may only send @dfn{commands}, represented by the -@code{} type. Each command specifies a service it applies -to, an action name, a list of strings to be used as arguments, and a -working directory. Commands are instantiated with @code{dmd-command}: +@code{} type. Each command specifies a service it +applies to, an action name, a list of strings to be used as arguments, +and a working directory. Commands are instantiated with +@code{shepherd-command}: -@deffn {procedure} dmd-command @var{action} @var{service} @ +@deffn {procedure} shepherd-command @var{action} @var{service} @ [#:@var{arguments} '()] [#:@var{directory} (getcwd)] -Return a new command (a @code{}) object for @var{action} on -@var{service}. +Return a new command (a @code{}) object for +@var{action} on @var{service}. @end deffn @noindent diff --git a/tests/status-sexp.sh b/tests/status-sexp.sh index a16c847..b47ce9a 100644 --- a/tests/status-sexp.sh +++ b/tests/status-sexp.sh @@ -62,7 +62,7 @@ test -S "$socket" # Code to fetch service status info. fetch_status=" (let ((sock (open-connection \"$socket\"))) - (write-command (dmd-command 'status 'dmd) sock) + (write-command (shepherd-command 'status 'dmd) sock) (read sock))" dmd_service_sexp=" @@ -98,7 +98,7 @@ dmd_service_sexp=" (use-modules (shepherd comm) (ice-9 match)) (match (let ((sock (open-connection \"$socket\"))) - (write-command (dmd-command 'status 'does-not-exist) sock) + (write-command (shepherd-command 'status 'does-not-exist) sock) (read sock)) (('reply _ ... ('error ('error _ 'service-not-found 'does-not-exist)) -- 2.6.3