-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
📝 [v3 Proposal]: Improve Storage Interface #2839
Comments
CurrentLines 43 to 63 in 847a4a9
|
related #2300 we should then continue |
i like the first idea // Storage defines the base storage interface.
type StorageV2 interface { // `V2` this allows us to differentiate between old and new interfaces and support at least the last 3, so that we have the possibility to make further adjustments in the future
Get(key string) ([]byte, error)
Set(key string, val []byte, exp time.Duration) error
Delete(key string) error
Reset() error
Close() error
WithContext() ContextAwareStorage // Methode, gives the ContextAwareStorage-Interface
}
// ContextAwareStorage defines the storage interface with context-aware methods.
type ContextAwareStorage interface {
Get(ctx context.Context, key string) ([]byte, error)
Set(ctx context.Context, key string, val []byte, exp time.Duration) error
Delete(ctx context.Context, key string) error
Reset(ctx context.Context) error
Close(ctx context.Context) error
} but maybe we don't need the old methods anymore 2nd idea |
I feel like having a version that doesn't take a context is redundant because people can just pass |
The benefit here would be more than just the ability to cancel. I'm trying to add open telemetry tracing to my redis storage, but I can't pass the context, so it's not aware of its trace parent. The redis client just has hardcoded |
Feature Proposal Description
Idea One
Storage interface doesn't allow us to pass context to make operations cancellable. We should add new methods to allow context operations. Something like:
Idea Two
We can allow using generics to change key and value types.
Alignment with Express API
Express does not have storage interface.
HTTP RFC Standards Compliance
Not related to core.
API Stability
Not related to core.
Feature Examples
Checklist:
The text was updated successfully, but these errors were encountered: