-
Notifications
You must be signed in to change notification settings - Fork 174
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 #384 from norbertklawikowski/fix-examples-initiali…
…zation Fix examples initialization after auto creation of topics is disabled
- Loading branch information
Showing
15 changed files
with
204 additions
and
23 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package topicinit | ||
|
||
import ( | ||
"github.com/lovoo/goka" | ||
"log" | ||
) | ||
|
||
// EnsureStreamExists is a convenience wrapper for TopicManager.EnsureStreamExists | ||
func EnsureStreamExists(topic string, brokers []string) { | ||
tm := createTopicManager(brokers) | ||
defer tm.Close() | ||
err := tm.EnsureStreamExists(topic, 8) | ||
if err != nil { | ||
log.Printf("Error creating kafka topic %s: %v", topic, err) | ||
} | ||
} | ||
|
||
// EnsureTableExists is a convenience wrapper for TopicManager.EnsureTableExists | ||
func EnsureTableExists(topic string, brokers []string) { | ||
tm := createTopicManager(brokers) | ||
defer tm.Close() | ||
err := tm.EnsureTableExists(topic, 8) | ||
if err != nil { | ||
log.Printf("Error creating kafka topic %s: %v", topic, err) | ||
} | ||
} | ||
|
||
func createTopicManager(brokers []string) goka.TopicManager { | ||
tmc := goka.NewTopicManagerConfig() | ||
tm, err := goka.NewTopicManager(brokers, goka.DefaultConfig(), tmc) | ||
if err != nil { | ||
log.Fatalf("Error creating topic manager: %v", err) | ||
} | ||
return tm | ||
} |
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.