Moved unit agnostic options to separate pkg.
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
This commit is contained in:
parent
59c9d6ef45
commit
8a775bc468
|
@ -40,6 +40,7 @@ import (
|
|||
"github.com/prometheus/common/model"
|
||||
"github.com/prometheus/common/promlog"
|
||||
"github.com/prometheus/common/version"
|
||||
tsdbconfig "github.com/prometheus/prometheus/tsdb/config"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
"k8s.io/klog"
|
||||
|
||||
|
@ -106,7 +107,7 @@ func main() {
|
|||
outageTolerance model.Duration
|
||||
resendDelay model.Duration
|
||||
web web.Options
|
||||
tsdb web.TSDBOptions
|
||||
tsdb tsdbconfig.Options
|
||||
lookbackDelta model.Duration
|
||||
webTimeout model.Duration
|
||||
queryTimeout model.Duration
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright 2020 The Prometheus Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tsdbconfig
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/units"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/prometheus/prometheus/tsdb"
|
||||
)
|
||||
|
||||
// Options is tsdb.Option version with defined units.
|
||||
// This is required as tsdb.Option fields are unit agnostic (time).
|
||||
type Options struct {
|
||||
WALSegmentSize units.Base2Bytes
|
||||
RetentionDuration model.Duration
|
||||
MaxBytes units.Base2Bytes
|
||||
NoLockfile bool
|
||||
AllowOverlappingBlocks bool
|
||||
WALCompression bool
|
||||
StripeSize int
|
||||
MinBlockDuration model.Duration
|
||||
MaxBlockDuration model.Duration
|
||||
}
|
||||
|
||||
func (opts Options) ToTSDBOptions() tsdb.Options {
|
||||
return tsdb.Options{
|
||||
WALSegmentSize: int(opts.WALSegmentSize),
|
||||
RetentionDuration: int64(time.Duration(opts.RetentionDuration) / time.Millisecond),
|
||||
MaxBytes: int64(opts.MaxBytes),
|
||||
NoLockfile: opts.NoLockfile,
|
||||
AllowOverlappingBlocks: opts.AllowOverlappingBlocks,
|
||||
WALCompression: opts.WALCompression,
|
||||
StripeSize: opts.StripeSize,
|
||||
MinBlockDuration: int64(time.Duration(opts.MinBlockDuration) / time.Millisecond),
|
||||
MaxBlockDuration: int64(time.Duration(opts.MaxBlockDuration) / time.Millisecond),
|
||||
}
|
||||
}
|
32
web/web.go
32
web/web.go
|
@ -38,7 +38,6 @@ import (
|
|||
template_text "text/template"
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/units"
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
conntrack "github.com/mwitkow/go-conntrack"
|
||||
|
@ -52,6 +51,7 @@ import (
|
|||
"github.com/prometheus/common/route"
|
||||
"github.com/prometheus/common/server"
|
||||
"github.com/prometheus/prometheus/tsdb"
|
||||
tsdbconfig "github.com/prometheus/prometheus/tsdb/config"
|
||||
"github.com/prometheus/prometheus/tsdb/index"
|
||||
"github.com/soheilhy/cmux"
|
||||
"golang.org/x/net/netutil"
|
||||
|
@ -209,39 +209,11 @@ func (h *Handler) ApplyConfig(conf *config.Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// TSDBOptions is tsdb.Option version with defined units.
|
||||
// This is required as tsdb.Option fields are unit agnostic (time).
|
||||
type TSDBOptions struct {
|
||||
WALSegmentSize units.Base2Bytes
|
||||
RetentionDuration model.Duration
|
||||
MaxBytes units.Base2Bytes
|
||||
NoLockfile bool
|
||||
AllowOverlappingBlocks bool
|
||||
WALCompression bool
|
||||
StripeSize int
|
||||
MinBlockDuration model.Duration
|
||||
MaxBlockDuration model.Duration
|
||||
}
|
||||
|
||||
func (opts TSDBOptions) ToTSDBOptions() tsdb.Options {
|
||||
return tsdb.Options{
|
||||
WALSegmentSize: int(opts.WALSegmentSize),
|
||||
RetentionDuration: int64(time.Duration(opts.RetentionDuration) / time.Millisecond),
|
||||
MaxBytes: int64(opts.MaxBytes),
|
||||
NoLockfile: opts.NoLockfile,
|
||||
AllowOverlappingBlocks: opts.AllowOverlappingBlocks,
|
||||
WALCompression: opts.WALCompression,
|
||||
StripeSize: opts.StripeSize,
|
||||
MinBlockDuration: int64(time.Duration(opts.MinBlockDuration) / time.Millisecond),
|
||||
MaxBlockDuration: int64(time.Duration(opts.MaxBlockDuration) / time.Millisecond),
|
||||
}
|
||||
}
|
||||
|
||||
// Options for the web Handler.
|
||||
type Options struct {
|
||||
Context context.Context
|
||||
TSDB func() *tsdb.DB
|
||||
TSDBCfg TSDBOptions
|
||||
TSDBCfg tsdbconfig.Options
|
||||
Storage storage.Storage
|
||||
QueryEngine *promql.Engine
|
||||
LookbackDelta time.Duration
|
||||
|
|
Loading…
Reference in New Issue