Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumer groups #89

Closed
wants to merge 6 commits into from
Closed

Consumer groups #89

wants to merge 6 commits into from

Conversation

harlow
Copy link
Owner

@harlow harlow commented May 21, 2019

No description provided.

…ome of the code in consumergroup to accomodate conditional expressions.

Moved the LeaseUpdate from consumergroup to ddb.go - it is only needed by ddb.go, and it is ddb.go specific.
Added some comments.
// shards on a regular cadence.
func (b *broker) start(ctx context.Context) {
b.findNewShards()
func (b *broker) Start(ctx context.Context, shardc chan string) {
Copy link
Owner Author

@harlow harlow May 21, 2019

Choose a reason for hiding this comment

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

we could potentially adjust this func signature to have it return chan string

func (b *broker) Start(ctx context.Context) chan string {

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me investigate that.

consumergroup.go Outdated
OwnerID string
done chan struct{}
currentLeases map[string]*Lease //Initially, this will only be one
Mutex *sync.Mutex
Copy link
Owner Author

Choose a reason for hiding this comment

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

can we use a Mutext Hat here:
https://dmitri.shuralyov.com/idiomatic-go#mutex-hat

Also I think the exported vs non-exported should be grouped together in alphabetical order

Copy link
Contributor

Choose a reason for hiding this comment

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

re-arranged. This is good idea for all go. I wish the reformatters in IDEs would do this.

consumergroup.go Outdated
for {
select {
case <-tick.C:
if len(cgc.currentLeases) == 0 { // only do anything if there are no current leases
Copy link
Owner Author

Choose a reason for hiding this comment

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

can we reduce indentation and use a guard clause?

if len(cgc.currentLeases) > 0 {
  continue
}

// ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

consumergroup.go Outdated
}

lease := cgc.CreateOrGetExpiredLease(currentLeases, previousLeases)
if lease != nil && lease.LeaseKey != "" {
Copy link
Owner Author

Choose a reason for hiding this comment

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

can we invert this conditional too? ideally the end of this loop will be the core functionality and not indented

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/aws/aws-sdk-go/service/dynamodb/expression"

consumer "github.com/harlow/kinesis-consumer"
Copy link
Owner Author

Choose a reason for hiding this comment

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

feels like we might be in danger of cyclical import. I've tried to stick to general rule of thump that sub packages don't know about directory levels above them.

Copy link
Contributor

@keperry keperry May 24, 2019

Choose a reason for hiding this comment

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

I think we might be fine once we reorganize the packages, but if not, let's revisit this guy. The only thing it is using right now is the Lease struct.

Copy link
Contributor

Choose a reason for hiding this comment

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

I moved Lease to storage - in a new file called lease.go - all storage options should be able to use this. Let me know if that works.

@harlow
Copy link
Owner Author

harlow commented Jul 29, 2019

hi @keperry I'm gonna close this PR for now (I can't approve PRs I open). that way you can rebase, and submit a PR from your account .

@harlow harlow closed this Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants