Skip to content

Conversation

@jh-bate
Copy link
Contributor

@jh-bate jh-bate commented Sep 10, 2014

add interface to base shoreline client from, also integrate with travis

jh-bate added a commit that referenced this pull request Sep 14, 2014
Jhbate/mock shoreline

pulling in the additional mock so that I can integrate with hydrophone
@jh-bate jh-bate merged commit 1253594 into master Sep 14, 2014
@jh-bate jh-bate deleted the jhbate/mock-shoreline branch September 14, 2014 23:26
ewollesen added a commit that referenced this pull request Mar 27, 2024
I believe there was confusion about how this is called or should run. These
changes provide equivalent functionality, while being easier to read and
understand.

There are instructions from the library authors here:
https://github.com/IBM/sarama/blob/v1.38.1/consumer_group.go#L19

I think there was confusion around the steps detailed in the link above. So
let me clarify my understanding:

- Canceling the context passed to Consume is how the implementor of the
  sarama.ConsumerGroupHandler tells Consume to return. In other words, when
  we're shutting down, we cancel the context to get Consume to return. I base
  this off of #4 in the link.

- No goroutine needs to be launched on our side, the sarama library will
  launch the goroutines and those goroutines will call our implementation of
  ConsumeClaim(). This comes from #3.

- The warnings about thread-safety apply to our implementation of
  ConsumeClaim(). In other words, we need to be careful that s.consumer isn't
  nil, but since nothing in our code modifies s.consumer after instantiation,
  we're fine. This comes from #3.

- Since our own events.EventConsumer has to be able to respond to Stop()
  calls, we need to be able to break the for-loop in Start(), which is done by
  canceling the context that we pass to Consume(). The context.CancelFunc is
  guarded with a mutex for for extra thread-safety, so that if Stop() is called
  from multiple goroutines, we don't have any race conditions to worry about.

We can reason that the goroutine being previously launched necessary, as there
was only a single goroutine being launched, and same function that launched
it then blocked, waiting for it to return before continuing.

Without the goroutine, the WaitGroup and stop channel and stopOnce are no
longer required.
ewollesen added a commit that referenced this pull request Mar 28, 2024
I believe there was confusion about how this is called or should run. These
changes provide equivalent functionality, while being easier to read and
understand.

There are instructions from the library authors here:
https://github.com/IBM/sarama/blob/v1.38.1/consumer_group.go#L19

I think there was confusion around the steps detailed in the link above. So
let me clarify my understanding:

- Canceling the context passed to Consume is how the implementor of the
  sarama.ConsumerGroupHandler tells Consume to return. In other words, when
  we're shutting down, we cancel the context to get Consume to return. I base
  this off of #4 in the link.

- No goroutine needs to be launched on our side, the sarama library will
  launch the goroutines and those goroutines will call our implementation of
  ConsumeClaim(). This comes from #3.

- The warnings about thread-safety apply to our implementation of
  ConsumeClaim(). In other words, we need to be careful that s.consumer isn't
  nil, but since nothing in our code modifies s.consumer after instantiation,
  we're fine. This comes from #3.

- Since our own events.EventConsumer has to be able to respond to Stop()
  calls, we need to be able to break the for-loop in Start(), which is done by
  canceling the context that we pass to Consume(). The context.CancelFunc is
  guarded with a mutex for for extra thread-safety, so that if Stop() is called
  from multiple goroutines, we don't have any race conditions to worry about.

We can reason that the goroutine being previously launched was not necessary,
because there was only a single goroutine being launched, and the same
function that launched the goroutine then blocked, waiting for it to exit
before continuing.

Without the goroutine, the WaitGroup, stop channel and stopOnce are no longer
necessary.
ewollesen added a commit that referenced this pull request Apr 15, 2024
I believe there was confusion about how this is called or should run. These
changes provide equivalent functionality, while being easier to read and
understand.

There are instructions from the library authors here:
https://github.com/IBM/sarama/blob/v1.38.1/consumer_group.go#L19

I think there was confusion around the steps detailed in the link above. So
let me clarify my understanding:

- Canceling the context passed to Consume is how the implementor of the
  sarama.ConsumerGroupHandler tells Consume to return. In other words, when
  we're shutting down, we cancel the context to get Consume to return. I base
  this off of #4 in the link.

- No goroutine needs to be launched on our side, the sarama library will
  launch the goroutines and those goroutines will call our implementation of
  ConsumeClaim(). This comes from #3.

- The warnings about thread-safety apply to our implementation of
  ConsumeClaim(). In other words, we need to be careful that s.consumer isn't
  nil, but since nothing in our code modifies s.consumer after instantiation,
  we're fine. This comes from #3.

- Since our own events.EventConsumer has to be able to respond to Stop()
  calls, we need to be able to break the for-loop in Start(), which is done by
  canceling the context that we pass to Consume(). The context.CancelFunc is
  guarded with a mutex for for extra thread-safety, so that if Stop() is called
  from multiple goroutines, we don't have any race conditions to worry about.

We can reason that the goroutine being previously launched was not necessary,
because there was only a single goroutine being launched, and the same
function that launched the goroutine then blocked, waiting for it to exit
before continuing.

Without the goroutine, the WaitGroup, stop channel and stopOnce are no longer
necessary.
ewollesen added a commit that referenced this pull request Feb 3, 2025
I believe there was confusion about how this is called or should run. These
changes provide equivalent functionality, while being easier to read and
understand.

There are instructions from the library authors here:
https://github.com/IBM/sarama/blob/v1.38.1/consumer_group.go#L19

I think there was confusion around the steps detailed in the link above. So
let me clarify my understanding:

- Canceling the context passed to Consume is how the implementor of the
  sarama.ConsumerGroupHandler tells Consume to return. In other words, when
  we're shutting down, we cancel the context to get Consume to return. I base
  this off of #4 in the link.

- No goroutine needs to be launched on our side, the sarama library will
  launch the goroutines and those goroutines will call our implementation of
  ConsumeClaim(). This comes from #3.

- The warnings about thread-safety apply to our implementation of
  ConsumeClaim(). In other words, we need to be careful that s.consumer isn't
  nil, but since nothing in our code modifies s.consumer after instantiation,
  we're fine. This comes from #3.

- Since our own events.EventConsumer has to be able to respond to Stop()
  calls, we need to be able to break the for-loop in Start(), which is done by
  canceling the context that we pass to Consume(). The context.CancelFunc is
  guarded with a mutex for for extra thread-safety, so that if Stop() is called
  from multiple goroutines, we don't have any race conditions to worry about.

We can reason that the goroutine being previously launched was not necessary,
because there was only a single goroutine being launched, and the same
function that launched the goroutine then blocked, waiting for it to exit
before continuing.

Without the goroutine, the WaitGroup, stop channel and stopOnce are no longer
necessary.
ewollesen added a commit that referenced this pull request Mar 3, 2025
I believe there was confusion about how this is called or should run. These
changes provide equivalent functionality, while being easier to read and
understand.

There are instructions from the library authors here:
https://github.com/IBM/sarama/blob/v1.38.1/consumer_group.go#L19

I think there was confusion around the steps detailed in the link above. So
let me clarify my understanding:

- Canceling the context passed to Consume is how the implementor of the
  sarama.ConsumerGroupHandler tells Consume to return. In other words, when
  we're shutting down, we cancel the context to get Consume to return. I base
  this off of #4 in the link.

- No goroutine needs to be launched on our side, the sarama library will
  launch the goroutines and those goroutines will call our implementation of
  ConsumeClaim(). This comes from #3.

- The warnings about thread-safety apply to our implementation of
  ConsumeClaim(). In other words, we need to be careful that s.consumer isn't
  nil, but since nothing in our code modifies s.consumer after instantiation,
  we're fine. This comes from #3.

- Since our own events.EventConsumer has to be able to respond to Stop()
  calls, we need to be able to break the for-loop in Start(), which is done by
  canceling the context that we pass to Consume(). The context.CancelFunc is
  guarded with a mutex for for extra thread-safety, so that if Stop() is called
  from multiple goroutines, we don't have any race conditions to worry about.

We can reason that the goroutine being previously launched was not necessary,
because there was only a single goroutine being launched, and the same
function that launched the goroutine then blocked, waiting for it to exit
before continuing.

Without the goroutine, the WaitGroup, stop channel and stopOnce are no longer
necessary.
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.

2 participants