xquery-mode / cider-any

Evaluate any buffer in cider – Replaced by Oook
0 stars 1 forks source link

multiple connection support #9

Closed m-g-r closed 7 years ago

m-g-r commented 8 years ago

Hi,

I usually have several xdbc servers I want to talk to at the same time (as I want to upload to one db and see the contents of the other).

hm, maybe having a list of connections instead of just one and C-c C-c have considering arguments with C-u? Right now I work with just two connection, where one of them is just occasionally used, so it'd be nice to use the first connection as the default and be easily possible to occasionally switch to "the other connection". But it will be probably even more than just two connections, then it would be great if it is possible to address more than two connection easily.

And a pony. ;)

Cheers, Max

proofit404 commented 8 years ago

Do you want to use multiple connections for the same buffer?

m-g-r commented 8 years ago

Uhm, I don't think so.

m-g-r commented 8 years ago

I wrote a quick hack for two connections that works for me for now. just switches between two DBs via prefix argument and I use it by having the line "(xdmp-select-db (prefix-numeric-value current-prefix-arg))" in other commands:

(defun xdmp-select-db (sel)
  "switch between two DBs." ;; this is clearly a hack
  (interactive "p")
  (if (= sel 1)
      (setq cider-any-uruk-uri "xdbc://localhost:8021/"
            cider-any-uruk-user "admin"
            cider-any-uruk-password "admin")
    (setq cider-any-uruk-uri "xdbc://localhost:8022/"
          cider-any-uruk-user "admin"
          cider-any-uruk-password "admin")))
proofit404 commented 8 years ago

I've added dbselector-mode (see it in the examples folder). With its help you can choose current connection and manage connection list. To use it open dbselector library, evaluate buffer. Then in the each xquery-mode buffer following commands will be available:

C-c d b a   dbselector-add
C-c d b r   dbselector-remove
C-c d b s   dbselector-set
C-c d b u   dbselector-unset

This mode make uruk connection parameters buffer local.

Please give it a try and let me know about functionality you miss.

proofit404 commented 7 years ago

dbselector and xdbc-selector kinda do same thing now? Is it necessary to abandon dbselector in the favor of xdbc-selector. Or is it any features to port from one project to another?

m-g-r commented 7 years ago

Hey Artem!

dbselector and xdbc-selector kinda do same thing now? Is it necessary to abandon dbselector in the favor of xdbc-selector. Or is it any features to port from one project to another?

No, xdbc-selector is thought as an interface to MarkLogic and does not only connection/session connection management, but allows also to manage documents and such.

But I've completely revised xdbc-selector now (see below). It doesn't mess with connections anymore, and as such should work together with your dbselector; though, right now I don't need dbselector anymore as what I wanted to achieve (easy access to the current modules database) was possible to manage in a cleaner way. But I think dbselector could still be useful if you talk to several servers!

I'd say both should stay.

Please, have a look at see: https://github.com/xquery-mode/xdbc-selector for revised README

Commit message was: completely revised xdbc-selector: don't mess with the connections anymore but ask the server what the available databases are: all, default, modules.

Cheers, Max

m-g-r commented 7 years ago

Artem, the connection lists are per buffer now, right? That, I think, is a bit cumbersome. I'd probably rather want a global connections list and easy means to switch. What do you think?

Or is the list of available connections managed globally and you select ("set") the connection per buffer. That is probably nice if it is the case.

Sorry, I'm not yet sure what is the best way. So it is a bit open...

Bye Max

proofit404 commented 7 years ago

You're right. Database list is global, but connection for current buffer is local. There is no default/failback database for now.

m-g-r commented 7 years ago

I consider this issue closed. We don't need this feature anymore, as we use now functionality of an external configuration service.

Of course, dbselector.el can stay, if you want. Though, it already will not work with the changes proposed in https://github.com/xquery-mode/cider-any/pull/15. I don't know if you want to keep if it needs extra work to adapt it to other changes.

Thanks!