-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ingest: repository data and p.js cached on disk for reliable startup ingest: gzip responses
- Loading branch information
Showing
14 changed files
with
514 additions
and
143 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module github.com/jitsucom/bulker/admin | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/confluentinc/confluent-kafka-go/v2 v2.3.0 | ||
github.com/hjson/hjson-go/v4 v4.3.1 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/google/uuid v1.4.0 // indirect | ||
github.com/klauspost/compress v1.17.0 // indirect | ||
github.com/moby/patternmatcher v0.6.0 // indirect | ||
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect | ||
github.com/opencontainers/runc v1.1.7 // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/sirupsen/logrus v1.9.3 // indirect | ||
github.com/stretchr/testify v1.8.4 // indirect | ||
github.com/testcontainers/testcontainers-go v0.25.0 // indirect | ||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect | ||
google.golang.org/grpc v1.59.0 // indirect | ||
) |
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,69 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/confluentinc/confluent-kafka-go/v2/kafka" | ||
"github.com/hjson/hjson-go/v4" | ||
"github.com/jitsucom/bulker/jitsubase/utils" | ||
"os" | ||
) | ||
|
||
// add partitions to the topic | ||
func main() { | ||
bootstapServers := os.Getenv("KAFKA_BOOTSTRAP_SERVERS") | ||
securityProtocol := utils.Nvl(os.Getenv("KAFKA_SECURITY_PROTOCOL"), "SASL_SSL") | ||
kafkaSasl := os.Getenv("KAFKA_SASL") | ||
|
||
kafkaConfig := &kafka.ConfigMap{ | ||
"client.id": "bulkerapp_admin", | ||
"bootstrap.servers": bootstapServers, | ||
"reconnect.backoff.ms": 1000, | ||
"reconnect.backoff.max.ms": 10000, | ||
} | ||
if securityProtocol != "" { | ||
_ = kafkaConfig.SetKey("security.protocol", securityProtocol) | ||
} | ||
_ = kafkaConfig.SetKey("enable.ssl.certificate.verification", false) | ||
if kafkaSasl != "" { | ||
sasl := map[string]interface{}{} | ||
err := hjson.Unmarshal([]byte(kafkaSasl), &sasl) | ||
if err != nil { | ||
panic(fmt.Errorf("error parsing Kafka SASL config: %v", err)) | ||
} | ||
for k, v := range sasl { | ||
_ = kafkaConfig.SetKey("sasl."+k, v) | ||
} | ||
} | ||
admin, err := kafka.NewAdminClient(kafkaConfig) | ||
if err != nil { | ||
panic(fmt.Errorf("error creating Kafka admin client: %v", err)) | ||
} | ||
m, err := admin.GetMetadata(nil, true, 10000) | ||
if err != nil { | ||
panic(fmt.Errorf("error getting Kafka metadata: %v", err)) | ||
} | ||
fmt.Println(m.Brokers) | ||
fmt.Print("Enter topic name to increase partitions: ") | ||
var topic string | ||
_, err = fmt.Scanln(&topic) | ||
if err != nil { | ||
panic(fmt.Errorf("error reading topic name: %v", err)) | ||
} | ||
fmt.Printf("Enter new number of partitions for topic '%s': ", topic) | ||
var partitions int | ||
_, err = fmt.Scanln(&partitions) | ||
if err != nil { | ||
panic(fmt.Errorf("error reading partitions number: %v", err)) | ||
} | ||
res, err := admin.CreatePartitions(context.Background(), []kafka.PartitionsSpecification{ | ||
{ | ||
Topic: topic, | ||
IncreaseTo: partitions, | ||
}, | ||
}) | ||
if err != nil { | ||
panic(fmt.Errorf("error creating partitions: %v", err)) | ||
} | ||
fmt.Println(res) | ||
} |
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
Oops, something went wrong.