Documentation
¶
Overview ¶
Package state holds all mutable state of one loop run behind one mutex. Nothing else in loop keeps shared state, so this is the only place to look for data races.
Index ¶
- type Change
- type Run
- func (r *Run) AddUsage(msg *schema.Message)
- func (r *Run) Append(msg *schema.Message)
- func (r *Run) Apply(c Change)
- func (r *Run) Begin(msgs []*schema.Message) bool
- func (r *Run) Fail(msg string)
- func (r *Run) Iteration() int
- func (r *Run) LastError() string
- func (r *Run) LastReply() string
- func (r *Run) MarkDoneIfRunning()
- func (r *Run) MaxIterations() int
- func (r *Run) Messages() []*schema.Message
- func (r *Run) NextIteration() int
- func (r *Run) Result() (event.DoneData, bool)
- func (r *Run) SetResult(d event.DoneData)
- func (r *Run) SetStatus(s Status)
- func (r *Run) Status() Status
- func (r *Run) TakeUnlogged() (start int, added []*schema.Message)
- func (r *Run) Temperature() float64
- func (r *Run) Usage() Usage
- type Settings
- type Status
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run is one run's state. settings.go and usage.go hold the rest of its methods.
func (*Run) Begin ¶
Begin moves Idle to Running with a copy of the starting messages. It returns false if the run had already started.
func (*Run) LastReply ¶
LastReply returns the text of the model's latest reply that had any, or "" when there is none.
func (*Run) MarkDoneIfRunning ¶
func (r *Run) MarkDoneIfRunning()
MarkDoneIfRunning settles a run that ended without a more specific status.
func (*Run) MaxIterations ¶
func (*Run) NextIteration ¶
NextIteration counts one more model call and returns its number.
func (*Run) TakeUnlogged ¶
TakeUnlogged returns the messages added since the last call, and the index of the first one.
func (*Run) Temperature ¶
type Settings ¶
Settings are the parts of the configuration a caller may change while the loop runs.
type Status ¶
type Status string
Status is the lifecycle state of a run.
const ( // Idle is the state before Start. Idle Status = "idle" // Running is the state between Start and the done event. Running Status = "running" // Done means the loop ended on its own: finished, max iterations, // timeout, or handed over to a human. Done Status = "done" // Stopped means the loop ended because it was told to stop. Stopped Status = "stopped" // Error means the loop ended on a fatal error. Error Status = "error" )