-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
storeApi: add component information to gRPC's Info response (resolves #739) #750
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,87 @@ | ||||||||
package component | ||||||||
|
||||||||
import ( | ||||||||
"strings" | ||||||||
|
||||||||
"github.com/improbable-eng/thanos/pkg/store/storepb" | ||||||||
) | ||||||||
|
||||||||
// StoreAPI is a component that implements Thanos' gRPC StoreAPI. | ||||||||
type StoreAPI interface { | ||||||||
adrien-f marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Go wants comments like this for exported functions:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exaclty this ^ |
||||||||
implementsStoreAPI() | ||||||||
String() string | ||||||||
ToProto() storepb.StoreType | ||||||||
} | ||||||||
|
||||||||
// Source is a Thanos component that produce blocks of metrics. | ||||||||
type Source interface { | ||||||||
producesBlocks() | ||||||||
String() string | ||||||||
} | ||||||||
|
||||||||
// SourceStoreAPI is a component that implements Thanos' gRPC StoreAPI | ||||||||
// and produce blocks of metrics. | ||||||||
type SourceStoreAPI interface { | ||||||||
implementsStoreAPI() | ||||||||
producesBlocks() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, we could use embedding here. For example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I guess it will cause diamond problem as described here: https://joaodlf.com/go-the-diamond-problem.html (with |
||||||||
String() string | ||||||||
ToProto() storepb.StoreType | ||||||||
} | ||||||||
|
||||||||
type component struct { | ||||||||
name string | ||||||||
} | ||||||||
|
||||||||
func (c component) String() string { return c.name } | ||||||||
|
||||||||
type storeAPI struct { | ||||||||
component | ||||||||
} | ||||||||
|
||||||||
func (storeAPI) implementsStoreAPI() {} | ||||||||
|
||||||||
func (s sourceStoreAPI) ToProto() storepb.StoreType { | ||||||||
return storepb.StoreType(storepb.StoreType_value[strings.ToUpper(s.String())]) | ||||||||
} | ||||||||
|
||||||||
func (s storeAPI) ToProto() storepb.StoreType { | ||||||||
return storepb.StoreType(storepb.StoreType_value[strings.ToUpper(s.String())]) | ||||||||
} | ||||||||
|
||||||||
type source struct { | ||||||||
component | ||||||||
} | ||||||||
|
||||||||
func (source) producesBlocks() {} | ||||||||
|
||||||||
type sourceStoreAPI struct { | ||||||||
component | ||||||||
source | ||||||||
storeAPI | ||||||||
} | ||||||||
|
||||||||
// FromProto converts from a gRPC StoreType to StoreAPI. | ||||||||
func FromProto(storeType storepb.StoreType) StoreAPI { | ||||||||
switch storeType { | ||||||||
case storepb.StoreType_QUERY: | ||||||||
return Query | ||||||||
case storepb.StoreType_RULE: | ||||||||
return Rule | ||||||||
case storepb.StoreType_SIDECAR: | ||||||||
return Sidecar | ||||||||
case storepb.StoreType_STORE: | ||||||||
return Store | ||||||||
default: | ||||||||
return nil | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
var ( | ||||||||
Bucket = source{component: component{name: "bucket"}} | ||||||||
Compact = source{component: component{name: "compact"}} | ||||||||
Downsample = source{component: component{name: "downsample"}} | ||||||||
Query = sourceStoreAPI{component: component{name: "query"}} | ||||||||
Rule = sourceStoreAPI{component: component{name: "rule"}} | ||||||||
Sidecar = sourceStoreAPI{component: component{name: "sidecar"}} | ||||||||
Store = sourceStoreAPI{component: component{name: "store"}} | ||||||||
adrien-f marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - let's just put constant in place everywhere in sidecar - no point to dynamically eval this variable