• This repository has been archived on 22/Jul/2018
  • Stars
    star
    1,331
  • Rank 35,309 (Top 0.7 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Connection pool for Go's net.Conn interface

Archived project. No maintenance.

This project is not maintained anymore and is archived. Feel free to fork and use make your own changes if needed.

Thanks all for their work on this project.

Pool GoDoc Build Status

Pool is a thread safe connection pool for net.Conn interface. It can be used to manage and reuse connections.

Install and Usage

Install the package with:

go get github.com/fatih/pool

Please vendor the package with one of the releases: https://github.com/fatih/pool/releases. master branch is development branch and will contain always the latest changes.

Example

// create a factory() to be used with channel based pool
factory    := func() (net.Conn, error) { return net.Dial("tcp", "127.0.0.1:4000") }

// create a new channel based pool with an initial capacity of 5 and maximum
// capacity of 30. The factory will create 5 initial connections and put it
// into the pool.
p, err := pool.NewChannelPool(5, 30, factory)

// now you can get a connection from the pool, if there is no connection
// available it will create a new one via the factory function.
conn, err := p.Get()

// do something with conn 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).
conn.Close()

// close the underlying connection instead of returning it to pool
// it is useful when acceptor has already closed connection and conn.Write() returns error
if pc, ok := conn.(*pool.PoolConn); ok {
  pc.MarkUnusable()
  pc.Close()
}

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

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

Credits

License

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

More Repositories

1

vim-go

Go development plugin for Vim
Vim Script
15,577
star
2

color

Color package for Go (golang)
Go
6,536
star
3

structs

Utilities for Go structs
Go
3,811
star
4

vim-go-tutorial

Tutorial for vim-go
Vim Script
2,122
star
5

gomodifytags

Go tool to modify struct field tags
Go
1,995
star
6

subvim

Vim customized to be like SublimeText
C++
1,122
star
7

dotfiles

My personal dotfiles
Lua
792
star
8

set

Set data structure for Go
Go
657
star
9

structtag

Parse and modify Go struct field tags
Go
568
star
10

errwrap

Go tool to wrap and fix errors with the new %w verb directive
Go
366
star
11

semgroup

Like errgroup/waitgroup, but only runs a maximum of tasks at any time.
Go
280
star
12

faillint

Report unwanted import path and declaration usages
Go
229
star
13

hclfmt

Format and prettify HCL files
Go
227
star
14

motion

Navigation and insight in Go
Go
180
star
15

astrewrite

Go tool to walk & rewrite AST
Go
166
star
16

camelcase

Split a camelcase word into a slice of words in Go
Go
158
star
17

starhook

Manage & Analyze repositories at scale
Go
93
star
18

vim-hclfmt

Vim plugin for hclfmt
Vim Script
73
star
19

stopwatch

Stopwatch functionality for Go
Go
69
star
20

images

Images is a tool for managing machine images from multiple providers
Go
68
star
21

addlint

An example linter written with go/analysis for tutorial purposes
Go
53
star
22

gb-example

Example gb project with dependencies and CI integration
Go
47
star
23

hcl

HCL Parser and Printer in Go
Go
44
star
24

templatectl

Simple templating CLI
Go
42
star
25

twirpdemo

An example repository of using the Twirp RPC framework with Go
Go
32
star
26

talks

My personal talk slides
Go
24
star
27

unexport

Unexport notused exported identifiers in Go
Go
22
star
28

kodla-talk-2022

Code and slides for Kodla 2022
Go
20
star
29

flags

Flag parsing in Go
Go
18
star
30

vim-nginx

Nginx runtime files for Vim
Vim Script
17
star
31

dvb-t2

Software implementation of DVB-T2
Objective-C
16
star
32

sicp

My personal notes, solutions, thoughts, etc.. about SICP
16
star
33

amqp-examples

Examples to show basic amqp commands in different languages
Go
15
star
34

testmod

Testing Go modules
AMPL
11
star
35

RailsDashboard.kdapp

An easy way to learn, test and deploy Rails
CoffeeScript
7
star
36

cafetiere

An iOS app to make beautiful Coffee
Objective-C
6
star
37

koding-wiki

Koding framework docs to build KD Apps
6
star
38

blog.arsln.org-backup

Fatih Arslan's Personal Blog
CSS
4
star
39

docker-ubuntu-go

Docker image for Go and Ubuntu
Shell
4
star
40

sinerji

A gui written in PyQt4 that uses Avahi as backend for Synergy
Python
1
star
41

snippets

Snippets, code examples, etc..
C
1
star
42

pisi-vim

A vim plugin for pisi packaging
Vim Script
1
star