mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
refactor: extract fn to check whether collector or querier
This commit is contained in:
@@ -200,7 +200,7 @@ func NewAWSCollector(config AWSCollectorConfig) (AWSCollector, error) {
|
||||
}
|
||||
|
||||
// If given a StoreInterval we will be storing periodically; if not we only answer queries
|
||||
if config.StoreInterval != 0 {
|
||||
if c.isCollector() {
|
||||
c.ticker = time.NewTicker(config.StoreInterval)
|
||||
go c.flushLoop()
|
||||
}
|
||||
|
||||
@@ -42,11 +42,14 @@ func (c *awsCollector) addToLive(ctx context.Context, userid string, rep report.
|
||||
entry.Unlock()
|
||||
}
|
||||
|
||||
func (c *awsCollector) isCollector() bool {
|
||||
return c.cfg.StoreInterval != 0
|
||||
}
|
||||
|
||||
func (c *awsCollector) reportsFromLive(ctx context.Context, userid string) ([]report.Report, error) {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "reportsFromLive")
|
||||
defer span.Finish()
|
||||
if c.cfg.StoreInterval != 0 {
|
||||
// We are a collector
|
||||
if c.isCollector() {
|
||||
e, found := c.pending.Load(userid)
|
||||
if !found {
|
||||
return nil, nil
|
||||
|
||||
Reference in New Issue
Block a user