-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest-manager.el
70 lines (57 loc) · 2.03 KB
/
request-manager.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
;;; force-mode.el --- A functional force IDE -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
(defvar requests '(0 ""))
(defvar default-timeout-ms 5000)
(defvar default-request-interval-ms 100)
(defvar request-num 0)
(defvar request-timer 0)
(defun construct-request-message (type)
"TYPE ."
`(status "PENDING" ,type))
(defun force-mode-add-to-request-queue (args)
"ARGS ."
(progn (setq request-num (+ 1 request-num))
(plist-put requests request-num args)
request-num))
;; (defun force-mode-start-request-timer ()
;; )
(defun force-mode-monitor (req-key)
"REQ-KEY check for completed requests; remove key when found."
(let* ((results (plist-get requests req-key))
(status (plist-get results 'status)))
(print (concat "key is" status))
(cond ((string= "PENDING" status) "Pending")
((string= "SUCCESS" status) "Success")
((string= "FAIL" status) "Fail")
("No request"))))
(defun force-cli-helm-complete (data)
"DATA ."
(interactive)
(helm :sources (helm-build-sync-source "objects"
:candidates data
:fuzzy-match t)
:buffer "* Force cli completions *"))
(defun force-cli-complete (params)
"PARAMS ."
(request
(concat "localhost:8080/complete")
:params params
:parser
(lambda ()
(let ((json-object-type 'plist))
(json-read)))
:success
(function* (lambda (&key data &allow-other-keys)
(progn
(setq tester (cl-map 'list #'identity data))
(force-cli-helm-complete data))))))
(defun force-mode-send-request (filter)
(progn (force-cli-complete `(("filter" . ,filter)
("api" . "true")))))
;; (force-mode-send-request "ALMErrorServices.")
;; (force-cli-helm-complete tester)
(defun force-mode-server-request (request)
"REQUEST put a request in the queue, and give the requestor a key to monitor."
(let ((req-key (force-mode-add-to-request-queue (construct-request-message request))))
(force-mode-monitor req-key)))