Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Update Design For Concurrency! #70

Merged
merged 6 commits into from
Mar 3, 2018

Conversation

toolateforteddy
Copy link
Contributor

I got a little annoyed that the current bot can only do one thing at a time. So I did some restructuring around how messages are sent back to the underlying chat layer to make sure that concurrency in the bot cannot expose race conditions within the chat layer message sending logic.

While doing so, after reading issue #69 , I decided that a passive version of the V3 command was in order.

So what do you think?

This makes the package much easier to import and use.

There should be no functional changes in this commit.
It is pretty annoying that a long running command hangs the
whole bot. Now commands will be executed on a launched
goroutine! Yay!

All objects passed into MessageReceived are generated at the
call site, so there can be no concurrency issues there.

We can later look into making the others concurrent, but for
now I just want Slack to work this way.
This reverts commit 4a9a8ca.

I really don't understand go package layout. Sorry.
This will be a passive command that can return multiple
messages.
This should make it much easier to have many go routines
sending messages back to the chat service at the same time,
but streamlining them through a channel.

I had to add a way to skip the async sending in tests because
otherwise I would likely end up having to add sleeps all over
the place.
bot.go Outdated
}
}

func (b *Bot) Close() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method Bot.Close should have comment or be unexported

Copy link
Member

@fabioxgn fabioxgn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR 👏

@fabioxgn fabioxgn merged commit d08a766 into go-chat-bot:master Mar 3, 2018
@fabioxgn fabioxgn mentioned this pull request Mar 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants