Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions proxy-service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ func (s Service) Evaluations(ctx context.Context, req domain.EvaluationsRequest)
target, err := s.targetRepo.GetByIdentifier(ctx, targetKey, req.TargetIdentifier)
if err != nil {
if errors.Is(err, domain.ErrCacheNotFound) {
s.logger.Error(ctx, "target not found in cache: ", "err", err.Error())
return nil, fmt.Errorf("%w: %s", ErrNotFound, err)
}
s.logger.Error(ctx, "error fetching target: ", "err", err.Error())
return []clientgen.Evaluation{}, fmt.Errorf("%w: %s", ErrInternal, err)
}

Expand Down Expand Up @@ -365,21 +367,24 @@ func (s Service) EvaluationsByFeature(ctx context.Context, req domain.Evaluation
return clientgen.Evaluation{}, ErrInternal
}

// fetch segment
// fetch segments
segments, err := s.segmentRepo.GetAsMap(ctx, segmentKey)
if err != nil {
if errors.Is(err, domain.ErrCacheNotFound) {
return clientgen.Evaluation{}, fmt.Errorf("%w: %s", ErrNotFound, err)
if !errors.Is(err, domain.ErrCacheNotFound) {
return clientgen.Evaluation{}, fmt.Errorf("%w: %s", ErrInternal, err)
}
return clientgen.Evaluation{}, fmt.Errorf("%w: %s", ErrInternal, err)
// segments aren't required so just log and continue here
s.logger.Info(ctx, "target segments not found in cache: ", "err", err.Error())
}

// fetch target
target, err := s.targetRepo.GetByIdentifier(ctx, targetKey, req.TargetIdentifier)
if err != nil {
if errors.Is(err, domain.ErrCacheNotFound) {
s.logger.Error(ctx, "target not found in cache: ", "err", err.Error())
return clientgen.Evaluation{}, fmt.Errorf("%w: %s", ErrNotFound, err)
}
s.logger.Error(ctx, "error fetching target: ", "err", err.Error())
return clientgen.Evaluation{}, fmt.Errorf("%w: %s", ErrInternal, err)
}

Expand Down