code refactor: move struct ReaderOptions to config
This commit is contained in:
parent
3e475e7e08
commit
e5c1641b6b
|
@ -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
|
||||
|
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue