mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Merge pull request #8488 from pstibrany/pass-queryable-and-appendable-explicitly
Split queryable and appendable arguments in api_v1.NewAPI.
This commit is contained in:
commit
6f488061df
|
@ -205,7 +205,8 @@ func init() {
|
||||||
// NewAPI returns an initialized API type.
|
// NewAPI returns an initialized API type.
|
||||||
func NewAPI(
|
func NewAPI(
|
||||||
qe *promql.Engine,
|
qe *promql.Engine,
|
||||||
s storage.Storage,
|
q storage.SampleAndChunkQueryable,
|
||||||
|
ap storage.Appendable,
|
||||||
tr func(context.Context) TargetRetriever,
|
tr func(context.Context) TargetRetriever,
|
||||||
ar func(context.Context) AlertmanagerRetriever,
|
ar func(context.Context) AlertmanagerRetriever,
|
||||||
configFunc func() config.Config,
|
configFunc func() config.Config,
|
||||||
|
@ -224,11 +225,10 @@ func NewAPI(
|
||||||
runtimeInfo func() (RuntimeInfo, error),
|
runtimeInfo func() (RuntimeInfo, error),
|
||||||
buildInfo *PrometheusVersion,
|
buildInfo *PrometheusVersion,
|
||||||
gatherer prometheus.Gatherer,
|
gatherer prometheus.Gatherer,
|
||||||
remoteWriteReceiver bool,
|
|
||||||
) *API {
|
) *API {
|
||||||
a := &API{
|
a := &API{
|
||||||
QueryEngine: qe,
|
QueryEngine: qe,
|
||||||
Queryable: s,
|
Queryable: q,
|
||||||
|
|
||||||
targetRetriever: tr,
|
targetRetriever: tr,
|
||||||
alertmanagerRetriever: ar,
|
alertmanagerRetriever: ar,
|
||||||
|
@ -252,8 +252,8 @@ func NewAPI(
|
||||||
gatherer: gatherer,
|
gatherer: gatherer,
|
||||||
}
|
}
|
||||||
|
|
||||||
if remoteWriteReceiver {
|
if ap != nil {
|
||||||
a.remoteWriteHandler = remote.NewWriteHandler(logger, s)
|
a.remoteWriteHandler = remote.NewWriteHandler(logger, ap)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a
|
return a
|
||||||
|
|
|
@ -298,7 +298,12 @@ func New(logger log.Logger, o *Options) *Handler {
|
||||||
factoryAr := func(_ context.Context) api_v1.AlertmanagerRetriever { return h.notifier }
|
factoryAr := func(_ context.Context) api_v1.AlertmanagerRetriever { return h.notifier }
|
||||||
FactoryRr := func(_ context.Context) api_v1.RulesRetriever { return h.ruleManager }
|
FactoryRr := func(_ context.Context) api_v1.RulesRetriever { return h.ruleManager }
|
||||||
|
|
||||||
h.apiV1 = api_v1.NewAPI(h.queryEngine, h.storage, factoryTr, factoryAr,
|
var app storage.Appendable
|
||||||
|
if o.RemoteWriteReceiver {
|
||||||
|
app = h.storage
|
||||||
|
}
|
||||||
|
|
||||||
|
h.apiV1 = api_v1.NewAPI(h.queryEngine, h.storage, app, factoryTr, factoryAr,
|
||||||
func() config.Config {
|
func() config.Config {
|
||||||
h.mtx.RLock()
|
h.mtx.RLock()
|
||||||
defer h.mtx.RUnlock()
|
defer h.mtx.RUnlock()
|
||||||
|
@ -323,7 +328,6 @@ func New(logger log.Logger, o *Options) *Handler {
|
||||||
h.runtimeInfo,
|
h.runtimeInfo,
|
||||||
h.versionInfo,
|
h.versionInfo,
|
||||||
o.Gatherer,
|
o.Gatherer,
|
||||||
o.RemoteWriteReceiver,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if o.RoutePrefix != "/" {
|
if o.RoutePrefix != "/" {
|
||||||
|
|
Loading…
Reference in a new issue