Documentation
¶
Overview ¶
Package chatwork keeps the work of the machine's chats: which git worktrees a chat changed or committed to, on which branch, from which commit, with which commits and merge request (hubproto.ChatWorkEntry). The runtime registers the work as the chat runs (Observer) or, for a chat older than the registry, from its transcript (Scan); the records are kept in one file under the runtime's data folder and handed to the hub over the replica socket.
Index ¶
- func RemoteProject(remote string) (host, project string)
- func Subtree(root string, chats []Chat) []string
- type Chat
- type Entry
- type Observer
- type Registry
- func (r *Registry) All() []Entry
- func (r *Registry) MarkScanned(conv string)
- func (r *Registry) Of(convs ...string) []Entry
- func (r *Registry) Put(e Entry) bool
- func (r *Registry) Scanned(conv string) bool
- func (r *Registry) Watch(fn func([]Entry)) (stop func())
- func (r *Registry) WatchWork(fn func(frame []byte)) (stop func())
- func (r *Registry) WorkFrames() [][]byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoteProject ¶
RemoteProject is the host and project path of a remote: gitlab.example.com, group/project.
Types ¶
type Chat ¶
type Chat struct {
ID string
Parent string
Cwd string
CreatedAt int64 // epoch ms
Transcript string
}
Chat is what the observer needs to know of a chat.
type Observer ¶
type Observer struct {
Reg *Registry
Chat func(id string) (Chat, bool)
Home string
Now func() time.Time
// contains filtered or unexported fields
}
Observer registers the work of the chats as their feeds go: a file a tool wrote registers its worktree at once; a folder a shell command named, when the command changed git (a commit, a new worktree or branch, a push…); and when a turn ends every worktree of the chat is looked at again, together with the chat's own folder if the chat committed there. All of it runs on one goroutine off a bounded queue: the feed never waits for git.
func NewObserver ¶
NewObserver makes an observer; Run starts it.
func (*Observer) Frame ¶
Frame takes a frame of the runtime's hub (wire.Hub.Tap): the tool steps and the ends of turns of the chats. It is called under the hub's lock, so it only looks for the words of such a frame and queues it; the frame is read on the observer's goroutine.
func (*Observer) Run ¶
func (o *Observer) Run(done <-chan struct{})
Run handles the queue until done closes.
func (*Observer) Scan ¶
Scan looks through a chat's transcript once (see scan.go) and waits until it is done or the time is out; false when it did not finish in time (it goes on in the background).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the machine's records. Its methods are safe for concurrent use.
func Open ¶
Open reads the registry kept at path ("" keeps nothing on disk). A file that does not read starts an empty registry.
func (*Registry) MarkScanned ¶
MarkScanned remembers that a chat's transcript was looked through.
func (*Registry) Put ¶
Put records e (merged into the record of the same chat and worktree) and reports whether anything changed. The first touch, the base and the merge request are kept from the older record when e has none; a live record is not turned into a scanned one.
func (*Registry) Watch ¶
Watch calls fn with every record that changes from now on, outside the registry's lock. stop ends it.
func (*Registry) WatchWork ¶
WatchWork calls fn with a replica frame of every record that changes from now on.
func (*Registry) WorkFrames ¶
WorkFrames are the replica socket's frames of every record ({"k":"work","entries":[…]}), at most hubproto.ChatWorkFrameMax records each.