Skip to content

Conversation

@mina-asham
Copy link
Contributor

@mina-asham mina-asham commented Jan 27, 2019

Fixes issue #492, and revives pull request #1132

The code is mostly based on the previous pull request with one main modification: exposing the unix domain socket file in the constructor. This makes the interface more clear from a Jedis client point of view.

Note: Tests were already failing due to latest Redis unstable version, but the test for this commit is working fine, and all tests pass on Redis 5.0 branch.

@mina-asham mina-asham force-pushed the unix-domain-socket branch 4 times, most recently from 12d1afc to 86835f4 Compare February 2, 2019 11:23
@mina-asham
Copy link
Contributor Author

@sazzad16 @marcosnils @gkorland can you have a look?
Also, @sunheehnus as owner of the original pull request.

@gkorland gkorland requested review from gkorland and sazzad16 July 3, 2019 14:18
</dependency>
<dependency>
<groupId>com.kohlschutter.junixsocket</groupId>
<artifactId>junixsocket-native-common</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of adding one more dependency* just to support one feature.

* compile time

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wasn't too mad about it as well, but thought it would be fine since it's a small dependency. So I think we have a few options (ordered by most to least favourite by me, but open to suggestions):

  • [My preferred suggestion] Make the dependency an optional one and do a reflection check to see if it is and if the feature can be supported
  • Shade and include the dependency (also since it's tiny), this way it would be self included and no need for consumers to worry
  • Accept the dependency as is now since it's tiny
  • Not include it at all and follow your below comments passing a socket straight in the constructor. It's my least preferred because I think the consumer shouldn't need to worry about creating/configuring the socket, specially that Jedis has some good defaults there. In the below comment you mention other sockets, any specific ones in mind?

(Sorry for the delayed response, this escaped me somehow...)

this.host = host;
}

public Connection(final File unixDomainSocket) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we take the Socket (and/or other objects) or a custom object which would create/connect a socket on demand? This would help to support many forms of sockets to be supported by Jedis at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See last point in above comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mention other sockets, any specific ones in mind?

Not anything specific, rather generic.

I just meant, if we had such constructor, sockets like unix domain socket, ssl or even plain socket with different configuration from Jedis could be used by users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just meant, if we had such constructor, sockets like unix domain socket, ssl or even plain socket with different configuration from Jedis could be used by users.

We can do that, but I think the question is should we expose that to the user as part of the library?

Jedis tries to do such constructs under the hood and expose other options (ssl, passwords, etc...) and sets some defaults for each of these, we would risk exposing this and making the library a bit harder (or a bit more confusing) to use.

It doesn't make much difference to my case by the way, so I am not opposing this, I just want to make sure you would be okay with that (minimal) risk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we would risk exposing this and making the library a bit harder (or a bit more confusing) to use.

I'm not sure I follow you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a user, I would much rather set a minimal parameters (e.g. port number, UDS path, credentials), than creating/setting/maintaining a socket (more code and might not be setup with the best configuration unless I am an advanced user).

Not the strongest argument, but this is my intuition. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • About dependency:
    Most users are not enthusiastic about more dependencies. So I'm a bit reluctant on this.

  • About not easy option:
    At least it is an option which would allow avid users to avoid long routes (like extending Jedis/Connection classes, building custom Jedis). Let's take sendCommand method (coming in 3.1.0) as an example. It would require some coding for the user but would allow them to use new commands in Redis (which are not in Jedis) more easily without waiting for Jedis to include those.

These are my viewpoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, sounds good, I will refactor this to allow creating it with a Socket object for advanced use-cases, will update this soon :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mina-asham Please take a look at #2036. WDYT?

mina-asham added a commit to mina-asham/jedis that referenced this pull request Mar 10, 2020
…main Socket) or any other custom address resolution

- Related pull requests: redis#2036 and redis#1942 and redis#1132
sazzad16 pushed a commit that referenced this pull request Apr 14, 2020
This can enable UDS (Unix Domain Socket) or any other custom address resolution

- Related feature request: #1998
- Related pull requests: #2036 and #1942 and #1132
@sazzad16
Copy link
Contributor

Resolved by #2151

@sazzad16 sazzad16 closed this Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants