-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
add support for unix socket binding service #7130
Conversation
@oiooj, thanks for your PR! By analyzing the annotation information on this pull request, we identified @gunnaraasen and @e-dard to be potential reviewers |
// SetLogOutput sets the writer to which all logs are written. It must not be | ||
// called after Open is called. | ||
func (s *Service) SetLogOutput(w io.Writer) { | ||
s.Logger = log.New(w, "[unixsocket] ", log.LstdFlags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: while I know other services have used this pattern, it should really be s.Logger.SetOutput(w)
😄
Also as it stands we would need to protect access to s.Logger
, but we can avoid that with SetOutput
@oiooj thanks for this PR, it looks great. It will need some input from some other core team members. I'm not sure why the |
@e-dard updated, and all checks have passed. It's strange. |
I don't think this resolves the issue from #7075. As I understood that, they wanted to be able to use the entire HTTP service using a unix socket so it would basically expose that service. I like this method of configuration better, but I think it would be good to mimic the http service rather than only the write protocol. That way, someone can communicate using HTTP over the unix socket similar to how Docker works. I think it would be possible by just opening a unix socket listener and then passing it to the same handler we use for httpd. See the httpd service for an example. |
@jsternberg I don't think so, |
Not true. A unix domain socket can be either SOCK_STREAM, or SOCK_DGRAM. SOCK_STREAM is what TCP uses. SOCK_DGRAM is what UDP uses. |
Unix sockets act more similar to TCP than UDP. I'm sure @phemmer is right though and unix sockets can also be opened as a datagram socket, but that's not the only way of using it. The reason why I'm saying using the HTTP handler would be more efficient is because it gives more freedom to be able to specify which database and which retention policy you want to write to while also making the query endpoint available. So you would just have to configure it once rather than configure it once per database/retention policy (with having no ability to query points). I personally think this functionality should just be implemented within the HTTP service itself. In this section of the code, you would just have to open a |
@oiooj I'm a bit confused. What do you mean by unix sockets being similar to udp service? That would be a design decision rather than a technology decision. Unix sockets can be opened as a stream socket and can support HTTP. UDP cannot support HTTP. HTTP requires a bidirectional stream which the UDP protocol can't support. It's OK for UDP to have its current limitations because UDP doesn't have the capability of doing something more complicated. It's possible to do more with unix sockets and #7075 doesn't seem to be focused only on writes. |
@jsternberg sorry, I'm confused. lol |
No problem. That's why we do these code reviews. 😄 |
Don't forget to tell me the final decision,I will fix this if I'm free |
I think we're going to go with building the unix socket binding into the httpd service. If you can update your PR to do that instead, that would be very helpful. |
check #7135 and close this PR |
Feature Request in #7075 and #4877. I tested the code, just like the UDP service.
start
write points example code:
query via influx
shutdown