Add PutMany, currently only for bbolt and hashmap storage backends

This commit is contained in:
Daniel 2020-04-09 14:22:22 +02:00
parent 35ab2be6a0
commit e0f96d5188
10 changed files with 246 additions and 12 deletions

View file

@ -137,6 +137,28 @@ func (c *Controller) Put(r record.Record) (err error) {
return nil
}
// PutMany stores many records in the database.
func (c *Controller) PutMany() (batch chan record.Record, err chan error) {
c.writeLock.RLock()
defer c.writeLock.RUnlock()
if shuttingDown.IsSet() {
batch = make(chan record.Record)
err = make(chan error, 1)
err <- ErrShuttingDown
return
}
if c.ReadOnly() {
batch = make(chan record.Record)
err = make(chan error, 1)
err <- ErrReadOnly
return
}
return c.storage.PutMany()
}
// Query executes the given query on the database.
func (c *Controller) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error) {
c.readLock.RLock()