Skip to content

Commit

Permalink
comment updated
Browse files Browse the repository at this point in the history
Signed-off-by: Pushkar Mishra <pushkarmishra029@gmail.com>
  • Loading branch information
Pushkarm029 committed May 15, 2024
1 parent b417348 commit d5b2bed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
14 changes: 3 additions & 11 deletions plugin/sampling/strategystore/adaptive/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func newPostAggregator(
}, nil
}

// GetSamplingStrategy implements Thrift endpoint for retrieving sampling strategy for a service.
// GetSamplingStrategy implements protobuf endpoint for retrieving sampling strategy for a service.
func (ss *StrategyStore) GetSamplingStrategy(_ context.Context, service string) (*api_v2.SamplingStrategyResponse, error) {
ss.RLock()
defer ss.RUnlock()
Expand All @@ -150,7 +150,7 @@ func (ss *StrategyStore) GetSamplingStrategy(_ context.Context, service string)
return ss.generateDefaultSamplingStrategyResponse(), nil
}

// Start initializes and starts the sampling processor which regularly calculates sampling probabilities.
// Start initializes and starts the PostAggregator which regularly calculates sampling probabilities.
func (p *PostAggregator) Start() error {
p.logger.Info("starting adaptive sampling processor")
if err := p.electionParticipant.Start(); err != nil {
Expand All @@ -168,15 +168,7 @@ func (p *PostAggregator) runBackground(f func()) {
}()
}

func (ss *StrategyStore) runBackground(f func()) {
ss.bgFinished.Add(1)
go func() {
f()
ss.bgFinished.Done()
}()
}

// Close stops the processor from calculating probabilities.
// Close stops the PostAggregator from calculating probabilities.
func (p *PostAggregator) Close() error {
p.logger.Info("stopping adaptive sampling processor")
err := p.electionParticipant.Close()
Expand Down
19 changes: 13 additions & 6 deletions plugin/sampling/strategystore/adaptive/strategy_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ type StrategyStore struct {
// probabilities contains the latest calculated sampling probabilities for service operations.
probabilities model.ServiceOperationProbabilities

// strategyResponses is the cache of the sampling strategies for every service, in Thrift format.
// TODO change this to work with protobuf model instead, to support gRPC endpoint.
// strategyResponses is the cache of the sampling strategies for every service, in protobuf format.
strategyResponses map[string]*api_v2.SamplingStrategyResponse

// followerRefreshInterval determines how often the follower processor updates its probabilities.
Expand All @@ -65,9 +64,9 @@ func NewStrategyStore(options Options, logger *zap.Logger, participant leaderele
}, nil
}

// Start initializes and starts the sampling processor which regularly calculates sampling probabilities.
// Start initializes and starts the sampling service which regularly loads sampling probabilities and generates strategies.
func (ss *StrategyStore) Start() error {
ss.logger.Info("starting adaptive sampling processor")
ss.logger.Info("starting adaptive sampling service")
if err := ss.electionParticipant.Start(); err != nil {
return err
}
Expand All @@ -78,13 +77,21 @@ func (ss *StrategyStore) Start() error {
return nil
}

// Close stops the processor from calculating probabilities.
// Close stops the service from loading probabilities and generating strategies.
func (ss *StrategyStore) Close() error {
ss.logger.Info("stopping adaptive sampling processor")
ss.logger.Info("stopping adaptive sampling service")
err := ss.electionParticipant.Close()
if ss.shutdown != nil {
close(ss.shutdown)
}
ss.bgFinished.Wait()
return err
}

func (ss *StrategyStore) runBackground(f func()) {
ss.bgFinished.Add(1)
go func() {
f()
ss.bgFinished.Done()
}()
}

0 comments on commit d5b2bed

Please sign in to comment.