stoewer/go-nakadi

Sub APIs are not threadsafe due to early initialization of backoff

stoewer opened this issue · 0 comments

Currently all sub APIs create a backoff instance while they are created. Although it is safe to reuse the same backoff instance multiple times (Retry calls Reset() every time it is used), it makes the sub API instances themselves not thread safe because each backoff maintains a state.

The following example shows such a shared backoff instance in the PublishAPI:

type PublishAPI struct {
	client     *Client
	publishURL string
	backOff    backoff.BackOff
}

To make all API instances thread safe, backoff instances should be created on each API call.