package main // CtrlMsg is the single envelope used for every message exchanged between // the manager and a control agent over frameCtrlJSON frames. It is // deliberately denormalized (not one struct per message type) to keep // (de)serialization trivial. type CtrlMsg struct { Type string `json:"type"` // stat request/response Path string `json:"path,omitempty"` Exists bool `json:"exists,omitempty"` IsDevice bool `json:"isDevice,omitempty"` Size int64 `json:"size,omitempty"` // connect_push (-> source agent) / connect_pull (-> dest agent) PeerHost string `json:"peerHost,omitempty"` PeerUser string `json:"peerUser,omitempty"` PeerPort int `json:"peerPort,omitempty"` PeerPath string `json:"peerPath,omitempty"` // PeerLocal is set when both source and dest are local to the manager, // so the driver (itself already a local child of the manager) can spawn // the sink/source-stream helper as a plain local subprocess instead of // over ssh — no loopback SSH access required for same-machine jobs. PeerLocal bool `json:"peerLocal,omitempty"` RemoteBin string `json:"remoteBin,omitempty"` SSHBin string `json:"sshBin,omitempty"` SSHOpts []string `json:"sshOpts,omitempty"` ConnectTimeoutSec int `json:"connectTimeoutSec,omitempty"` BlockSize int64 `json:"blockSize,omitempty"` // failure/error detail Reason string `json:"reason,omitempty"` Message string `json:"message,omitempty"` // progress / block_done_batch Copied int64 `json:"copied,omitempty"` Skipped int64 `json:"skipped,omitempty"` TotalBlocks int64 `json:"totalBlocks,omitempty"` BytesCopied int64 `json:"bytesCopied,omitempty"` Entries []BlockResult `json:"entries,omitempty"` // log Level string `json:"level,omitempty"` } // BlockResult is one confirmed-written block's new hash, reported from a // control agent back to the manager so it can update the job state file. type BlockResult struct { Index uint64 `json:"i"` Hash string `json:"h"` // hex-encoded 32 bytes } const ( msgStat = "stat" msgStatOK = "stat_ok" msgPrepare = "prepare" msgPrepareOK = "prepare_ok" msgConnectPush = "connect_push" msgConnectPull = "connect_pull" msgPushOK = "push_ok" msgPushFailed = "push_failed" msgPullOK = "pull_ok" msgPullFailed = "pull_failed" msgProgress = "progress" msgBlockDoneBatch = "block_done_batch" msgLog = "log" msgError = "error" msgClose = "close" msgBye = "bye" )