Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 95fdf89d authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

proxy: Add user-defined properties to <proxy-state>.

* guix/jupyter/proxy.scm (<proxy-state>)[properties]: New field.
(proxy-state): Adjust accordingly.
(proxy-state-property, set-proxy-state-property): New procedures.
parent 1201d247
......@@ -19,6 +19,7 @@
#:use-module (jupyter messages)
#:use-module (jupyter kernels)
#:use-module (gcrypt base16)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9 gnu)
#:use-module (ice-9 vlist)
#:use-module (ice-9 match)
......@@ -35,6 +36,9 @@
proxy-state-proxied-number
increment-execution-count
set-proxy-state-execution-count
proxy-state-property
set-proxy-state-property
terminate-proxied-kernels
proxy-request-handler))
......@@ -46,17 +50,19 @@
;;; Code:
(define-immutable-record-type <proxy-state>
(%proxy-state client client-id proxied count)
(%proxy-state client client-id proxied count properties)
proxy-state?
(client proxy-state-client set-proxy-state-client) ;<kernel>
(client-id proxy-state-client-id set-proxy-state-client-id) ;bytevector
(proxied proxy-state-proxied set-proxy-state-proxied) ;vhash
(count proxy-state-execution-count ;integer
set-proxy-state-execution-count))
set-proxy-state-execution-count)
(properties proxy-state-properties ;alist
set-proxy-state-properties))
(define* (proxy-state client #:key client-id)
"Return a new proxy state with CLIENT, a <kernel>, as its client."
(%proxy-state client client-id vlist-null 0))
(%proxy-state client client-id vlist-null 0 '()))
(define (register-proxied name kernel state)
"Register KERNEL as a proxied kernel with the given NAME in STATE, a
......@@ -130,3 +136,18 @@ HANDLERS, a list of message type/handler pairs, pass it to that handler."
#:kernel-socket kind
#:recipient id)
state))))
(define* (proxy-state-property state key #:optional default)
"Return the property associated with KEY in STATE, or DEFAULT if it could
not be found."
;; This is where we break into a property of the state.
(match (assq key (proxy-state-properties state))
(#f default)
((_ . value) value)))
(define (set-proxy-state-property state key value)
"Record the KEY/VALUE association in STATE's properties."
(let ((properties (proxy-state-properties state)))
(set-proxy-state-properties state
`((,key . ,value)
,@(alist-delete key properties eq?)))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment