Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
add no-consumers flag to be set on shared clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
magnushoerberg committed Feb 1, 2021
1 parent 944deec commit 70adc78
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ var (
Port string
Retention int64
AuthType string
Version string = "0.3.7"
Version string = "0.3.8"
GitCommit string = "HEAD"
JMXRequestTimeout time.Duration
KafkaDir string
ZookeeperURL []string
WebRequestTimeout time.Duration = 5 * time.Second
DevMode bool = false
NoConsumers bool = false
)

func PrintConfig() {
Expand Down
2 changes: 2 additions & 0 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var (
zk = flag.String("zookeeper", "localhost:2181", "The connection string for the zookeeper connection in the form host:port. Multiple hosts can be given to allow fail-over.")
kafkaDir = flag.String("kafkadir", "/opt/kafka", "The directory where kafka lives")
devMode = flag.Bool("dev", false, "Devmode add more logging and reloadable assets")
noConsumers = flag.Bool("no-consumers", false, "Disable listing of consumer groups")
)

func Parse() {
Expand All @@ -25,5 +26,6 @@ func Parse() {
KafkaDir = *kafkaDir
ZookeeperURL = strings.Split(*zk, ",")
DevMode = *devMode
NoConsumers = *noConsumers
PrintConfig()
}
5 changes: 5 additions & 0 deletions server/api/consumers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"
"sort"

"github.com/cloudkarafka/cloudkarafka-manager/config"
mw "github.com/cloudkarafka/cloudkarafka-manager/server/middleware"
"github.com/cloudkarafka/cloudkarafka-manager/store"
"goji.io/pat"
Expand All @@ -15,6 +16,10 @@ func ListConsumerGroups(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
if config.NoConsumers {
writeAsJson(w, Page(1, 1, store.ConsumerSlice{}))
return
}
ps, p, err := pageInfo(r)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
Expand Down

0 comments on commit 70adc78

Please sign in to comment.