Skip to content

chenpengfei/scuttlebutt-golang

Repository files navigation

Scuttlebutt Golang

Build Status Software License Coverage Status Go Report Card GolangCI GoDoc

尝试解决两个一致性问题

  1. 最终一致性问题中的 “最终结果同步”,用一个分布式 "HashMap" 解决
  2. “过程完全回放” 问题,用一个分布式 "Queue" 解决

Usage

a := model.NewSyncModel(sb.WithId("A"))
b := model.NewSyncModel(sb.WithId("B"))

sa := a.CreateStream(duplex.WithName("a->b"))
sb := b.CreateStream(duplex.WithName("b->a"))

a.Set("foo", "changed by A")

sb.On("synced", func(data interface{}) {
    PrintKeyValue(b, "foo")
})

duplex.Link(sa, sb)

Run

make run