Adds storage driver interface, tests, and two basic implementations
This commit is contained in:
parent
12e68998e1
commit
3f95694180
12 changed files with 1320 additions and 0 deletions
83
storagedriver/ipc/ipc.go
Normal file
83
storagedriver/ipc/ipc.go
Normal file
|
@ -0,0 +1,83 @@
|
|||
package ipc
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
|
||||
"github.com/docker/libchan"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Type string
|
||||
Parameters map[string]interface{}
|
||||
ResponseChannel libchan.Sender
|
||||
}
|
||||
|
||||
type noWriteReadWriteCloser struct {
|
||||
io.ReadCloser
|
||||
}
|
||||
|
||||
func (r noWriteReadWriteCloser) Write(p []byte) (n int, err error) {
|
||||
return 0, errors.New("Write unsupported")
|
||||
}
|
||||
|
||||
func WrapReadCloser(readCloser io.ReadCloser) io.ReadWriteCloser {
|
||||
return noWriteReadWriteCloser{readCloser}
|
||||
}
|
||||
|
||||
type responseError struct {
|
||||
Type string
|
||||
Message string
|
||||
}
|
||||
|
||||
func ResponseError(err error) *responseError {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return &responseError{
|
||||
Type: reflect.TypeOf(err).String(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
|
||||
func (err *responseError) Error() string {
|
||||
return fmt.Sprintf("%s: %s", err.Type, err.Message)
|
||||
}
|
||||
|
||||
type GetContentResponse struct {
|
||||
Content []byte
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type PutContentResponse struct {
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type ReadStreamResponse struct {
|
||||
Reader io.ReadWriteCloser
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type WriteStreamResponse struct {
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type ResumeWritePositionResponse struct {
|
||||
Position uint64
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Keys []string
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type MoveResponse struct {
|
||||
Error *responseError
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
Error *responseError
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue