8000 GitHub - hxjiejie/nsqpool
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

hxjiejie/nsqpool

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSQPool

NSQPool is a thread safe connection pool for nsq producer. It can be used to manage and reuse nsq producer connection.

Install and Usage

Install the package with:

github.com/qgymje/nsqpool

Import it with:

import (
    "github.com/qgymje/nsqpool"
    nsq "github.com/nsqio/go-nsq"
)

and use pool as the package name inside the code.

Example

// create a factory() to be used with channel based pool
factory := func() (*nsq.Producer, error) { 
    config := nsq.NewConfig()
    return nsq.NewProducer(":4160", config)
}

nsqPool, err := pool.NewChannelPool(5, 30, factory)

producer, err := nsqPool.Get()

// do something with producer and put it back to the pool by closing the connection
// (this doesn't close the underlying connection instead it's putting it back
// to the pool).
producer.Close()

// close pool any time you want, this closes all the connections inside a pool
nsqPool.Close()

// currently available connections in the pool
current := nsqPool.Len()

License

The MIT License (MIT) - see LICENSE for more details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%
0