Fix task action handling
Refactor actions to remove context
This commit is contained in:
parent
f2f88ce0dc
commit
b463a828be
3 changed files with 8 additions and 8 deletions
|
@ -5,7 +5,6 @@
|
||||||
#:use-module (srfi srfi-71) ; extended let
|
#:use-module (srfi srfi-71) ; extended let
|
||||||
#:use-module ((srfi srfi-197) #:select (chain-when))
|
#:use-module ((srfi srfi-197) #:select (chain-when))
|
||||||
#:use-module (ordo connection)
|
#:use-module (ordo connection)
|
||||||
#:use-module (ordo context)
|
|
||||||
#:export (create-temporary-directory
|
#:export (create-temporary-directory
|
||||||
install-directory
|
install-directory
|
||||||
install-file))
|
install-file))
|
||||||
|
@ -30,7 +29,7 @@
|
||||||
;; Helper not intended for use outside of this module
|
;; Helper not intended for use outside of this module
|
||||||
(define (upload-tmp-file conn)
|
(define (upload-tmp-file conn)
|
||||||
(lambda (input-port)
|
(lambda (input-port)
|
||||||
(let ((tmp-path (car (connection-must conn "mktemp"))))
|
(let ((tmp-path (car (connection-must conn "mktemp" '()))))
|
||||||
(connection-call-with-output-file conn tmp-path
|
(connection-call-with-output-file conn tmp-path
|
||||||
(lambda (output-port)
|
(lambda (output-port)
|
||||||
(let loop ((data (get-bytevector-some input-port)))
|
(let loop ((data (get-bytevector-some input-port)))
|
||||||
|
|
|
@ -28,15 +28,16 @@
|
||||||
((_ description (action arg ...) kwarg ...)
|
((_ description (action arg ...) kwarg ...)
|
||||||
(task%
|
(task%
|
||||||
description
|
description
|
||||||
(lambda (conn ctx)
|
(lambda (ctx)
|
||||||
(action conn (resolve-context-refs ctx arg) ...))
|
(action (resolve-context-refs ctx arg) ...))
|
||||||
kwarg ...))))
|
kwarg ...))))
|
||||||
|
|
||||||
(define (run-task conn ctx task)
|
(define (run-task conn ctx t)
|
||||||
(match task
|
(match t
|
||||||
(($ <task> description action register triggers)
|
(($ <task> description action register triggers)
|
||||||
(format #t "RUNNING TASK ~a~%" description)
|
(format #t "RUNNING TASK ~a~%" description)
|
||||||
(let ((result (action conn ctx)))
|
(pk 'action action)
|
||||||
|
(let ((result ((action ctx) conn)))
|
||||||
(when register
|
(when register
|
||||||
(register-context-var! ctx register result))
|
(register-context-var! ctx register result))
|
||||||
(when triggers
|
(when triggers
|
||||||
|
|
|
@ -38,4 +38,4 @@
|
||||||
(fritz . ,(handler "Fritz" (const #t)))
|
(fritz . ,(handler "Fritz" (const #t)))
|
||||||
(frotz . ,(handler "Frotz" (const #t))))))
|
(frotz . ,(handler "Frotz" (const #t))))))
|
||||||
|
|
||||||
;;(run-play test-play)
|
(run-play test-play)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue