Skip to content
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

refactor(cache): Deprecate namespace parameter in decorators #31079

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zharinov
Copy link
Collaborator

@zharinov zharinov commented Aug 28, 2024

Changes

This PR deprecates usage of cache namespace for decorators, using the default one (equals the class name).

We could then remove namespace paramter per-datasource. Since the default namespace is different, it leads to cache reset.

The alternative is to apply class name transformation, e.g. FooBarDatasource to datasource-foo-bar, but maybe it's easier to just gradually move to new namespaces.

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

lib/util/cache/package/decorator.ts Show resolved Hide resolved
@zharinov zharinov changed the title refactor(cache): Make the namespace optional for the decorator refactor(cache): Make the namespace parameter optional in decorators Aug 28, 2024
@zharinov zharinov changed the title refactor(cache): Make the namespace parameter optional in decorators refactor(cache): Deprecate namespace parameter in decorators Aug 28, 2024
function getClassName(instance: unknown): string | undefined {
// istanbul ignore if: should never happen
if (!is.object(instance)) {
return undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should throw if it's happening. undefined is a bad namespace.

or at least log a stack trace at debug level to see how it happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants