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

POC for persistable state service. #63085

Closed
wants to merge 1 commit into from

Conversation

lukeelmers
Copy link
Member

@lukeelmers lukeelmers commented Apr 9, 2020

Prior art: #57496

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

id,
isDeprecated: !!isDeprecated,
extractReferences: extractReferences || identity,
injectReferences: injectReferences || noop,
Copy link
Member

Choose a reason for hiding this comment

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

all of them should have default implementation, that does nothing and all of them should not modify the object passed in (so injectReferences should also have identity rather that noop?)

const definition = this.definitions.get(id);

if (!definition) {
throw new Error(
Copy link
Member

Choose a reason for hiding this comment

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

should we really throw here or just return undefined ?

attributes: SavedObjectAttributes;
references: SavedObjectReference[];
}
type ExtractReferences = (opts: SavedObjectWithReferences) => SavedObjectWithReferences;
Copy link
Member

Choose a reason for hiding this comment

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

should return saved object + reference array

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need attributes in addition to the reference array? For something like Expressions, that aren't backed by a saved object, what would attributes be?

references: SavedObjectReference[];
}
type ExtractReferences = (opts: SavedObjectWithReferences) => SavedObjectWithReferences;
type InjectReferences = (opts: SavedObjectWithReferences) => void;
Copy link
Member

Choose a reason for hiding this comment

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

should accept saved object + array of reference and return new object with injected references

import { SavedObjectAttributes, SavedObjectReference } from 'src/core/public';

export interface PersistableState<
S extends SavedObjectAttributes,
Copy link
Member

Choose a reason for hiding this comment

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

maybe this should not be refering to savedObjectAttributes ? there might be no saved object asociated with that state, for example saved visualization contains filters (which belong to data plugin, but are not saved on their own)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I agree this is misleading. I used SavedObjectAttributes as a convenience because the type essentially allows for any serializable json, but should probably re-write the correct interface here to avoid confusion

MS extends SavedObjectAttributes | undefined = undefined
> {
state: S;
migratedId?: I;
Copy link
Member

Choose a reason for hiding this comment

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

whats the migratedId ?

@stacey-gammon
Copy link
Contributor

I woke up this morning thinking about a use case that might put a wrench in this whole "use the id in place of the version number" scheme.

We say today that it's only possibly for the owner of a saved object to migrate that saved object, but we do have an out. It's possible for us to write code to migrate every saved object. It's what security is going to do to migrate ids.

We don't have that possibility if we use ids as the version numbers. Due to how flexible EmbeddableInput is, we could encounter this more. For example:

  • I want to change title on EmbeddableInput to customPanelTitle
  • Drilldowns feature branch added enhancements to EmbeddableInput on which it's going to store events. What happens when we need to migrate serialized action data stored on events.. Embeddables don't even know about this data, only drilldowns does. How do we migrate it if we base this off the id? We can't change the id of other people's registered embeddables.

@stacey-gammon
Copy link
Contributor

Filed my thoughts more formally here: #63358

@ppisljar ppisljar mentioned this pull request Apr 14, 2020
7 tasks
@lukeelmers
Copy link
Member Author

closing in favor of #63451

@lukeelmers lukeelmers closed this Apr 14, 2020
@lukeelmers lukeelmers deleted the poc/state-migration branch April 14, 2020 19:28
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.

4 participants