Documentation
¶
Overview ¶
Package sessiondir lets short commands reach a running pedit session on the same machine: a session registers a directory of its own under the user's configuration, and a command leaves a request there and waits for the answer (docs/design/comments-cli.md). Nothing in it names a path on disk or holds a key.
Index ¶
Constants ¶
const ( OpList = "list" OpReply = "reply" OpResolve = "resolve" OpReopen = "reopen" )
The ops of a Request.
const MaxRequestBytes = 64 << 10
MaxRequestBytes bounds a request: a comment is at most 4,000 UTF-16 code units, which JSON writes in less.
const Version = 1
Version is the version of the files this package writes and reads.
Variables ¶
var ( // ErrWithdrawn means the session did not take the request in time, and // it was withdrawn: nothing was done. ErrWithdrawn = errors.New("the session did not answer; nothing was done") // ErrUnknown means the session took the request but did not answer in // time: what it did is not known. ErrUnknown = errors.New("the session took the request but did not answer in time") // ErrGone means the session ended before the request was left for it: // nothing was done. ErrGone = errors.New("the session ended") )
Errors of Call.
Functions ¶
Types ¶
type Answer ¶
type Answer struct {
Version int `json:"version"`
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
Delivered *bool `json:"delivered,omitempty"`
Threads []Thread `json:"threads,omitempty"`
}
Answer is a session's answer to a Request.
type Dir ¶
type Dir struct {
ID string
// contains filtered or unexported fields
}
Dir is the directory of a running session.
func Register ¶
Register makes the directory of a session under base, private to the user, takes its lock and writes info.
func (*Dir) Close ¶
func (d *Dir) Close()
Close stops serving, waits for the requests under way, and removes the directory.
type Info ¶
type Info struct {
Version int `json:"version"`
PID int `json:"pid"`
Room string `json:"room"`
Access string `json:"access"`
Project string `json:"project,omitempty"`
Name string `json:"name"`
Files []string `json:"files"`
}
Info is what a session tells about itself, in session.json.
type Live ¶
Live is a session found running.
type Message ¶
type Message struct {
ID string `json:"id"`
Author string `json:"author"`
Time string `json:"time"`
Body string `json:"body"`
}
Message is one comment of a Thread.