-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Info server in Sidecar and StoreGW
Signed-off-by: Hitanshu Mehta <[email protected]>
- Loading branch information
1 parent
ea8cf49
commit 89aedf4
Showing
9 changed files
with
1,298 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package info | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/go-kit/kit/log" | ||
"github.com/thanos-io/thanos/pkg/info/infopb" | ||
"github.com/thanos-io/thanos/pkg/store/labelpb" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
type InfoServer struct { | ||
infopb.UnimplementedInfoServer | ||
|
||
logger log.Logger | ||
component infopb.ComponentType | ||
|
||
getLabelSet func() []labelpb.ZLabelSet | ||
getStoreInfo func() *infopb.StoreInfo | ||
getExemplarsInfo func() *infopb.ExemplarsInfo | ||
} | ||
|
||
func NewInfoServer( | ||
component infopb.ComponentType, | ||
getLabelSet func() []labelpb.ZLabelSet, | ||
getStoreInfo func() *infopb.StoreInfo, | ||
getExemplarsInfo func() *infopb.ExemplarsInfo, | ||
) *InfoServer { | ||
return &InfoServer{ | ||
component: component, | ||
getLabelSet: getLabelSet, | ||
getStoreInfo: getStoreInfo, | ||
getExemplarsInfo: getExemplarsInfo, | ||
} | ||
} | ||
|
||
// RegisterInfoServer register info server. | ||
func RegisterInfoServer(infoSrv infopb.InfoServer) func(*grpc.Server) { | ||
return func(s *grpc.Server) { | ||
infopb.RegisterInfoServer(s, infoSrv) | ||
} | ||
} | ||
|
||
func (srv *InfoServer) Info(ctx context.Context, req *infopb.InfoRequest) (*infopb.InfoResponse, error) { | ||
return &infopb.InfoResponse{ | ||
LabelSets: srv.getLabelSet(), | ||
ComponentType: srv.component, | ||
StoreInfo: srv.getStoreInfo(), | ||
ExemplarsInfo: srv.getExemplarsInfo(), | ||
}, nil | ||
} |
Oops, something went wrong.