Pool for accessing NATS
Altenrion opened this issue · 1 comments
Altenrion commented
Is it possible to use this pool with NATS MQ system ?
Nats protocol itself uses tcp/ip inside but for connection it takes url nats://0.0.0.0:4222
.
I tried many variations before posting this issue, but most reasonably close to the working one must be this :
natsFactory := func() (net.Conn, error) { return net.Dial("tcp", "nats://0.0.0.0:4222") }
natsPool, err := pool.NewChannelPool(3, 10, natsFactory)
if err != nil {
logrus.Printf("Nats error: %s",err)
}
But it returns error:
INFO[0000] Nats error: factory is not able to fill the pool: dial tcp: address nats://0.0.0.0:4222: too many colons in address
I tried to figure out what might be misconfigured, and tried even setting nats
as protocol itself, but your pool lib don't know nats protocol. A part from you code :
// Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only),
// "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4"
// (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and
// "unixpacket".
So what you can recommend in this case?
fatih commented
Hi @Altenrion
This package supports only net.Conn. You could write your own wrapper that implements net.Conn
and not use net.Dial()
. Thanks