Comments (15)
I guess we need to allow configuring nrepl-sync-request-timeout
variable in clomacs
from ejc-sql.
User can change nrepl-sync-request-timeout
directly, clomacs is trying to be close to CIDER as much as possible. But there are some ideas to do:
nrepl-sync-request-timeout
should be mentioned in ejc-sql README.- Timeout should have possibility to be passed to
ejc-eval-user-sql-at-point
as prefix number,
e.g. M-6 M-0 C-c C-c - eval SQL with 60 sec timeout. - For autocomplete we should eval SQL asynchronously.
from ejc-sql.
most of my queries take more than a min, I had set nrepl-sync-request-timeout
to 60 sec in my .spacemacs
file and it works, ty.
For making autocomplete to work async, do we have anything in clomacs that support async execution?
from ejc-sql.
do we have anything in clomacs that support async execution?
Not yet.
from ejc-sql.
ok sure, can we add this as an enhancement to clomacs and use it for long running calls in ejc-sql.
from ejc-sql.
Another idea is to load and cache the database structure in the clojure side and use the sync requests as usual.
from ejc-sql.
Database structure is already cached in EmacsLisp side. But it's an interesting idea. EmacsLisp request for database structure data can start async Clojure (probably long-running) request and receive cached data or empty data (if request still running) immediately.
from ejc-sql.
Tried writing a async version of the clomacs-defun macro, here is what i have
;;;###autoload
(cl-defmacro clomacs-defun-async (el-func-name
cl-func-name
callback-func-name
&optional &key
(doc nil)
(return-type :string)
(return-value :value)
lib-name
namespace)
"Wrap CL-FUNC-NAME, evaluated on clojure side by EL-FUNC-NAME.
DOC - optional elisp function docstring (when nil it constructed from
underlying clojure entity docstring if possible).
RETURN-TYPE possible values are listed in the CLOMACS-POSSIBLE-RETURN-TYPES,
or it may be a custom function (:string by default).
RETURN-VALUE may be :value or :stdout (:value by default)."
(cl-multiple-value-bind
(doc namespace-str cl-entity-full-name)
(clomacs-prepare-vars cl-func-name
:doc doc
:namespace namespace)
`(defun ,el-func-name (&rest attributes)
,doc
(clomacs-ensure-nrepl-run ,lib-name)
(let* ((attrs ""))
(dolist (a attributes)
(setq attrs (concat attrs " "
(clomacs-format-arg a))))
(let* ((connection (clomacs-get-connection ,lib-name))
(session (clomacs-get-session connection)))
(nrepl-request:eval
(concat
(if ',namespace
(concat "(require '" ',namespace-str ") ") "")
"(" ',cl-entity-full-name attrs ")")
(lambda (result)
(let* ((el-result (clomacs-get-result
result ,return-value ',return-type ',namespace)))
(message "result %s :: el-result %s" result el-result)
(if el-result
(,callback-func-name el-result))))
connection
session))
))))
and the test code
The following tests works as well, had verified them manually, couldn't find a way to test async calls
(defun result-handler (result)
(message "Result: %s" result))
(clomacs-defun-async summ-1 * (lambda (result)
(message "Result: %s" result)
result))
(summ-1 3 5 9)
(clomacs-defun-async summ-2 + result-handler :return-type :number)
(summ-2 2 3)
(clomacs-defun-async summ-3 + result-handler :return-type string-to-int)
(summ-3 2 3)
(clomacs-defun-async str str result-handler)
(str 2 "str")
(clomacs-defun-async get-property System/getProperty result-handler)
(get-property "java.version")
(clomacs-defun-async make-clojure-list list result-handler :return-type :list)
(make-clojure-list 1 2 3)
(clomacs-defun-async make-clojure-vector vector result-handler :return-type :list)
(make-clojure-vector 1 2 3)
Values can be null when async call returns status and completion, so added a null check in the format method
(defun clomacs-format-result (raw-string return-type)
"Format Elisp representation of Clojure evaluation result."
(cl-assert return-type)
(if raw-string
...)))) ))
from ejc-sql.
I see the changes adapted in clomacs, ty. Let me get the latest version check and see
from ejc-sql.
I see the changes adapted in clomacs
That is a rough version, but feel free to play with it.
from ejc-sql.
Ok, looks like there is no way to prevent unwanted calls for callback except checking for result is not nil.
from ejc-sql.
no way to prevent unwanted calls for callback except checking for result is not nil.
yes, nprel calls the callback for value and status update. I was looking into nrepl source code to see if they can send multiple messages with value, if they are sending multiple then we may have to collect all values till the status is done and then call the callback with the complete value.
from ejc-sql.
@tutysara you can test last activity about this issue in the new-cache
branch. It will be merged to master
branch soon after some testing.
from ejc-sql.
sure, let me test after office and update
from ejc-sql.
@tutysara new-cache
branch merged to master
, so the let's consider issue closed. In the case of any related bugs or ideas, new issues should be created.
from ejc-sql.
Related Issues (20)
- Please let `DESCRIBE-TABLE` show comment about the fields.
- Error when trying to connect HOT 1
- how to connect mongodb
- Transaction rollback not working HOT 1
- Failure on connect in Emacs 28 with native compilation HOT 3
- ejc:goto--line-column not defined HOT 1
- ejc-connect got AbstractMethodError HOT 1
- Table in ejc-result not align correct. HOT 2
- Is that prosssible to use key word USE in mysql?
- No suitable driver found for jdbc:postgresql://localhost:5432/db HOT 2
- Support for displaying PL/SQL output
- Cloudera Impala JDBC support? HOT 4
- ejc-eval-org-snippet should return org table if possible HOT 1
- Warning about obosolete generalized variable 'point' HOT 1
- postgre List of relations error HOT 1
- Where would be a good place to escape/handle the pipe char "|" in the results? HOT 1
- No such function `pprint`
- ejc-connect fails frequently
- Upon killing buffer with connection, reopenning buffer raises error "Selecting deleted buffer"
- Is there a setting to show <null> values in the result buffer?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ejc-sql.