Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flags for driving cassandra connection compression through config #1675

Merged
merged 4 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/cassandra/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Configuration struct {
MaxRetryAttempts int `validate:"min=0" yaml:"max_retry_attempt"`
ProtoVersion int `yaml:"proto_version"`
Consistency string `yaml:"consistency"`
DisableCompression bool `yaml:"disable-compression"`
Port int `yaml:"port"`
Authenticator Authenticator `yaml:"authenticator"`
DisableAutoDiscovery bool `yaml:"disable_auto_discovery"`
Expand Down Expand Up @@ -128,7 +129,11 @@ func (c *Configuration) NewCluster() *gocql.ClusterConfig {
if c.Port != 0 {
cluster.Port = c.Port
}
cluster.Compressor = gocql.SnappyCompressor{}

if !c.DisableCompression {
cluster.Compressor = gocql.SnappyCompressor{}
}

if c.Consistency == "" {
cluster.Consistency = gocql.LocalOne
} else {
Expand Down
6 changes: 6 additions & 0 deletions plugin/storage/cassandra/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const (
suffixKeyspace = ".keyspace"
suffixDC = ".local-dc"
suffixConsistency = ".consistency"
suffixDisableCompression = ".disable-compression"
suffixProtoVer = ".proto-version"
suffixSocketKeepAlive = ".socket-keep-alive"
suffixUsername = ".username"
Expand Down Expand Up @@ -163,6 +164,10 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
nsConfig.namespace+suffixConsistency,
nsConfig.Consistency,
"The Cassandra consistency level, e.g. ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_QUORUM, EACH_QUORUM, LOCAL_ONE (default LOCAL_ONE)")
flagSet.Bool(
nsConfig.namespace+suffixDisableCompression,
false,
"Disables the use of the default Snappy Compression while connecting to the Cassandra Cluster if set to true. This is useful for connecting to Cassandra Clusters(like Azure Cosmos Db with Cassandra API) that do not support SnappyCompression")
flagSet.Int(
nsConfig.namespace+suffixProtoVer,
nsConfig.ProtoVersion,
Expand Down Expand Up @@ -243,6 +248,7 @@ func (cfg *namespaceConfig) initFromViper(v *viper.Viper) {
cfg.TLS.ServerName = v.GetString(cfg.namespace + suffixServerName)
cfg.TLS.EnableHostVerification = v.GetBool(cfg.namespace + suffixVerifyHost)
cfg.EnableDependenciesV2 = v.GetBool(cfg.namespace + suffixEnableDependenciesV2)
cfg.DisableCompression = v.GetBool(cfg.namespace + suffixDisableCompression)
}

// GetPrimary returns primary configuration.
Expand Down