Further drafting of rpc module.

Also: fix typo in model definitions.
This commit is contained in:
Christian Schwarz
2017-04-15 18:31:14 +02:00
parent 32f07c51c7
commit c1aed10e8b
3 changed files with 183 additions and 47 deletions
+56 -9
View File
@@ -1,29 +1,76 @@
package protocol
package rpc
type RequestId uint8
type Request struct {
RequestType RequestType
RequestId [16]byte // UUID
import "io"
type RequestId [16]byte
type RequestType uint8
const (
RTProtocolVersionRequest RequestType = 1
RTFilesystemRequest = 16
RTInitialTransferRequest = 17
)
type RequestHeader struct {
Type RequestType
Id [16]byte // UUID
}
type FilesystemRequest struct {
Request
Roots []string
}
type InitialTransferRequest struct {
Request
Snapshot string // tank/my/db@ljlsdjflksdf
}
func (r InitialTransferRequest) Respond(snapshotReader io.Reader) {
}
type IncrementalTransferRequest struct {
Request
FromSnapshot string
ToSnapshot string
ToSnapshot string
}
func (r IncrementalTransferRequest) Respond(snapshotReader io.Reader) {
}
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 (
ROK ResponseType = 0
)
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{}
}