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

Ability to use unix socket for connection to nsqd #1

Merged
merged 3 commits into from
Dec 28, 2022
Merged

Conversation

telepenin
Copy link
Member

@telepenin telepenin commented Dec 23, 2022

Example to use reader:

	consumer, _ := nsq.NewConsumer(stream, group, nsq.NewConfig())
	if err = consumer.ConnectToNSQD("/var/run/nsqd.sock"); err != nil {
		logger.Error("failed to connect to nsqd: ", err)
		return
	}

and writer:

	nsq.NewProducer("/var/run/nsqd.sock", cfg)

with connection to nsqd via unix sockets.

conn.go Outdated

// create a local copy of the config to set ServerName for this connection
conf := &tls.Config{}
if tlsConf != nil {
conf = tlsConf.Clone()
}
conf.ServerName = host
if c.socketType == "tcp" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

You did !unixSocket in another place. Maybe it would be better for consistency to do the same here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

also, I don't think we will ever get in here (inside upgradeTLS) for unixSocket. How / why would we?

Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping backward compatibility with TLS and no need to specify conflicting options explicitly

Copy link
Collaborator

@iseletsk iseletsk left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@moredure moredure self-requested a review December 27, 2022 21:27
conn.go Outdated
@@ -90,8 +93,13 @@ func NewConn(addr string, config *Config, delegate ConnDelegate) *Conn {
if !config.initialized {
panic("Config must be created with NewConfig()")
}
socketType := "tcp"
Copy link

@moredure moredure Dec 27, 2022

Choose a reason for hiding this comment

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

Probably, it's better to organise this part as method func (*Conn) socketType() string instead of procedure isSocket since it won't be called too frequently it should not affect performance, but in general LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, thank you!

@telepenin telepenin merged commit 12284d6 into cl Dec 28, 2022
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.

3 participants