pool.go 798 B

12345678910111213141516171819202122232425
  1. // Package pool implements a pool of net.Conn interfaces to manage and reuse them.
  2. package nsqclient
  3. import "errors"
  4. var (
  5. // ErrClosed is the error resulting if the pool is closed via pool.Close().
  6. ErrClosed = errors.New("pool is closed")
  7. )
  8. // Pool interface describes a pool implementation. A pool should have maximum
  9. // capacity. An ideal pool is threadsafe and easy to use.
  10. type Pool interface {
  11. // Get returns a new connection from the pool. Closing the connections puts
  12. // it back to the Pool. Closing it when the pool is destroyed or full will
  13. // be counted as an error.
  14. Get() (*PoolConn, error)
  15. // Close closes the pool and all its connections. After Close() the pool is
  16. // no longer usable.
  17. Close()
  18. // Len returns the current number of connections of the pool.
  19. Len() int
  20. }