Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.whoami() #3934

Closed
neumino opened this issue Mar 13, 2015 · 24 comments
Closed

r.whoami() #3934

neumino opened this issue Mar 13, 2015 · 24 comments
Assignees
Milestone

Comments

@neumino
Copy link
Member

neumino commented Mar 13, 2015

It's similar to what was mentioned in #2979 but my use case is a bit different. I'm trying to have the connection pool in rethinkdbdash automatically populates connections to all the servers listed in the table server_status.

And one problem that surfaces is that people may try to populate the pool from localhost. I have one pool per server (and a "master" that manage all these pools). Since localhost will match all the servers, I can't know exactly in which pool I should put these connections.

I'm working around this by opening new connection to not localhost (by picking up the "wider" address and closing the one to localhost, but being able to run r.whoami() and get a server id would make the code way more simple.
If the server id can be returned at the end of the handshake, that would also work for me.

@deontologician
Copy link
Contributor

+1 this is the last special /ajax functionality the webui is using (beyond the http reql connections)

@mlucy mlucy added this to the 2.1 milestone Mar 18, 2015
@mlucy
Copy link
Member

mlucy commented Mar 18, 2015

@danielmewes -- putting this in 2.1 so it's in a milestone and we don't forget about it, but feel free to move it out if there isn't room.

@danielmewes
Copy link
Member

There was some relevant discussion about this in #2979

We should consider exposing this functionality as a function on the connection object instead of a ReQL term I think, like discussed over there.

@timmaxw
Copy link
Member

timmaxw commented Apr 21, 2015

Yeah, I definitely think this should be a method or variable on the connection rather than a ReQL term.

@danielmewes
Copy link
Member

To bring something else over from the other thread: I really prefer the name conn.server_uuid() over conn.whoami().

@timmaxw
Copy link
Member

timmaxw commented Apr 21, 2015

I think server_id is better, for consistency with the system tables.

@danielmewes
Copy link
Member

Sure, server_id sounds good.

@coffeemug
Copy link
Contributor

👍 for conn.server_id()

@deontologician
Copy link
Contributor

to clarify, will this return the uuid of the server, the server name, or the hostname of the server?

@timmaxw
Copy link
Member

timmaxw commented Apr 22, 2015

This will return the UUID of the server as a string.

@timmaxw
Copy link
Member

timmaxw commented Apr 22, 2015

Also, it's not a query. So if you run >>> conn.server_id() in the Python console, it just returns the UUID as a string. You don't write conn.server_id().run(conn) or anything like that.

@deontologician
Copy link
Contributor

It'd be super super nice if I could get the server name as well without having to query server_config

@mlucy
Copy link
Member

mlucy commented Apr 22, 2015

What if we had conn.server() and it returned {name: X, id: Y}?

@timmaxw
Copy link
Member

timmaxw commented Apr 22, 2015

If conn.server() internally compiles to r.secret_magic_whoami().run(conn), then that's easy. If conn.server() returns the value of a local variable that was transmitted during the handshake, then that's difficult.

@Tryneus
Copy link
Member

Tryneus commented Apr 22, 2015

It doesn't have to be a term, we have NOREPLY_WAIT as a query-type rather than a term-type, we could add another query-type SERVER_INFO or something.

@danielmewes danielmewes modified the milestones: 2.1, 2.1-polish Apr 22, 2015
@coffeemug
Copy link
Contributor

What if we had conn.server() and it returned {name: X, id: Y}?

👍 (assuming implementing this isn't too painful).

@danielmewes
Copy link
Member

I think either conn.server_id() or conn.server() would be sufficient.
I think we should implement the latter with {name: X, id: Y} if it's about the same amount of work, and the former returning only the ID if it's easier.

@VeXocide
Copy link
Member

A conn.server_id() sounds good.

@danielmewes
Copy link
Member

Marking settled with conn.server_id(), or conn.server() if it's similarly easy to implement.

@mglukhovsky
Copy link
Member

This would be really useful for the web UI, and for rethinkdb import (see #4617).

@dancannon
Copy link

Would also be really useful for gorethink, currently the way I am checking host status is a bit hacky.

@encryptio
Copy link
Contributor

in review with @VeXocide, CR 3317

@dancannon
Copy link

This is great, Thanks for the work guys!

@encryptio
Copy link
Contributor

Done in next, will be in 2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests