2017-04-15 18:31:14 +02:00
|
|
|
package rpc
|
2017-04-14 19:26:32 +02:00
|
|
|
|
2017-08-06 13:04:29 +02:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/zrepl/zrepl/zfs"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ json.Marshaler = &zfs.DatasetPath{}
|
|
|
|
var _ json.Unmarshaler = &zfs.DatasetPath{}
|
2017-04-15 18:31:14 +02:00
|
|
|
|
|
|
|
type RequestId [16]byte
|
|
|
|
type RequestType uint8
|
|
|
|
|
|
|
|
const (
|
2017-05-03 17:13:08 +02:00
|
|
|
RTProtocolVersionRequest RequestType = 0x01
|
|
|
|
RTFilesystemRequest = 0x10
|
|
|
|
RTFilesystemVersionsRequest = 0x11
|
|
|
|
RTInitialTransferRequest = 0x12
|
|
|
|
RTIncrementalTransferRequest = 0x13
|
2017-05-16 16:57:24 +02:00
|
|
|
RTPullMeRequest = 0x20
|
|
|
|
RTCloseRequest = 0xf0
|
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 {
|
2017-05-20 17:34:24 +02:00
|
|
|
Roots []string // may be nil, indicating interest in all filesystems
|
2017-04-14 19:26:32 +02:00
|
|
|
}
|
|
|
|
|
2017-05-03 17:12:15 +02:00
|
|
|
type FilesystemVersionsRequest struct {
|
2017-08-06 13:04:29 +02:00
|
|
|
Filesystem *zfs.DatasetPath
|
2017-05-03 17:12:15 +02:00
|
|
|
}
|
|
|
|
|
2017-04-14 19:26:32 +02:00
|
|
|
type InitialTransferRequest struct {
|
2017-08-06 13:04:29 +02:00
|
|
|
Filesystem *zfs.DatasetPath
|
2017-05-07 12:04:16 +02:00
|
|
|
FilesystemVersion zfs.FilesystemVersion
|
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 InitialTransferRequest) Respond(snapshotReader io.Reader) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
type IncrementalTransferRequest struct {
|
2017-08-06 13:04:29 +02:00
|
|
|
Filesystem *zfs.DatasetPath
|
2017-05-07 12:04:16 +02:00
|
|
|
From zfs.FilesystemVersion
|
|
|
|
To zfs.FilesystemVersion
|
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
|
|
|
|
}
|
|
|
|
|
2017-05-20 17:08:18 +02:00
|
|
|
const LOCAL_TRANSPORT_IDENTITY string = "local"
|
|
|
|
|
|
|
|
const DEFAULT_INITIAL_REPL_POLICY = InitialReplPolicyMostRecent
|
|
|
|
|
|
|
|
type InitialReplPolicy string
|
|
|
|
|
|
|
|
const (
|
|
|
|
InitialReplPolicyMostRecent InitialReplPolicy = "most_recent"
|
|
|
|
InitialReplPolicyAll InitialReplPolicy = "all"
|
|
|
|
)
|
|
|
|
|
2017-05-16 16:57:24 +02:00
|
|
|
type PullMeRequest struct {
|
|
|
|
// if true, the other fields are undefined
|
|
|
|
Finished bool
|
|
|
|
InitialReplPolicy InitialReplPolicy
|
|
|
|
}
|
|
|
|
|
2017-05-14 12:28:19 +02:00
|
|
|
type CloseRequest struct {
|
|
|
|
Goodbye string
|
|
|
|
}
|
|
|
|
|
2017-04-15 18:31:14 +02:00
|
|
|
type ErrorId uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
ENoError ErrorId = 0
|
|
|
|
EDecodeHeader = 1
|
|
|
|
EUnknownRequestType = 2
|
|
|
|
EDecodeRequestBody = 3
|
|
|
|
EProtocolVersionMismatch = 4
|
|
|
|
EHandler = 5
|
|
|
|
)
|
|
|
|
|
|
|
|
type ResponseType uint8
|
|
|
|
|
|
|
|
const (
|
2017-05-03 17:13:08 +02:00
|
|
|
RNONE ResponseType = 0x0
|
|
|
|
ROK = 0x1
|
|
|
|
RFilesystems = 0x10
|
|
|
|
RFilesystemDiff = 0x11
|
|
|
|
RChunkedStream = 0x20
|
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{}
|
|
|
|
}
|