Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to serialize a path and later on re-create it #354

@andrewzhurov

Description

@andrewzhurov

I'd like to allow users craft paths, such as user.blog.like() and capture it in JSON, to later on re-create path Proxy and execute on say another machine.
Any tips on how this can be done? @jblemee @rubensworks @RubenVerborgh
(this is not an issue, rather I'd like to know your thougths on it and did not know how to better contact for a discussion)

Motivation

My motivation behind it is to capture dispatched paths in a distributed event log, and playback that log, recreating RDF Store on peers. This way we'd have transactional guarantees, as peers that dispatch event end up with an eventually consistent state of the log and RDF Store consequently.
The architecture overall resembles that of Solid, only if a Solid Pod would contain not an RDF Store but event log.
Here is a sketch of this architecture (it refers to Clojure's re-frame in some places).
image

Current implementation details

Atm I'm trying to do so via a custom .dispatch() handler, that goes through pathData and outputs JSON, which I later on send to other users. This bit works fine, however I'm struggling to re-create the original path to execute on other users' side, I think I'll make it work in the end and thought maybe you can give some tips on how to best do it to ease the battle.:)

Atm I'm trying to re-create it via

const computeRDFStoreInner2 = async (events, rootPath) => {
  await events.map(async (arrayPath) => {
    const path = arrayPath.reduce(async (pathCurrentPromise, { property, args }) => {
      const pathCurrent = await pathCurrentPromise
      const newPathCurrent = await pathCurrent.get(property)
      const newPathCurrent2 = !args ? newPathCurrent : await newPathCurrent(args)
      return newPathCurrent2
    }, new Promise((resolve, reject) => resolve(rootPath)))
    await path
  })

  return null
}

Where events are captured as

[ [{property: "fov"}, {property: "set", args: [90]}] ]

That's been serialized on dispatch from db.fov.set(90).dispatch()

Aand it doesn't work, throwing

handler.handle(...) is not a function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions