branch: elpa/emacsql commit c89ccf82dfba245085d28903fa6fa0059915695d Author: Christopher Wellons <well...@nullprogram.com> Commit: Christopher Wellons <well...@nullprogram.com>
Make a reconnect generic method. --- README.md | 1 + emacsql.el | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a7998fe57..2e5b59096b 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,7 @@ inherits from `emacsql-connection`. * Provide `emacsql-types` if needed (hint: use a class-allocated slot). * Ensure that you properly read NULL as nil (hint: ask your back-end to print it that way). + * Preferably provide `emacsql-reconnect` if possible. The provided implementations should serve as useful examples. If your back-end outputs data in a clean, standard way you may be able to use diff --git a/emacsql.el b/emacsql.el index fc0d415836..315414e159 100644 --- a/emacsql.el +++ b/emacsql.el @@ -70,7 +70,7 @@ If nil, wait forever.") (defclass emacsql-connection () ((process :type process :initarg :process - :reader emacsql-process) + :accessor emacsql-process) (log-buffer :type (or null buffer) :initarg :log-buffer :accessor emacsql-log-buffer @@ -85,6 +85,13 @@ If nil, wait forever.") (defgeneric emacsql-close (connection) "Close CONNECTION and free all resources.") +(defgeneric emacsql-reconnect (connection) + "Re-establish CONNECTION with the same parameters.") + +(defmethod emacsql-live-p ((connection emacsql-connection)) + "Return non-nil if CONNECTION is still alive and ready." + (not (null (process-live-p (emacsql-process connection))))) + (defgeneric emacsql-types (connection) "Return an alist mapping Emacsql types to database types. This will mask `emacsql-type-map' during expression compilation.