-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[storage] Remove usages of jaegerstorage.GetStorageFactory #6624
Changes from all commits
1d43f01
7c22a4b
2fe5157
8b0bc9a
25772a0
d3bcf8d
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 |
---|---|---|
|
@@ -5,13 +5,21 @@ | |
|
||
import ( | ||
"context" | ||
"errors" | ||
"io" | ||
|
||
"github.com/jaegertracing/jaeger/pkg/distributedlock" | ||
storage_v1 "github.com/jaegertracing/jaeger/storage" | ||
"github.com/jaegertracing/jaeger/storage/samplingstore" | ||
"github.com/jaegertracing/jaeger/storage_v2/depstore" | ||
"github.com/jaegertracing/jaeger/storage_v2/tracestore" | ||
) | ||
|
||
var ( | ||
ErrPurgerNotImplemented = errors.New("storage backend does not support Purger") | ||
ErrSamplingStoreNotImplemented = errors.New("storage backend does not support sampling store") | ||
) | ||
|
||
type Factory struct { | ||
ss storage_v1.Factory | ||
} | ||
|
@@ -61,3 +69,33 @@ | |
} | ||
return NewDependencyReader(dr), nil | ||
} | ||
|
||
// CreateLock implements storage_v1.SamplingStoreFactory | ||
func (f *Factory) CreateLock() (distributedlock.Lock, error) { | ||
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. @yurishkuro This approach works but there's a slight change in behaviour. Consider the following:
I don't see a huge downside to doing it this way except maybe a slightly different/confusing error message. We could mitigate that by returning a specific error here that we check for upstream and return the same error message as before. What do you think? The other approach would be to only construct the factory adapter based on the interfaces the underlying factory implements. 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. As long as we fail during startup, as opposed to later when processing incoming data, it should be fine. 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.
I've changed the error checking to something along the lines of this. Please have a look. |
||
ss, ok := f.ss.(storage_v1.SamplingStoreFactory) | ||
if !ok { | ||
return nil, ErrSamplingStoreNotImplemented | ||
} | ||
lock, err := ss.CreateLock() | ||
return lock, err | ||
} | ||
|
||
// CreateSamplingStore implements storage_v1.SamplingStoreFactory | ||
func (f *Factory) CreateSamplingStore(maxBuckets int) (samplingstore.Store, error) { | ||
ss, ok := f.ss.(storage_v1.SamplingStoreFactory) | ||
if !ok { | ||
return nil, ErrSamplingStoreNotImplemented | ||
} | ||
store, err := ss.CreateSamplingStore(maxBuckets) | ||
return store, err | ||
} | ||
|
||
// Purge implements storage_v1.Purger | ||
func (f *Factory) Purge(ctx context.Context) error { | ||
p, ok := f.ss.(storage_v1.Purger) | ||
if !ok { | ||
return ErrPurgerNotImplemented | ||
} | ||
err := p.Purge(ctx) | ||
return err | ||
} |
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.
it doesn't make sense to be checking an error from v1adapter here. We need storage_v2 APIs to be self-sufficient. I would recommend moving Sampling/Lock/Purger APIs to storage_v2 and replacing them with type aliases in v1 storage (it should be a separate PR before this one).
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.
I'm a bit confused, wouldn't we still need to check for the casting error in the adapter to return an error like
storage %s does not implement Purger interface
with the correct storage_name that is used?Should each of these APIs be in a different module in storage_v2, in a similar way DependencyStore has been moved to
storage_v2/depstore
? Or should they be defined in thestorage_v2/tracestore
? What do you think?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.
in the adapter you can check anything you want, but the extension code should not be dependent on adapter package.
Yes, follow the existing pattern.
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.
Got it, thanks! Closing this PR now to work on moving the APIs to v2.