Merge pull request #589 from stevvooe/content-service-client

services/content: move service client into package
This commit is contained in:
Derek McGowan 2017-03-01 11:28:01 -08:00 committed by GitHub
commit a185a69f46
10 changed files with 136 additions and 102 deletions

View file

@ -2,6 +2,7 @@ package content
import (
"io"
"sync"
"github.com/Sirupsen/logrus"
"github.com/docker/containerd"
@ -20,6 +21,12 @@ type Service struct {
store *content.Store
}
var bufPool = sync.Pool{
New: func() interface{} {
return make([]byte, 1<<20)
},
}
var _ api.ContentServer = &Service{}
func init() {
@ -100,9 +107,9 @@ func (s *Service) Read(req *api.ReadRequest, session api.Content_ReadServer) err
// TODO(stevvooe): Using the global buffer pool. At 32KB, it is probably
// little inefficient for work over a fast network. We can tune this later.
p = content.BufPool.Get().([]byte)
p = bufPool.Get().([]byte)
)
defer content.BufPool.Put(p)
defer bufPool.Put(p)
if offset < 0 {
offset = 0