code refactor: move struct ReaderOptions to config

This commit is contained in:
Ulric Qin 2022-06-07 18:00:11 +08:00
parent 3e475e7e08
commit e5c1641b6b
2 changed files with 21 additions and 21 deletions

View File

@ -14,7 +14,6 @@ import (
"github.com/didi/nightingale/v5/src/pkg/httpx"
"github.com/didi/nightingale/v5/src/pkg/logx"
"github.com/didi/nightingale/v5/src/pkg/ormx"
"github.com/didi/nightingale/v5/src/server/reader"
"github.com/didi/nightingale/v5/src/storage"
)
@ -136,10 +135,27 @@ type Config struct {
DB ormx.DBConfig
WriterOpt WriterGlobalOpt
Writers []WriterOptions
Reader reader.Options
Reader ReaderOptions
Ibex Ibex
}
type ReaderOptions struct {
Url string
BasicAuthUser string
BasicAuthPass string
Timeout int64
DialTimeout int64
TLSHandshakeTimeout int64
ExpectContinueTimeout int64
IdleConnTimeout int64
KeepAlive int64
MaxConnsPerHost int
MaxIdleConns int
MaxIdleConnsPerHost int
}
type WriterOptions struct {
Url string
BasicAuthUser string

View File

@ -5,34 +5,18 @@ import (
"net/http"
"time"
"github.com/didi/nightingale/v5/src/server/config"
"github.com/prometheus/client_golang/api"
)
type Options struct {
Url string
BasicAuthUser string
BasicAuthPass string
Timeout int64
DialTimeout int64
TLSHandshakeTimeout int64
ExpectContinueTimeout int64
IdleConnTimeout int64
KeepAlive int64
MaxConnsPerHost int
MaxIdleConns int
MaxIdleConnsPerHost int
}
type ReaderType struct {
Opts Options
Opts config.ReaderOptions
Client API
}
var Reader ReaderType
func Init(opts Options) error {
func Init(opts config.ReaderOptions) error {
cli, err := api.NewClient(api.Config{
Address: opts.Url,
RoundTripper: &http.Transport{