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 connect over Unix socket? #16

Open
HugoDelval opened this issue Dec 19, 2017 · 2 comments
Open

Ability to connect over Unix socket? #16

HugoDelval opened this issue Dec 19, 2017 · 2 comments

Comments

@HugoDelval
Copy link

HugoDelval commented Dec 19, 2017

Really useful but.. do you support unix socket? If not, would you accept a PR?

Thanks a lot! Awesome work

@arp242
Copy link

arp242 commented Dec 19, 2017

Thanks!

Do you support unix socket

Maybe? I never tried it. The New() function is func New(addr string, d Dialer), where Dialer is:

type Dialer interface {
    DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

This may already work if you write a thin wrapper around net.UnixConn or something.

It could (and should) definitely be more straightforward than that though!

would you accept a PR?

Sure; the only reason it's not supported is because I don't need/use it.

@arp242 arp242 changed the title Really useful but.. Ability to connect over Unix socket? Dec 19, 2017
@HugoDelval
Copy link
Author

I think it won't work because of this line -> https://github.com/Teamwork/spamc/blob/master/spamc.go#L163

The only solution I see would be to add a third parameter to the New() function, something like:

func New(addr string, d Dialer, p string) {
    ...
    return &Client{
		addr:   addr,
		dialer: d,
                proto: p,
    }
}

and then instead of https://github.com/Teamwork/spamc/blob/master/spamc.go#L163 :

conn, err := c.dialer.DialContext(ctx, c.proto, c.addr)

Would it be ok? (I'll update the tests too)

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

No branches or pull requests

2 participants