Stop action when picking up the job
This commit is contained in:
@@ -14,7 +14,9 @@ type ActionContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ac *ActionContext) Cancel() {
|
func (ac *ActionContext) Cancel() {
|
||||||
ac.cancelFunc()
|
if ac.cancelFunc == nil {
|
||||||
|
ac.cancelFunc()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContext(ctx context.Context, cancel context.CancelFunc) *ActionContext {
|
func NewContext(ctx context.Context, cancel context.CancelFunc) *ActionContext {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ func (a *Agent) Ask(opts ...JobOption) *JobResult {
|
|||||||
xlog.Debug("Agent has finished being asked", "agent", a.Character.Name)
|
xlog.Debug("Agent has finished being asked", "agent", a.Character.Name)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
a.StopAction()
|
//a.StopAction()
|
||||||
j := NewJob(
|
j := NewJob(
|
||||||
append(
|
append(
|
||||||
opts,
|
opts,
|
||||||
@@ -730,6 +730,7 @@ func (a *Agent) Run() error {
|
|||||||
<-timer.C
|
<-timer.C
|
||||||
}
|
}
|
||||||
xlog.Debug("Agent is consuming a job", "agent", a.Character.Name, "job", job)
|
xlog.Debug("Agent is consuming a job", "agent", a.Character.Name, "job", job)
|
||||||
|
a.StopAction()
|
||||||
a.consumeJob(job, UserRole)
|
a.consumeJob(job, UserRole)
|
||||||
timer.Reset(a.options.periodicRuns)
|
timer.Reset(a.options.periodicRuns)
|
||||||
case <-a.context.Done():
|
case <-a.context.Done():
|
||||||
@@ -740,6 +741,7 @@ func (a *Agent) Run() error {
|
|||||||
if !a.options.standaloneJob {
|
if !a.options.standaloneJob {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
a.StopAction()
|
||||||
xlog.Debug("Agent is running periodically", "agent", a.Character.Name)
|
xlog.Debug("Agent is running periodically", "agent", a.Character.Name)
|
||||||
a.periodicallyRun()
|
a.periodicallyRun()
|
||||||
timer.Reset(a.options.periodicRuns)
|
timer.Reset(a.options.periodicRuns)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ type Character struct {
|
|||||||
Age any `json:"age"`
|
Age any `json:"age"`
|
||||||
Occupation string `json:"job_occupation"`
|
Occupation string `json:"job_occupation"`
|
||||||
Hobbies []string `json:"hobbies"`
|
Hobbies []string `json:"hobbies"`
|
||||||
MusicTaste []string `json:"music_taste"`
|
MusicTaste []string `json:"favorites_music_genres"`
|
||||||
Sex string `json:"sex"`
|
Sex string `json:"sex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user