[Zenoh](https://zenoh.io) /zeno/ is a stack that unifies data in motion, data at rest and computations. It elegantly blends traditional pub/sub with geo distributed storage, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.
Before delving into the examples, we need to introduce few Zenoh concepts. First off, in Zenoh you will deal with Resources, where a resource is made up of a key and a value. The other concept you'll have to familiarize yourself with are key expressions, such as robot/sensor/temp
, robot/sensor/*
, robot/**
, etc. As you can gather, the above key expression denotes set of keys, while the *
and **
are wildcards representing respectively (1) a single chunk (non-empty sequence of characters that doesn't contain /
), and (2) any amount of chunks (including 0).
Below are some examples that highlight these key concepts and show how easy it is to get started with.
>>> import zenoh >>> z = zenoh.open() >>> z.put('demo/example/hello', 'Hello World!')
>>> import zenoh, time >>> def listener(sample): >>> print(f"{sample.key_expr} => {sample.payload.decode('utf-8')}") >>> >>> z = zenoh.open() >>> subscriber = z.subscribe('demo/example/**', listener) >>> time.sleep(60) >>> subscriber.undeclare()
>>> import zenoh >>> z = zenoh.open() >>> for response in z.get('demo/example/**', zenoh.Queue()): >>> response = response.ok >>> print(f"{response.key_expr} => {response.payload.decode('utf-8')}")
zenoh
zenoh.Hello
zenoh.Config
zenoh.Session
zenoh.Info
zenoh.KeyExpr
zenoh.Sample
zenoh.SampleKind
zenoh.Value
zenoh.Encoding
zenoh.Publisher
zenoh.CongestionControl
zenoh.Priority
zenoh.Subscriber
zenoh.PullSubscriber
zenoh.Reliability
zenoh.Query
zenoh.Selector
zenoh.QueryTarget
zenoh.QueryConsolidation
zenoh.Reply
zenoh.Queryable
zenoh.ZenohId
zenoh.Timestamp
zenoh