Skip to content

Latest commit

 

History

History
200 lines (160 loc) · 4.15 KB

index.rst

File metadata and controls

200 lines (160 loc) · 4.15 KB

Zenoh API Reference

[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.

Quick start examples:

Publish a key/value pair onto Zenoh

>>> import zenoh >>> z = zenoh.open() >>> z.put('demo/example/hello', 'Hello World!')

Subscribe to a set of keys with Zenoh

>>> 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()

Get keys/values from zenoh

>>> 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')}")

module zenoh

zenoh

Hello

zenoh.Hello

Config

zenoh.Config

Session

zenoh.Session

Info

zenoh.Info

KeyExpr

zenoh.KeyExpr

Sample

zenoh.Sample

SampleKind

zenoh.SampleKind

Value

zenoh.Value

Encoding

zenoh.Encoding

Publisher

zenoh.Publisher

CongestionControl

zenoh.CongestionControl

Priority

zenoh.Priority

Subscriber

zenoh.Subscriber

PullSubscriber

zenoh.PullSubscriber

Reliability

zenoh.Reliability

Query

zenoh.Query

Selector

zenoh.Selector

QueryTarget

zenoh.QueryTarget

QueryConsolidation

zenoh.QueryConsolidation

Reply

zenoh.Reply

Queryable

zenoh.Queryable

ZenohId

zenoh.ZenohId

Timestamp

zenoh.Timestamp

zenoh