Skip to content

Commit

Permalink
create storage.Purger interface
Browse files Browse the repository at this point in the history
Signed-off-by: Harshvir Potpose <hpotpose62@gmail.com>
  • Loading branch information
akagami-harsh committed Apr 22, 2024
1 parent a5a4e56 commit ee84793
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/jaeger/internal/integration/storagecleaner/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"go.opentelemetry.io/collector/extension"

"github.com/jaegertracing/jaeger/cmd/jaeger/internal/extension/jaegerstorage"
"github.com/jaegertracing/jaeger/plugin/storage/badger"
"github.com/jaegertracing/jaeger/storage"
)

var (
Expand Down Expand Up @@ -44,16 +44,16 @@ func (c *storageCleaner) Start(ctx context.Context, host component.Host) error {
return fmt.Errorf("cannot find storage factory for Badger: %w", err)
}

purgeBadger := func() error {
badgerFactory := storageFactory.(*badger.Factory)
if err := badgerFactory.Purge(); err != nil {
purgeStorage := func() error {
purger := storageFactory.(storage.Purger)
if err := purger.Purge(); err != nil {
return fmt.Errorf("error purging Badger storage: %w", err)
}
return nil
}

purgeHandler := func(w http.ResponseWriter, r *http.Request) {
if err := purgeBadger(); err != nil {
if err := purgeStorage(); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
Expand Down
1 change: 1 addition & 0 deletions plugin/storage/badger/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var ( // interface comformance checks
_ storage.Factory = (*Factory)(nil)
_ io.Closer = (*Factory)(nil)
_ plugin.Configurable = (*Factory)(nil)
_ storage.Purger = (*Factory)(nil)

// TODO badger could implement archive storage
// _ storage.ArchiveFactory = (*Factory)(nil)
Expand Down
6 changes: 6 additions & 0 deletions storage/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ type Factory interface {
CreateDependencyReader() (dependencystore.Reader, error)
}

// Purger defines an interface that is capable of purging the storage.
type Purger interface {
// Purge removes all data from the storage.
Purge() error
}

// SamplingStoreFactory defines an interface that is capable of returning the necessary backends for
// adaptive sampling.
type SamplingStoreFactory interface {
Expand Down

0 comments on commit ee84793

Please sign in to comment.