8000 Read only stream? · Issue #24 · dominictarr/crdt · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Read only stream? #24

Open
Open

Description

@mbrevoort

Is there as way to create a read-only stream between two documents? So if you have document A and B, A stream updates to B but B doesn't send updates to A. Instead B is thought to be read-only.

I've tried to not pipe the B stream back to A but this resulted in B not getting all of the existing state from A:

A.createStream()
  .pipe(B.createStream());

Is there a way to do this currently?

Activity

  1. juliangruber commented on Jul 9, 2013

    @juliangruber

    you could write a scuttlebutt subclass that only accepts changes from the scuttlebutt that has been piped to it, then you can do:

    A.createStream().pipe(oneWay()).pipe(B.createStream());
  2. Raynos commented on Jul 9, 2013

    @Raynos
    Contributor

    x.createStream({ writable: false })

  3. mbrevoort commented on Jul 9, 2013

    @mbrevoort
    CollaboratorAuthor

    @Raynos oh man, that just made my day :)

  4. juliangruber commented on Jul 9, 2013

    @juliangruber

    every scuttlebutt would get that, right? then I think that's the better solution. oh, is that already in scuttlebutt?

  5. Raynos commented on Jul 9, 2013

    @Raynos
    Contributor

    every scuttlebutt has createStream({ writable: Boolean, readable: Boolean })

  6. Raynos commented on Jul 9, 2013

    @Raynos
    Contributor

    Both default to true

  7. dominictarr commented on Jul 9, 2013

    @dominictarr
    Owner

    oh, hmm. that feature was intended for persistance - using it that way will work,
    but will just resend old data, instead of only sending new data.
    You really want to still send the vector clock hand shake,

    okay, I just added a sendClock option.

    now, you can create a scuttlebutt stream that will emit updates, but not send them,
    like this:

    var s1 = master.createStream({writable: false, sendClock: true})
    var s2 = slave.createStream({readable: false, sendClock: true})

    just added this in scuttlebutt 5.6, update any subclass and you should get that.

  8. mbrevoort commented on Jul 10, 2013

    @mbrevoort
    CollaboratorAuthor

    @dominictarr that's excellent, thanks!

    What does setting the slave stream to readable: false do? Does it prevent that stream from propagating changes down stream? So if you just set the master as writable: false and didn't set the slave as readable: false, the slave stream would still send changes over the wire to the master but the master would just ignore them? Is that the intention?

  9. dominictarr commented on Jul 10, 2013

    @dominictarr
    Owner

    readable: false tells it not to emit any updates after the vector clock.
    So you probably don't need that, but it will stop it spamming if you are also setting properties on it locally.

    note that this is a setting on the stream - you can have a pair that is master(a) -> slave(b), but have still have master(a) <-> master(c) or even master(a) -> slave(b); master(c) -> slave(b). setting readable: false on b's streams prevent it from sending update received from another master(c) back to master(a), etc.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0