-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ricardo-ch/adr-35-instrumentation
Go-kafka V2
- Loading branch information
Showing
16 changed files
with
743 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
version: 2.1 | ||
orbs: | ||
coveralls: coveralls/[email protected] | ||
jobs: | ||
quality-gate: | ||
docker: | ||
|
@@ -16,15 +14,9 @@ jobs: | |
- run: | ||
name: Test | ||
command: make test | ||
- run: | ||
name: install coveralls | ||
command: go install github.com/mattn/goveralls@latest | ||
- run: | ||
name: code coverage | ||
command: goveralls -service=circle-ci -ignore "mocks/*" -repotoken=$COVERALLS_REPO_TOKEN | ||
workflows: | ||
version: 2 | ||
coveralls_workflow: | ||
quality-gate: | ||
jobs: | ||
- quality-gate: | ||
context: dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package kafka | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/Shopify/sarama" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
var ( | ||
client *sarama.Client | ||
clientMutex = &sync.Mutex{} | ||
) | ||
|
||
func getClient() (*sarama.Client, error) { | ||
if client != nil { | ||
return client, nil | ||
} | ||
|
||
clientMutex.Lock() | ||
defer clientMutex.Unlock() | ||
|
||
if client == nil { | ||
var c sarama.Client | ||
var err error | ||
|
||
if len(Brokers) == 0 { | ||
return nil, errors.New("cannot create new client, Brokers must be specified") | ||
} | ||
c, err = sarama.NewClient(Brokers, Config) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client = &c | ||
} | ||
|
||
return client, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.