Rename throttle package to limiter

pull/7024/head
Jason Wilder 2016-07-18 12:00:58 -06:00
parent c2370b437b
commit b692ef4f48
3 changed files with 14 additions and 13 deletions

View File

@ -1,11 +1,11 @@
package throttle
package limiter
// Fixed is a simple channel based concurrency limiter. It uses a fixed
// size channel to limit callers from proceeding until there is a value avalable
// in the channel. If all are in-use, the caller blocks until one is freed.
type Fixed chan struct{}
func New(limit int) Fixed {
func NewFixed(limit int) Fixed {
return make(Fixed, limit)
}

View File

@ -18,7 +18,7 @@ import (
"github.com/golang/snappy"
"github.com/influxdata/influxdb/models"
"github.com/influxdata/influxdb/pkg/throttle"
"github.com/influxdata/influxdb/pkg/limiter"
)
const (
@ -63,8 +63,9 @@ var (
// Statistics gathered by the WAL.
const (
statWALOldBytes = "oldSegmentsDiskBytes"
statWALCurrentBytes = "currentSegmentDiskBytes"
statWALOldBytes = "oldSegmentsDiskBytes"
statWALCurrentBytes = "currentSegmentDiskBytes"
defaultWaitingWALWrites = 10
)
type WAL struct {
@ -91,8 +92,8 @@ type WAL struct {
LoggingEnabled bool
// statistics for the WAL
stats *WALStatistics
throttle throttle.Fixed
stats *WALStatistics
limiter limiter.Fixed
}
func NewWAL(path string) *WAL {
@ -105,7 +106,7 @@ func NewWAL(path string) *WAL {
logger: log.New(os.Stderr, "[tsm1wal] ", log.LstdFlags),
closing: make(chan struct{}),
stats: &WALStatistics{},
throttle: throttle.New(10),
limiter: limiter.NewFixed(defaultWaitingWALWrites),
}
}
@ -283,8 +284,8 @@ func (l *WAL) writeToLog(entry WALEntry) (int, error) {
// limit how many concurrent encodings can be in flight. Since we can only
// write one at a time to disk, a slow disk can cause the allocations below
// to increase quickly. If we're backed up, wait until others have completed.
l.throttle.Take()
defer l.throttle.Release()
l.limiter.Take()
defer l.limiter.Release()
// encode and compress the entry while we're not locked
bytes := getBuf(walEncodeBufSize)

View File

@ -16,7 +16,7 @@ import (
"github.com/influxdata/influxdb/influxql"
"github.com/influxdata/influxdb/models"
"github.com/influxdata/influxdb/pkg/throttle"
"github.com/influxdata/influxdb/pkg/limiter"
)
var (
@ -146,7 +146,7 @@ func (s *Store) loadShards() error {
err error
}
t := throttle.New(runtime.GOMAXPROCS(0))
t := limiter.NewFixed(runtime.GOMAXPROCS(0))
resC := make(chan *res)
var n int
@ -515,7 +515,7 @@ func (s *Store) walkShards(shards []*Shard, fn func(sh *Shard) error) error {
err error
}
t := throttle.New(runtime.GOMAXPROCS(0))
t := limiter.NewFixed(runtime.GOMAXPROCS(0))
resC := make(chan res)
var n int