netpool

package module
v0.0.0-...-09376b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2014 License: MIT Imports: 3 Imported by: 0

README

netpool

Build Status GoDoc

Connection Pool

Install

go get github.com/tristanwietsma/netpool

Usage

Create a connection pool
p, err := netpool.NewConnectionPool("<type>", "<server ip address>", <pool size>)
Get a connection from the pool
c, err := p.Connect()
Use a connection

Connections implement Write and Read.

err := c.Write([]byte("ping"))
msg, err := c.Read()
Return a connection to the pool
p.Release(c)

Testing

Build and start the echoServer, then go test as normal.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	IsClosed bool
	// contains filtered or unexported fields
}

func NewConnection

func NewConnection(network, address string) (*Connection, error)

Returns a connection to `address`.

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Read

func (c *Connection) Read() ([]byte, error)

func (*Connection) Write

func (c *Connection) Write(msg []byte) error

type ConnectionPool

type ConnectionPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConnectionPool

func NewConnectionPool(network, address string, size uint) (*ConnectionPool, error)

func (*ConnectionPool) Connect

func (p *ConnectionPool) Connect() (*Connection, error)

func (*ConnectionPool) Release

func (p *ConnectionPool) Release(c *Connection)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL