mirror of https://github.com/velour/catbase.git
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:
parent
68cb50a117
commit
66fa219f78
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue