forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add single compactor http client for delete and gennumber clients (gr…
- Loading branch information
Showing
10 changed files
with
80 additions
and
55 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
42 changes: 42 additions & 0 deletions
42
pkg/storage/stores/indexshipper/compactor/compactor_client.go
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,42 @@ | ||
package compactor | ||
|
||
import ( | ||
"flag" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/grafana/dskit/crypto/tls" | ||
) | ||
|
||
// Config for compactor's generation-number client | ||
type ClientConfig struct { | ||
TLSEnabled bool `yaml:"tls_enabled"` | ||
TLS tls.ClientConfig `yaml:",inline"` | ||
} | ||
|
||
// RegisterFlags adds the flags required to config this to the given FlagSet. | ||
func (cfg *ClientConfig) RegisterFlags(f *flag.FlagSet) { | ||
prefix := "boltdb.shipper.compactor.client" | ||
f.BoolVar(&cfg.TLSEnabled, prefix+".tls-enabled", false, | ||
"Enable TLS in the HTTP client. This flag needs to be enabled when any other TLS flag is set. If set to false, insecure connection to HTTP server will be used.") | ||
cfg.TLS.RegisterFlagsWithPrefix(prefix, f) | ||
} | ||
|
||
// NewDeleteHTTPClient return a pointer to a http client instance based on the | ||
// delete client tls settings. | ||
func NewCompactorHTTPClient(cfg ClientConfig) (*http.Client, error) { | ||
transport := http.DefaultTransport.(*http.Transport).Clone() | ||
transport.MaxIdleConns = 250 | ||
transport.MaxIdleConnsPerHost = 250 | ||
|
||
if cfg.TLSEnabled { | ||
tlsCfg, err := cfg.TLS.GetTLSConfig() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
transport.TLSClientConfig = tlsCfg | ||
} | ||
|
||
return &http.Client{Timeout: 5 * time.Second, Transport: transport}, nil | ||
} |
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