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 1 commit
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
Prev Previous commit
Next Next commit
updated disable-compression flag for backward compatibility
Signed-off-by: Sagar Anand <sagar.anand015@gmail.com>
  • Loading branch information
sagaranand015 committed Jul 26, 2019
commit 86895fa117c9663d1389cc1fcc1aa417d3d7fc4f
9 changes: 7 additions & 2 deletions pkg/cassandra/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Configuration struct {
MaxRetryAttempts int `validate:"min=0" yaml:"max_retry_attempt"`
ProtoVersion int `yaml:"proto_version"`
Consistency string `yaml:"consistency"`
EnableCompression bool `yaml:"enable-compression"`
DisableCompression bool `yaml:"disable-compression"`
Port int `yaml:"port"`
Authenticator Authenticator `yaml:"authenticator"`
DisableAutoDiscovery bool `yaml:"disable_auto_discovery"`
Expand Down Expand Up @@ -130,10 +130,15 @@ func (c *Configuration) NewCluster() *gocql.ClusterConfig {
cluster.Port = c.Port
}

if c.EnableCompression {
fmt.Println("Disable Compression Flag is: ")
fmt.Println(c.DisableCompression)
if !c.DisableCompression {
cluster.Compressor = gocql.SnappyCompressor{}
}

fmt.Println("Compression is:")
fmt.Println(cluster.Compressor)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove print statements, we don't do that in Jaeger. I believe at some point we simply log the whole config struct, using the logger, not println.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad..Removed these in the latest push


if c.Consistency == "" {
cluster.Consistency = gocql.LocalOne
} else {
Expand Down
10 changes: 5 additions & 5 deletions plugin/storage/cassandra/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
suffixKeyspace = ".keyspace"
suffixDC = ".local-dc"
suffixConsistency = ".consistency"
suffixEnableCompression = ".enable-compression"
suffixDisableCompression = ".disable-compression"
suffixProtoVer = ".proto-version"
suffixSocketKeepAlive = ".socket-keep-alive"
suffixUsername = ".username"
Expand Down Expand Up @@ -165,9 +165,9 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
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+suffixEnableCompression,
true,
"Enable the use of Compression while connecting to Cassandra API based Storage backend. Uses SnappyCompression by default")
nsConfig.namespace+suffixDisableCompression,
false,
"Disables the use of the default Snappy Compression while connecting to the Cassandra Cluster if set to true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may want to add to description: "This may be useful when using Azure Cosmos DB instead of Cassandra"

flagSet.Int(
nsConfig.namespace+suffixProtoVer,
nsConfig.ProtoVersion,
Expand Down Expand Up @@ -248,7 +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.EnableCompression = v.GetBool(cfg.namespace + suffixEnableCompression)
cfg.DisableCompression = v.GetBool(cfg.namespace + suffixDisableCompression)
}

// GetPrimary returns primary configuration.
Expand Down