Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(protocol-changes): adapt API with protocol changes. #179

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,228 changes: 708 additions & 520 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ name = "zenoh"
crate-type = ["cdylib"]

[features]
complete_n = ["zenoh/complete_n"]
default = ["zenoh/default"]

[badges]
maintenance = { status = "actively-developed" }

[dependencies]
env_logger = "0.10.0"
env_logger = "0.11.3"
flume = "0.11.0"
json5 = "0.4.1"
pyo3 = { version = "0.18.1", features = ["extension-module", "abi3-py37"] }
uhlc = "0.6.0"
pyo3 = { version = "0.21.1", features = ["extension-module", "abi3-py37"] }
uhlc = "0.7.0"
validated_struct = "2.1.0"
zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = ["unstable"], default-features = false }
zenoh-buffers = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
zenoh-core = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main" }
zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "protocol_changes", features = ["unstable"], default-features = false }
zenoh-buffers = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "protocol_changes" }
zenoh-core = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "protocol_changes" }
5 changes: 0 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ Subscriber
.. autoclass:: zenoh.Subscriber
:members:

PullSubscriber
--------------
.. autoclass:: zenoh.PullSubscriber
:members:

Reliability
-----------
.. autoclass:: zenoh.Reliability
Expand Down
127 changes: 66 additions & 61 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,153 +6,158 @@
python3 <example.py>
```

Each example accepts the `-h` or `--help` option that provides a description of its arguments and their default values.
Each example accepts the `-h` or `--help` option that provides a description of its arguments and their default values.

If you run the tests against the zenoh router running in a Docker container, you need to add the
`-e tcp/localhost:7447` option to your examples. That's because Docker doesn't support UDP multicast
transport, and therefore the zenoh scouting and discrovery mechanism cannot work with.
If you run the tests against the zenoh router running in a Docker container, you need to add the
`-e tcp/localhost:7447` option to your examples. That's because Docker doesn't support UDP multicast
transport, and therefore the zenoh scouting and discrovery mechanism cannot work with.

## Examples description

### z_scout

Scouts for zenoh peers and routers available on the network.
Scouts for zenoh peers and routers available on the network.

Typical usage:

Typical usage:
```bash
python3 z_scout.py
```

### z_info

Gets information about the Zenoh session.
Gets information about the Zenoh session.

Typical usage:

Typical usage:
```bash
python3 z_info.py
```


### z_put

Puts a path/value into Zenoh.
The path/value will be received by all matching subscribers, for instance the [z_sub](#z_sub)
and [z_storage](#z_storage) examples.
Puts a path/value into Zenoh.
The path/value will be received by all matching subscribers, for instance the [z_sub](#z_sub)
and [z_storage](#z_storage) examples.

Typical usage:

Typical usage:
```bash
python3 z_put.py
```
or

or

```bash
python3 z_put.py -k demo/example/test -v 'Hello World'
```

### z_pub

Declares a resource with a path and a publisher on this resource. Then puts a value using the numerical resource id.
The path/value will be received by all matching subscribers, for instance the [z_sub](#z_sub)
and [z_storage](#z_storage) examples.
Declares a resource with a path and a publisher on this resource. Then puts a value using the numerical resource id.
The path/value will be received by all matching subscribers, for instance the [z_sub](#z_sub)
and [z_storage](#z_storage) examples.

Typical usage:

Typical usage:
```bash
python3 z_pub.py
```
or

or

```bash
python3 z_pub.py -k demo/example/test -v 'Hello World'
```

### z_sub

Creates a subscriber with a key expression.
The subscriber will be notified of each put made on any key expression matching
the subscriber's key expression, and will print this notification.
Creates a subscriber with a key expression.
The subscriber will be notified of each put made on any key expression matching
the subscriber's key expression, and will print this notification.

Typical usage:

Typical usage:
```bash
python3 z_sub.py
```
or
```bash
python3 z_sub.py -k 'demo/**'
```

### z_pull

Creates a pull subscriber with a selector.
The pull subscriber will receive each put made on any key expression matching
the subscriber's key expression and will pull on demand and print the received
key/value.
or

Typical usage:
```bash
python3 z_pull.py
```
or
```bash
python3 z_pull.py -k 'demo/**'
python3 z_sub.py -k 'demo/**'
```

### z_get

Sends a query message for a selector.
The queryables with a matching path or selector (for instance [z_queryable](#z_queryable) and [z_storage](#z_storage))
will receive this query and reply with paths/values that will be received by the query callback.
Sends a query message for a selector.
The queryables with a matching path or selector (for instance [z_queryable](#z_queryable) and [z_storage](#z_storage))
will receive this query and reply with paths/values that will be received by the query callback.

Typical usage:

Typical usage:
```bash
python3 z_get.py
```
or

or

```bash
python3 z_get.py -s 'demo/**'
```

### z_queryable

Creates a queryable function with a key expression.
This queryable function will be triggered by each call to a get operation on zenoh
with a selector that matches the key expression, and will return a value to the querier.
Creates a queryable function with a key expression.
This queryable function will be triggered by each call to a get operation on zenoh
with a selector that matches the key expression, and will return a value to the querier.

Typical usage:

Typical usage:
```bash
python3 z_queryable.py
```
or

or

```bash
python3 z_queryable.py -k demo/example/queryable -v 'This is the result'
```

### z_storage

Trivial implementation of a storage in memory.
This examples creates a subscriber and a queryable on the same key expression.
The subscriber callback will store the received key/values in an hashmap.
The queryable callback will answer to queries with the key/values stored in the hashmap
and that match the queried selector.
Trivial implementation of a storage in memory.
This examples creates a subscriber and a queryable on the same key expression.
The subscriber callback will store the received key/values in an hashmap.
The queryable callback will answer to queries with the key/values stored in the hashmap
and that match the queried selector.

Typical usage:

Typical usage:
```bash
python3 z_storage.py
```
or

or

```bash
python3 z_storage.py -k 'demo/**'
```

### z_pub_thr & z_sub_thr

Pub/Sub throughput test.
This example allows to perform throughput measurements between a pubisher performing
put operations and a subscriber receiving notifications of those puts.
Pub/Sub throughput test.
This example allows to perform throughput measurements between a pubisher performing
put operations and a subscriber receiving notifications of those puts.

Typical Subscriber usage:

Typical Subscriber usage:
```bash
python3 z_sub_thr.py
```

Typical Publisher usage:
Typical Publisher usage:

```bash
python3 z_pub_thr.py 1024
```
4 changes: 2 additions & 2 deletions examples/z_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import argparse
import json
import zenoh
from zenoh import config, QueryTarget
from zenoh import config, QueryTarget, into_payload

# --- Command line argument parsing --- --- --- --- --- ---
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -79,7 +79,7 @@ def main():
session = zenoh.open(conf)

print("Sending Query '{}'...".format(selector))
replies = session.get(selector, zenoh.Queue(), target=target, value=args.value, consolidation=zenoh.QueryConsolidation.NONE())
replies = session.get(selector, zenoh.Queue(), target=target, payload=into_payload(args.value), consolidation=zenoh.QueryConsolidation.NONE())
for reply in replies.receiver:
try:
print(">> Received ('{}': '{}')"
Expand Down
5 changes: 2 additions & 3 deletions examples/z_pub_thr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import argparse
import json
import zenoh
from zenoh import config, CongestionControl, Value
from zenoh import config, CongestionControl

# --- Command line argument parsing --- --- --- --- --- ---
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -63,14 +63,13 @@ def main():
data = bytearray()
for i in range(0, size):
data.append(i % 10)
data = Value(bytes(data))
congestion_control = CongestionControl.BLOCK()

session = zenoh.open(conf)
pub = session.declare_publisher('test/thr', congestion_control=congestion_control)

print("Press CTRL-C to quit...")
while True:
pub.put(data)
pub.put(bytes(data))

main()
88 changes: 0 additions & 88 deletions examples/z_pull.py

This file was deleted.

2 changes: 1 addition & 1 deletion examples/z_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import argparse
import json
import zenoh
from zenoh import config, Value
from zenoh import config

# --- Command line argument parsing --- --- --- --- --- ---
parser = argparse.ArgumentParser(
Expand Down
Loading