Skip to content

Commit

Permalink
Documented options
Browse files Browse the repository at this point in the history
  • Loading branch information
dim committed Jan 31, 2015
1 parent f05782e commit a6385cc
Showing 3 changed files with 59 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pool.go
Original file line number Diff line number Diff line change
@@ -251,13 +251,13 @@ func (p *connPool) Close() (err error) {

for {
if p.Size() < 1 {
return
break
}
if e := p.remove(<-p.conns); e != nil {
err = e
}
}
panic("not reached")
return
}

//------------------------------------------------------------------------------
34 changes: 28 additions & 6 deletions redis.go
Original file line number Diff line number Diff line change
@@ -153,22 +153,44 @@ type options struct {
}

type Options struct {
// The network type, either "tcp" or "unix".
// Default: "tcp"
Network string
Addr string
// The network address.
Addr string

// Dialer creates new network connection and has priority over
// Network and Addr options.
Dialer func() (net.Conn, error)

// An optional password. Must match the password specified in the
// `requirepass` server configuration option.
Password string
DB int64

DialTimeout time.Duration
ReadTimeout time.Duration
// Select a database.
// Default: 0
DB int64

// Sets the deadline for establishing new connections. If reached,
// deal attepts will fail with a timeout.
DialTimeout time.Duration
// Sets the deadline for socket reads. If reached, commands will
// fail with a timeout instead of blocking.
ReadTimeout time.Duration
// Sets the deadline for socket writes. If reached, commands will
// fail with a timeout instead of blocking.
WriteTimeout time.Duration

PoolSize int
// The maximum number of socket connections.
// Default: 10
PoolSize int
// If all socket connections is the pool are busy, the pool will wait
// this amount of time for a conection to become available, before
// returning an error.
// Default: 5s
PoolTimeout time.Duration
// Evict connections from the pool after they have been idle for longer
// than specified in this option.
// Default: 0 = no eviction
IdleTimeout time.Duration
}

37 changes: 29 additions & 8 deletions sentinel.go
Original file line number Diff line number Diff line change
@@ -12,19 +12,40 @@ import (
//------------------------------------------------------------------------------

type FailoverOptions struct {
MasterName string
// The master name.
MasterName string
// Seed addresses of sentinel nodes.
SentinelAddrs []string

// An optional password. Must match the password specified in the
// `requirepass` server configuration option.
Password string
DB int64
// Select a database.
// Default: 0
DB int64

// Sets the deadline for establishing new connections. If reached,
// deal attepts will fail with a timeout.
DialTimeout time.Duration
// Sets the deadline for socket reads. If reached, commands will
// fail with a timeout instead of blocking.
ReadTimeout time.Duration
// Sets the deadline for socket writes. If reached, commands will
// fail with a timeout instead of blocking.
WriteTimeout time.Duration

// The maximum number of socket connections.
// Default: 10
PoolSize int

DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
PoolTimeout time.Duration
IdleTimeout time.Duration
// If all socket connections is the pool are busy, the pool will wait
// this amount of time for a conection to become available, before
// returning an error.
// Default: 5s
PoolTimeout time.Duration
// Evict connections from the pool after they have been idle for longer
// than specified in this option.
// Default: 0 = no eviction
IdleTimeout time.Duration
}

func (opt *FailoverOptions) getPoolSize() int {

0 comments on commit a6385cc

Please sign in to comment.