Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

feature: Add UNIX socket support #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mauricioabreu
Copy link
Collaborator

No description provided.

@mauricioabreu
Copy link
Collaborator Author

I need some help here:

  • I could not figure out how to test the socket abstraction. spawn in the spec_helpers uses a real address. I don't know if I could just change it to another and let it go.
  • For some reason the test for UNIXServer is failing (but that I can figure out myself)
  • How would the cli work if everything needs a default value? Should not we handle hostname, port, unix file as just address?

Thank you!

@marceloboeira
Copy link
Owner

marceloboeira commented Sep 2, 2016

@mauricioabreu the code is quite nice so far, I will take a proper look tonight and try to answer your questions!

@mauricioabreu
Copy link
Collaborator Author

@marceloboeira Thank you!

@marceloboeira
Copy link
Owner

No, thank you for all the support.

:)

On Fri, Sep 2, 2016 at 10:13 AM Mauricio de Abreu Antunes <
notifications@github.com> wrote:

@marceloboeira https://github.com/marceloboeira Thank you!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#49 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABz28V_tPiJ6TvuGD1l-5FeRhMNpvRSRks5ql9q0gaJpZM4JzL-U
.

Marcelo Boeira

@mauricioabreu
Copy link
Collaborator Author

I was reading a book these days, "Practical Object-Oriented Design in Ruby". In the beginning of this book the author talks about the case where we create functions that need hostname and port and she asks why we don't call it just address.

@marceloboeira
Copy link
Owner

@mauricioabreu the thing is, you can have the hostname and port together, for sure. BUT you have to consider you are adding a responsibility to the class that receives the address, to split it. Since we don't use as an address, now this responsibility is credited to the "user".

If you add this logic and continue to do this for the dependencies, you make the server class handle a lot of functions, which is not what is supposed to do.

The best way to do it, in my opinion, would be to have a BoJack::Address class, that receives the input and return hostname and port. The server receives the address object instead of 2 strings.

@mauricioabreu
Copy link
Collaborator Author

@marceloboeira I was not thinking in adding this code to the server. Just like you said an Address object could handle it. We just use the address to create the socket and logging. Not sure if we actually use the hostname and port for specific cases.

Anyways, I am kinda lost with this PR. Commander needs a default value for every argument. This way I can not check if the user is trying to connect via TCP/IP or UnixSocket.

@mauricioabreu
Copy link
Collaborator Author

I am trying to solve this issue without this refactor (I am not sure if we need to have this refactor).
Reading the redis CLI it uses hostname and port (-h and -p)

@mauricioabreu
Copy link
Collaborator Author

Well, one idea is to have a default "empty" for the Unix socket since it is not the default way to run BoJack.

@marceloboeira
Copy link
Owner

Basically, what we need is to decide the default interface: Unix/TCP.

My opinion, TCP should be the default, then we could have a flag: "--unix", "--use-unix-socket", if the flag is true then hostname as port are ignored.

What do you think? less effort and it is backwards compatible.

@mauricioabreu
Copy link
Collaborator Author

@marceloboeira I agree that TCP should be default.
The problem here is that other parts of the codebase rely on "hostname/port" like BoJack::Logger.build

@marceloboeira
Copy link
Owner

@mauricioabreu hmm, maybe it is not relevant at all to have the hostname and port in the log after all.

@mauricioabreu
Copy link
Collaborator Author

@marceloboeira For developers/teams who watch logs and take actions on behalf of them it is useful.
Does it make sense?

@marceloboeira
Copy link
Owner

@mauricioabreu in order to make it simple, create a logger initializer that initializes with the socket path, for another formatter, so a formatter for TCP and another for UnixSocket.

@mauricioabreu mauricioabreu force-pushed the unix-socket-support branch 4 times, most recently from 4fa58a6 to c09da36 Compare September 4, 2016 02:34
@mauricioabreu
Copy link
Collaborator Author

Bad rebase here.

@mauricioabreu mauricioabreu force-pushed the unix-socket-support branch 2 times, most recently from 2a24993 to b394c95 Compare September 4, 2016 14:20
@marceloboeira
Copy link
Owner

screen shot 2016-09-07 at 14 22 20

Look how Postgres approach the CLI options.

@mauricioabreu
Copy link
Collaborator Author

Thanks for sharing @marceloboeira
redis-cli does it by having a unix-socket-file argument.

I am still trying to solve the code which passes the right socket ahead (UNIXServer or TCPServer). After solving this problem I will get back to the CLI.

@marceloboeira
Copy link
Owner

@mauricioabreu yes, I think the unix-socket-file it is better. I just found interesting the way PGSQL does and wanted to document it here.

@mauricioabreu
Copy link
Collaborator Author

@marceloboeira thank you! It is good too see how others are handling this problem.

@mauricioabreu
Copy link
Collaborator Author

It looks like I am bad at overloading stuff. 😭

@mauricioabreu
Copy link
Collaborator Author

Sorry :( bad memory here

@marceloboeira
Copy link
Owner

@mauricioabreu no worries, I am actually testing something with the webhooks, that's why I closed and reopened
ahha

@mauricioabreu
Copy link
Collaborator Author

@marceloboeira haha :P I am studying crystal again. Maybe it is time to get back to this pull request

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

Successfully merging this pull request may close these issues.

2 participants