babbler: make recording new babbles _fast_

This is a hack. I am just pushing the processing off into a goroutine so
that we can return as quickly as possible from a non-event as far as the
bot's interaction with users is concerned. This is potentially harmful
if we have too many goroutines blocked writing babblers (hopefully
    sqlite is configured to be thread-safe). But if we have a bunch of
    babblers writing off to disk, it's no worse than blocking for each
    one sequentially, I guess.
This commit is contained in:
Chris Sexton 2018-10-29 18:27:16 -04:00 committed by Chris Sexton
parent 68cb50a117
commit 66fa219f78
1 changed files with 1 additions and 1 deletions

View File

@ -17,7 +17,7 @@ func (p *BabblerPlugin) initializeBabbler(tokens []string) (string, bool) {
func (p *BabblerPlugin) addToBabbler(babblerName, whatWasSaid string) (string, bool) {
babblerId, err := p.getOrCreateBabbler(babblerName)
if err == nil {
p.addToMarkovChain(babblerId, whatWasSaid)
go p.addToMarkovChain(babblerId, whatWasSaid)
}
return "", false
}