From 66fa219f78df9f55ab965f1ff203baca9c361668 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 29 Oct 2018 18:27:16 -0400 Subject: [PATCH] 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. --- plugins/babbler/commands.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/babbler/commands.go b/plugins/babbler/commands.go index ba337e7..38e50d9 100644 --- a/plugins/babbler/commands.go +++ b/plugins/babbler/commands.go @@ -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 }