Note
asyncmachine-go is a declarative control flow library implementing AOP and Actor Model through a clock-based state machine.
/pkg/pubsub is a trustful decentralized synchronization network for asyncmachine-go. Each peer exposes several state
machines, then starts gossiping about them and other ones known to him. Remote state machines are then visible to other
peers as /pkg/rpc.LocalWorker
. PubSub can be used to match Clients with Workers from /pkg/node.
Under the hood it's based on libp2p gossipsub, which is a mesh-based PubSub, also based on gossipping, but for the purpose of network topology. libp2p gossips are separate from gossips of this package.
- state checking YES
- state mutations NO
- state waiting YES
- gossip-based discovery
- gossip-based clock updates
- gossip-based checksums via machine time
- rate limitting
- no leaders, no elections
am-dbg view of a PubSub with 6 peers, with p1-p5 exposing a single state machine each.
State schema from /pkg/pubsub/states/.
- more rate limitting
- confirmed handler timeouts
- faster discovery
- load test
- mDNS & DHT & auth
- optimizations
- documentation
- discovery protocol
- sequence diagrams
import (
ma "github.com/multiformats/go-multiaddr"
ampubsub "github.com/pancsta/asyncmachine-go/pkg/pubsub"
)
// ...
// init a pubsub peer
ps, _ := ampubsub.NewTopic(ctx, t.Name(), name, machs, nil)
// prep a libp2p multi address
a, _ := ma.NewMultiaddr("/ip4/127.0.0.1/udp/75343/quic-v1")
addrs := []ma.Multiaddr{a}
ps.ConnAddrs = addrs
ps.Start()
<-ps.Mach.When1(ss.Connected, ctx)
ps.Mach.Add1()
Alpha, work in progress, not semantically versioned.
Go back to the monorepo root to continue reading.