Imports #
"io"
"time"
"io"
"time"
CmdClose requests that the cache program exit gracefully. The cache program should reply to this request and then exit (thus closing its stdout).
const CmdClose = *ast.CallExpr
CmdGet tells the cache program to retrieve an object from the cache. [Request.ActionID] specifies the key of the object to get. If the cache does not contain this object, it should set [Response.Miss] to true. Otherwise, it should populate the fields of [Response], including setting [Response.OutputID] to the OutputID of the original "put" request and [Response.DiskPath] to the path of a local file containing the Body of the original "put" request. That file must continue to exist at least until a "close" request.
const CmdGet = *ast.CallExpr
CmdPut tells the cache program to store an object in the cache. [Request.ActionID] is the cache key of this object. The cache should store [Request.OutputID] and [Request.Body] under this key for a later "get" request. It must also store the Body in a file in the local file system and return the path to that file in [Response.DiskPath], which must exist at least until a "close" request.
const CmdPut = *ast.CallExpr
Cmd is a command that can be issued to a child process. If the interface needs to grow, the go command can add new commands or new versioned commands like "get2" in the future. The initial [Response] from the child process indicates which commands it supports.
type Cmd string
Request is the JSON-encoded message that's sent from the go command to the GOCACHEPROG child process over stdin. Each JSON object is on its own line. A ProgRequest of Type "put" with BodySize > 0 will be followed by a line containing a base64-encoded JSON string literal of the body.
type Request struct {
ID int64
Command Cmd
ActionID []byte `json:",omitempty"`
OutputID []byte `json:",omitempty"`
Body io.Reader `json:"-"`
BodySize int64 `json:",omitempty"`
ObjectID []byte `json:",omitempty"`
}
Response is the JSON response from the child process to the go command. With the exception of the first protocol message that the child writes to its stdout with ID==0 and KnownCommands populated, these are only sent in response to a Request from the go command. Responses can be sent in any order. The ID must match the request they're replying to.
type Response struct {
ID int64
Err string `json:",omitempty"`
KnownCommands []Cmd `json:",omitempty"`
Miss bool `json:",omitempty"`
OutputID []byte `json:",omitempty"`
Size int64 `json:",omitempty"`
Time *time.Time `json:",omitempty"`
DiskPath string `json:",omitempty"`
}
Generated with Arrow