Skip to content

Investigate how to simplify DataAccessorBasedStore #998

Open

Description

@jvherweg

DataAccessorBasedStore is the store responsible for the "main" Solid behaviour of resources on CRUD requests. The main issue is that this class does a lot, and only works with DataAccessors. Questions is if/how we can split up some of this behaviour and allow for easier reuse, without losing the interactions that are required.

Some options:

  1. Move most of the behaviour to a SolidBehaviourStore and let DataAccessorBasedStore be a very simple store. Issue is that this might be less efficient since there no longer is any direct access to the DataAccessors. This might be mostly ok if the stores are configured so they are completely at the end of the store chain.
  2. Move part of the behaviour to utility functions.
  3. Have different components for each of the store functions and then have 1 store that aggregates them.

Activity

  1. added
    ☀️ enhancement
    on Oct 14, 2021
  2. changed the title [-]Investiage how to simplify DataAccessorBasedStore[/-] [+]Investigate how to simplify DataAccessorBasedStore[/+] on Oct 14, 2021
  3. RubenVerborgh commented on Oct 18, 2021

    @RubenVerborgh
    Member

    I'm leaning towards 3; the goal not being simplification to me, but rather compartmentalization of knowledge and hence better reusability for components that want to implement new backends.
    DataAccessorBasedStore just knows too much at the moment.

    Another (additional) option is that we make DataAccessor the de-factor default interface for implementing back-ends, and then projects such as https://github.com/RubenVerborgh/solid-hue should start from an accessor rather than a store. It should be crucial that this does not make their code more complex, but rather simplifies it then.

  4. jvherweg commented on Oct 19, 2021

    @jvherweg
    MemberAuthor

    Another (additional) option is that we make DataAccessor the de-factor default interface for implementing back-ends

    I would say that is already the case, when adding a new backend it's easiest to create a new DataAccessor, if you want to have full Solid behaviour on your backend (GET/PUT/POST/DELETE, containers, etc.). It's been a while but I think for the hue case not all of that was wanted? Or maybe we didn't even have data accessors then, it's been a while.

  5. RubenVerborgh commented on Oct 19, 2021

    @RubenVerborgh
    Member

    Or maybe we didn't even have data accessors then, it's been a while.

    We might not have; I do recall simplifying the CSS API a bit (implementing common helpers) as I was writing the Hue code.
    I should rewrite https://github.com/RubenVerborgh/solid-hue/blob/main/src/PhilipsHueStore.ts as an accessor and see if the same is needed.

  6. jvherweg commented on Nov 4, 2022

    @jvherweg
    MemberAuthor

    Some ideas that followed from each other.

    One thing we can do is not support the addResource function in the DataAccessorBasedStore. A previous store should interpret such a request and transform it into a setRepresentation. That way everything related to generating a valid identifier is moved out and we have a ResourceStore specifically for POST requests, just like we do for PATCH requests. This would also allow us to solve #288 if this store came before the converting store.

    One issue with the above, and probably other suggestions if we split them over multiple stores, is that the same data will be requested multiple times. This is one of the reasons a lot is done in the DataAccessorBasedStore: direct access to the DataAccessor, and reuse of the same objects. The main object that often gets reused is the metadata though, so we could have a CachedResourceStore that caches the metadata, similar to the CachedResourceSet (it could extend that one even). Besides that we would also have to add a getMetadata function to the ResourceStore interface as otherwise we would still always have to request the data stream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ☀️ enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions