2017-04-15 18:31:14 +02:00
|
|
|
package rpc
|
2017-04-14 19:26:32 +02:00
|
|
|
|
2017-04-15 18:31:14 +02:00
|
|
|
import "io"
|
2017-05-03 17:12:15 +02:00
|
|
|
import "github.com/zrepl/zrepl/zfs"
|
2017-04-15 18:31:14 +02:00
|
|
|
|
|
|
|
type RequestId [16]byte
|
|
|
|
type RequestType uint8
|
|
|
|
|
|
|
|
const (
|
2017-04-26 20:25:53 +02:00
|
|
|
RTProtocolVersionRequest RequestType = 1
|
|
|
|
RTFilesystemRequest = 16
|
|
|
|
RTInitialTransferRequest = 17
|
|
|
|
RTIncrementalTransferRequest = 18
|
2017-05-03 17:12:15 +02:00
|
|
|
RTFilesystemVersionsRequest = 19
|
2017-04-15 18:31:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type RequestHeader struct {
|
|
|
|
Type RequestType
|
|
|
|
Id [16]byte // UUID
|
2017-04-14 19:26:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type FilesystemRequest struct {
|
|
|
|
Roots []string
|
|
|
|
}
|
|
|
|
|
2017-05-03 17:12:15 +02:00
|
|
|
type FilesystemVersionsRequest struct {
|
|
|
|
Filesystem zfs.DatasetPath
|
|
|
|
}
|
|
|
|
|
2017-04-14 19:26:32 +02:00
|
|
|
type InitialTransferRequest struct {
|
|
|
|
Snapshot string // tank/my/db@ljlsdjflksdf
|
|
|
|
}
|
2017-04-15 18:31:14 +02:00
|
|
|
|
2017-04-14 19:26:32 +02:00
|
|
|
func (r InitialTransferRequest) Respond(snapshotReader io.Reader) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
type IncrementalTransferRequest struct {
|
|
|
|
FromSnapshot string
|
2017-04-15 18:31:14 +02:00
|
|
|
ToSnapshot string
|
2017-04-14 19:26:32 +02:00
|
|
|
}
|
2017-04-15 18:31:14 +02:00
|
|
|
|
2017-04-14 19:26:32 +02:00
|
|
|
func (r IncrementalTransferRequest) Respond(snapshotReader io.Reader) {
|
|
|
|
|
|
|
|
}
|
2017-04-15 18:31:14 +02:00
|
|
|
|
|
|
|
type ByteStreamRPCProtocolVersionRequest struct {
|
|
|
|
ClientVersion uint8
|
|
|
|
}
|
|
|
|
|
|
|
|
type ErrorId uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
ENoError ErrorId = 0
|
|
|
|
EDecodeHeader = 1
|
|
|
|
EUnknownRequestType = 2
|
|
|
|
EDecodeRequestBody = 3
|
|
|
|
EProtocolVersionMismatch = 4
|
|
|
|
EHandler = 5
|
|
|
|
)
|
|
|
|
|
|
|
|
type ResponseType uint8
|
|
|
|
|
|
|
|
const (
|
2017-04-30 17:58:39 +02:00
|
|
|
RNONE ResponseType = 0
|
|
|
|
ROK = 1
|
2017-04-26 20:25:53 +02:00
|
|
|
RFilesystems = 2
|
|
|
|
RChunkedStream = 3
|
2017-05-03 17:12:15 +02:00
|
|
|
RFilesystemDiff = 4
|
2017-04-15 18:31:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type ResponseHeader struct {
|
|
|
|
RequestId RequestId
|
|
|
|
ErrorId ErrorId
|
|
|
|
Message string
|
|
|
|
ResponseType ResponseType
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewByteStreamRPCProtocolVersionRequest() ByteStreamRPCProtocolVersionRequest {
|
|
|
|
return ByteStreamRPCProtocolVersionRequest{
|
|
|
|
ClientVersion: ByteStreamRPCProtocolVersion,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func newUUID() [16]byte {
|
|
|
|
return [16]byte{}
|
|
|
|
}
|