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

0.2.0 is developed!! #12

Merged
merged 170 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 133 commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
9f319af
Start 0.2.0-dev
pojiro Jan 18, 2024
f71ddf9
Remove useless test
pojiro Jan 18, 2024
5f70339
Add native/zenohex_nif by `mix rustler.new`
pojiro Jan 18, 2024
dd16c80
Add sample nif.ex and nif_test.exs
pojiro Jan 18, 2024
5ccc6f3
Add .github/workflows/ci.yaml
pojiro Jan 19, 2024
4a469a7
[zenohex_nif] Add zenoh to native/zenohex_nif by `cargo add zenoh`
pojiro Jan 19, 2024
1851d6b
Add mix_test_watch to deps
pojiro Jan 21, 2024
93b1c98
[zenohex_nif] Add sample impl
pojiro Jan 19, 2024
9aa7119
[zenohex_nif] Remove unwrap
pojiro Jan 21, 2024
50be07d
[zenohex_nif] Update header
pojiro Jan 21, 2024
964a232
[zenohex_nif] Add publisher_put_(string|integer|float)
pojiro Jan 21, 2024
814bb18
[zenohex_nif] Add to_term/2 to lib.rs
pojiro Jan 22, 2024
f848eb9
[zenohex_nif] Support binary pub/sub
pojiro Jan 22, 2024
e8ec5c7
[zenohex_nif] Replcace todo! with unimplemented!
pojiro Jan 22, 2024
fa7045c
[zenohex_nif] Refactor lib.rs error handling
pojiro Jan 23, 2024
6b7d22f
[zenohex_nif] Add publisher functions
pojiro Jan 23, 2024
bc3eb29
[zenohex_nif] Remove publisher_put_string
pojiro Jan 23, 2024
c3c18c9
[zenohex_nif] Add declare_subscriber/3
pojiro Jan 23, 2024
aa7de11
[zenohex_nif] Add pull subscriber
pojiro Jan 23, 2024
212667f
[zenohex_nif] Add declare_queryable/2,3
pojiro Jan 23, 2024
1763948
[zenohex_nif] Add session functions
pojiro Jan 23, 2024
66ae5a9
[zenohex_nif] Improve PublisherOptions
pojiro Jan 25, 2024
45e13fc
[zenohex_nif] Improve SubscriberOptions
pojiro Jan 25, 2024
3501b39
[zenohex_nif] Improve QueryableOptions
pojiro Jan 25, 2024
b94628b
[zenohex_nif] Add publisher mod
pojiro Jan 26, 2024
e66c82e
[zenohex_nif] Add subscriber mod
pojiro Jan 26, 2024
721a936
[zenohex_nif] Add pull_subscriber mod
pojiro Jan 26, 2024
3c4834c
[zenohex_nif] Add queryable mod
pojiro Jan 26, 2024
f14f750
[zenohex_nif] Add session mod
pojiro Jan 26, 2024
ec73c38
[zenohex_nif] Reorder rustler::init! funcs
pojiro Jan 26, 2024
df06275
Add credo to deps
pojiro Jan 29, 2024
1ac2e25
Add dialyxir to deps
pojiro Jan 29, 2024
901d387
[zenohex_nif] Add docs and tests
pojiro Jan 29, 2024
91674ff
Add toml to deps
pojiro Jan 29, 2024
2472cc7
Add test/version_match_test.exs
pojiro Jan 29, 2024
d8238ed
[zenohex_nif] Apply rustler_precompiled
pojiro Jan 30, 2024
84b9406
Update .github/workflows/ci.yaml
pojiro Jan 30, 2024
317a2be
Remove nifzenoh codes
pojiro Jan 30, 2024
1fcc0b3
Update mix.exs
pojiro Jan 30, 2024
211b5ce
Update README.md
pojiro Jan 30, 2024
62d020c
Change dev version from 0.2.0-dev to 0.2.0-dev.0
pojiro Jan 30, 2024
3e20e17
Update mix.exs
pojiro Jan 30, 2024
e5c613d
Add config.exs
pojiro Jan 30, 2024
bb56234
Change version from 0.2.0-dev.0 to 0.2.0-rc.0
pojiro Jan 30, 2024
80e2b2e
Add targets to .github/workflows/nif_precompile.yml
pojiro Jan 30, 2024
5b401d1
Bump version from 0.2.0-rc.0 to 0.2.0-rc.1
pojiro Jan 30, 2024
737ae55
Add checksum-Elixir.Zenohex.Nif.exs for v0.2.0-rc.1
pojiro Jan 30, 2024
d667ff4
Update README.md
pojiro Jan 30, 2024
cb34bef
[zenohex_nif] Update nif.ex
pojiro Jan 30, 2024
eb11ded
Update README.md, fix wrong link
pojiro Jan 30, 2024
d5b6030
Reduce testing time, fix #11
pojiro Jan 31, 2024
294a394
Update .github/workflows/ci.yaml
pojiro Jan 31, 2024
0e26b00
Change API
pojiro Jan 31, 2024
d401df3
Fix session get, to be able to receive multiple reply
pojiro Feb 1, 2024
617c19a
Update mix aliases
pojiro Feb 1, 2024
49a4dce
Add Sample struct
pojiro Feb 2, 2024
f8333a0
Add `schedule = "DirtyIo"` to NIFs
pojiro Feb 2, 2024
edff6ee
Add storage example
pojiro Feb 2, 2024
63f8cf5
Add queryable server to storage example
pojiro Feb 3, 2024
455e743
Update storage example's queryable NOTE
pojiro Feb 4, 2024
5dc1599
Modify Sample, use ErlOption for reference
pojiro Feb 4, 2024
037b837
Modify Query struct
pojiro Feb 4, 2024
b64eda3
Refactor zenohex_nif mod
pojiro Feb 4, 2024
6aa9f53
Remove unused NIFs
pojiro Feb 4, 2024
a1ec9aa
Fix visibility of zenohex_nif
pojiro Feb 5, 2024
c52f44f
Add finish_reply/1 to Zenohex.Query
pojiro Feb 6, 2024
31b1212
Rename Ex...Ref name with ...Ref
pojiro Feb 6, 2024
2e2d7b3
Refactor zenohex_nif variable names
pojiro Feb 6, 2024
71d24b0
Add From trait impl to sample.rs
pojiro Feb 6, 2024
9a3c817
Add key_expr_intersects/2 to NIFs
pojiro Feb 6, 2024
132c5cf
Add test to check Nif.key_expr_intersects/2's left and right are equal
pojiro Feb 6, 2024
6783023
Add {:error, :disconnected} return to *_timeout NIFs
pojiro Feb 7, 2024
e200a21
Add queryable_server to examples
pojiro Feb 7, 2024
db40862
Add session_server to examples
pojiro Feb 7, 2024
18af264
Add publisher_server to examples
pojiro Feb 7, 2024
cce4671
Add subscriber_server to examples
pojiro Feb 7, 2024
304e06e
Add pull_subscriber_server to examples
pojiro Feb 7, 2024
1337253
Add delete/1 to examples/session_server
pojiro Feb 7, 2024
88b5463
Modify examples/session_server's test
pojiro Feb 7, 2024
2b0ac07
Modify examples/publisher_server's test
pojiro Feb 7, 2024
e92be88
Fix examples/session_server test
pojiro Feb 7, 2024
e314b96
Enhance examples/publiser_server test
pojiro Feb 7, 2024
1ea2bc2
Fix examples/storage/store, make it possible to delete with wildcard
pojiro Feb 7, 2024
4aed6cc
Change return typespec, from {:error, String.t()} to {:error, any()}
pojiro Feb 8, 2024
7166a6b
Fix credo issues, nested too deep
pojiro Feb 8, 2024
39cd42e
Change StorageBehaviour file location
pojiro Feb 8, 2024
8b28e2c
Add `@moduledoc false` to examples
pojiro Feb 8, 2024
0e75985
Add document to KeyExpr.intersects/2
pojiro Feb 8, 2024
b1ff76f
Add credo to .github/workflows/ci.yaml
pojiro Feb 8, 2024
563eb10
Add default timeout_us, 1ms
pojiro Feb 8, 2024
747a22f
Remove useless recv_timeout/1,2 return types from PullSubscriber, Que…
pojiro Feb 8, 2024
632f192
Add docs to Query functions
pojiro Feb 8, 2024
84f2992
Enhance docs of each options
pojiro Feb 8, 2024
b51f312
Refactor Zenohex.Nif
pojiro Feb 8, 2024
15c0b56
Add coverage to .github/workflows/ci.yaml
pojiro Feb 8, 2024
d9533d5
Enhance docs of Query and Sample
pojiro Feb 8, 2024
323c84f
Fix Session.get_timeout doc
pojiro Feb 8, 2024
456c7da
Refactor Examples.Storage
pojiro Feb 8, 2024
d89e743
Refactor Examples.Subscriber
pojiro Feb 8, 2024
568b539
Refactor Examples.Publisher
pojiro Feb 8, 2024
efa4e52
Refactor Examples.Queryable
pojiro Feb 8, 2024
46433a2
Refactor Examples.PullSubscriber
pojiro Feb 8, 2024
6fe37c8
Refactor Examples.Session
pojiro Feb 8, 2024
f1b29b0
Add open!/0 to Zenohex
pojiro Feb 9, 2024
69c6b75
Fix typo
pojiro Feb 9, 2024
e1eb965
Add docs to Examples.Publisher and refactor
pojiro Feb 9, 2024
0c08217
Rename examples/publisher files
pojiro Feb 9, 2024
0a57ae5
Add docs to Examples.Subscriber and refactor
pojiro Feb 9, 2024
1139095
Rename examples/subscriber files
pojiro Feb 9, 2024
76bd6e6
Add docs to Examples.PullSubscriber and refactor
pojiro Feb 9, 2024
361f25f
Rename examples/pull_subscriber files
pojiro Feb 9, 2024
62f5e78
Add docs to Examples.Queryable, Examples.Session and refactor
pojiro Feb 9, 2024
013b94d
Rename examples/queryable, examples/session files
pojiro Feb 9, 2024
ff26f2b
Add docs to Examples.Storage
pojiro Feb 9, 2024
b5eba5b
Modify example's receivers to receive immediately in init/1
pojiro Feb 9, 2024
c53d911
Make Example document group
pojiro Feb 9, 2024
d0af034
Update README.md
pojiro Feb 9, 2024
471d761
Refactor keyexpr.rs
pojiro Feb 9, 2024
30f4fbc
Add NOTE to session_get_reply_receiver/3
pojiro Feb 11, 2024
2826638
Add Config module
pojiro Feb 12, 2024
742c3f6
Add Config.Connect
pojiro Feb 12, 2024
9f9b0e9
Suppress not harmful dialyzer error
pojiro Feb 12, 2024
7351461
Modify dialyzer settings
pojiro Feb 12, 2024
f1c40eb
Enhance CI
pojiro Feb 12, 2024
dd1fec1
Fix docs name
pojiro Feb 12, 2024
75dd1ee
Bump version to v0.2.0-rc.2
pojiro Feb 12, 2024
188aca5
Update chechsum-Elixir.Zenohex.Nif.exs
pojiro Feb 12, 2024
f39dd3f
Update README.md
pojiro Feb 12, 2024
16fe613
Remove `async: true` to avoid interference between tests that throw z…
pojiro Feb 13, 2024
f3446ce
Fix flaky Examples.SessionTest which depends on the network interface…
pojiro Feb 13, 2024
5572390
Refactor Examples.Session.Impl
pojiro Feb 13, 2024
ef5d03a
Refactor Examples.(Subscriber|PullSubscriber|Queryable).Impl
pojiro Feb 13, 2024
5514b4e
Fix version, use 0.2.0-rc.2
pojiro Feb 15, 2024
3a4f612
Fix Zenoh.open!() timing with short-circuit eval
pojiro Feb 15, 2024
6030e13
Remove useless code
pojiro Feb 15, 2024
cb5566d
Modify Zenohex.open/1
pojiro Feb 15, 2024
fc3cf09
Change disable_zenoh_delay/1 on mix.exs
pojiro Feb 15, 2024
790f952
Use different sessions in Examples.SessionTest
pojiro Feb 15, 2024
efb214f
Refactor trivial, remove alias and more
pojiro Feb 15, 2024
764878a
Add session switch feature to examples/test
pojiro Feb 16, 2024
7fc6ad4
Fix trivial
pojiro Feb 16, 2024
7264f64
Fix tests that are caused by using different session
pojiro Feb 16, 2024
c55b045
Modify reducing test time suggest
pojiro Feb 16, 2024
a480ed8
Modify Zenohex.open/1
pojiro Feb 16, 2024
57b77d9
Update .github/workflows/ci.yaml to test both using same/different se…
pojiro Feb 16, 2024
8383468
Update .github/workflows/ci.yaml to run CI when push to main and any PR
pojiro Feb 16, 2024
fad9431
Fix credo issues
pojiro Feb 16, 2024
053cc42
Merge pull request #14 from b5g-ex/pojiro/fix-session-test
pojiro Feb 16, 2024
e743a2b
Fix trivial
pojiro Feb 16, 2024
1ef100f
Update .github/workflows/nif_precompile.yml, update OS versions
pojiro Feb 15, 2024
8f531fa
Add .github/dependabot.yml
pojiro Feb 14, 2024
5d1ea8e
Update rustler from 0.30.0 to 0.31.0
pojiro Feb 14, 2024
e214fe5
Merge pull request #13 from b5g-ex/pojiro/dependabot
pojiro Feb 16, 2024
6b551fa
Merge pull request #15 from b5g-ex/pojiro/precompile-os-update
pojiro Feb 16, 2024
8347c99
Fix USE_DIFFERENT_SESSION use
pojiro Feb 16, 2024
c20fa03
Merge pull request #18 from b5g-ex/pojiro/patch
pojiro Feb 16, 2024
7f8d809
Move Examples.Publisher doc to lib/zenohex/examples/README.md
pojiro Feb 16, 2024
d91c346
Move Examples.Subscriber doc to lib/zenohex/examples/README.md
pojiro Feb 16, 2024
a7499dd
Move Examples.PullSubscriber doc to lib/zenohex/examples/README.md
pojiro Feb 16, 2024
5be10ee
Move Examples.Queryable doc to lib/zenohex/examples/README.md
pojiro Feb 16, 2024
a36e97c
Move Examples.Session doc to lib/zenohex/examples/README.md
pojiro Feb 16, 2024
5e65529
Move Examples.Storage doc to lib/zenohex/examples/README.md
pojiro Feb 16, 2024
eb03352
Remove Examples section from mix docs
pojiro Feb 16, 2024
f5a900e
Update README.md
pojiro Feb 16, 2024
16bcc41
Exclude lib/zenohex/examples directory from package files
pojiro Feb 16, 2024
43283be
Update .github/workflows/ci.yaml, remove `on push`
pojiro Feb 19, 2024
9e9995a
Rename .github/workflows/ci.yaml to ci.yml
pojiro Feb 19, 2024
4c882c8
Update .github/workflows/ci.yml
pojiro Feb 19, 2024
e17cd0a
Remove unnecessary `uses` from .github/workflows/ci.yml
pojiro Feb 19, 2024
de4d092
Merge pull request #17 from b5g-ex/pojiro/update-examples-docs
pojiro Feb 19, 2024
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
122 changes: 122 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: CI

env:
OTP_VERSION: 26.1.2
ELIXIR_VERSION: 1.15.7
MIX_ENV: test

# based https://github.com/erlef/setup-beam

on:
push:
branches:
- "pojiro/0.2.0-dev"
pojiro marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build-deps:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
id: setup-beam
with:
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}

- uses: actions/cache@v4
id: save-deps-cache
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/*.lock') }}

- name: build deps
if: steps.save-deps-cache.outputs.cache-hit != 'true'
run: mix do deps.get, deps.compile

code-analysis:
needs: build-deps
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
id: setup-beam
with:
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- uses: actions/cache/restore@v4
id: restore-deps-cache
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/*.lock') }}
restore-keys: deps-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-

- name: format
run: mix format --check-formatted

- name: cargo fmt
working-directory: native/zenohex_nif
run: cargo fmt --all -- --check

- name: credo
run: mix credo --all

- name: restore plts cache
id: restore-plts-cache
uses: actions/cache/restore@v4
with:
key: plts-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/*.lock') }}
restore-keys: plts-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-
path: priv/plts

- name: create plts
if: steps.restore-plts-cache.outputs.cache-hit != 'true'
run: mix dialyzer --plt

- name: save plts cache
id: save-plts-cache
uses: actions/cache/save@v4
if: steps.restore-plts-cache.outputs.cache-hit != 'true'
with:
key: plts-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/*.lock') }}
path: priv/plts

- name: dialyzer
run: mix dialyzer --format github

test:
needs: build-deps
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
id: setup-beam
with:
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}

- uses: actions/cache/restore@v4
id: restore-deps-cache
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-${{ hashFiles('**/*.lock') }}
restore-keys: deps-${{ runner.os }}-${{ steps.setup-beam.outputs.otp-version }}-${{ steps.setup-beam.outputs.elixir-version }}-

- name: test
run: mix test --warnings-as-errors --cover
17 changes: 9 additions & 8 deletions .github/workflows/nif_precompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ jobs:
strategy:
fail-fast: false
matrix:
nif: ["2.16", "2.15"]
nif: ["2.15"]
job:
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-apple-darwin , os: macos-11 }
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04 , use-cross: true }
- { target: aarch64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04 , use-cross: true }
- { target: x86_64-apple-darwin , os: macos-11 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }
- { target: x86_64-pc-windows-gnu , os: windows-2019 }
- { target: x86_64-pc-windows-msvc , os: windows-2019 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04 , use-cross: true }

steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract project version
shell: bash
Expand All @@ -42,12 +43,12 @@ jobs:
id: build-crate
uses: philss/[email protected]
with:
project-name: nifzenoh
project-name: zenohex_nif
project-version: ${{ env.PROJECT_VERSION }}
target: ${{ matrix.job.target }}
nif-version: ${{ matrix.nif }}
use-cross: ${{ matrix.job.use-cross }}
project-dir: "native/nifzenoh"
project-dir: "native/zenohex_nif"

- name: Artifact upload
uses: actions/upload-artifact@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ zenohex-*.tar
/tmp/

/priv/native/

/priv/plts/*.plt
/priv/plts/*.plt.hash
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.15.6-otp-26
erlang 26.1.1
elixir 1.15.7-otp-26
erlang 26.1.2
84 changes: 54 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Zenohex

[![Hex version](https://img.shields.io/hexpm/v/zenohex.svg "Hex version")](https://hex.pm/packages/zenohex)
[![API docs](https://img.shields.io/hexpm/v/rclex.svg?label=hexdocs "API docs")](https://hexdocs.pm/zenohex/)
[![API docs](https://img.shields.io/hexpm/v/zenohex.svg?label=hexdocs "API docs")](https://hexdocs.pm/zenohex/)
[![License](https://img.shields.io/hexpm/l/zenohex.svg)](https://github.com/zenohex/zenohex/blob/main/LICENSE)

Zenohex is the [zenoh](https://zenoh.io/) client library for elixir.

Currently zenohex uses version 0.10.1-rc of zenoh.
If you want to communicate with Rust version of Zenoh, please use the same version.
**Currently zenohex uses version 0.10.1-rc of zenoh.
If you want to communicate with other Zenoh clients or routers, please use the same version.**

## Installation

Expand All @@ -17,7 +17,7 @@ by adding `zenohex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:zenohex, "~> 0.1.5"}
{:zenohex, "~> 0.2.0-rc.2"}
]
end
```
Expand All @@ -27,40 +27,64 @@ and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/zenohex>.

### Install rust (Optional)

Since version 0.1.3, Zenohex uses rustler precompiled and does not require Rust to be installed.

If you need to build rust NIFs code, please set the environment variable and install rust.
```
export RUSTLER_PRECOMPILATION_EXAMPLE_BUILD=1
If you want to build rust NIFs code, please add following to your config file.

```elixir
config :rustler_precompiled, :force_build, zenohex: true
```

https://www.rust-lang.org/tools/install

## Getting Started

### Publisher example
#### terminal 1 (Subscriber)
```
iex -S mix
iex> NifZenoh.tester_sub "demo/example/zenoh-rs-pub"
```
### Low layer Pub/Sub example

#### terminal 2 (Publisher)
```
iex -S mix
iex> session = Zenohex.open
iex> {:ok, publisher} = Session.declare_publisher(session, "demo/example/zenoh-rs-pub")
iex> Publisher.put(publisher, "Hello zenoh?")
```sh
$ iex -S mix
```

### Subscriber example
```
(Subscriber)
iex -S mix
iex> session = Zenohex.open
iex> Session.declare_subscriber(session, "demo/example/zenoh-rs-pub", fn m -> IO.inspect(m) end)
(third argument is callback function)

(Publisher)
iex> {:ok, publisher} = Session.declare_publisher(session, "demo/example/zenoh-rs-pub")
iex> Publisher.put(publisher, "Hello zenoh?")
```elixir
iex(1)> {:ok, session} = Zenohex.open()
{:ok, #Reference<>}
iex(2)> {:ok, publisher} = Zenohex.Session.declare_publisher(session, "pub/sub")
{:ok, #Reference<>}
iex(3)> {:ok, subscriber} = Zenohex.Session.declare_subscriber(session, "pub/sub")
{:ok, #Reference<>}
iex(4)> Zenohex.Publisher.put(publisher, "Hello Zenoh Dragon")
:ok
iex(5)> Zenohex.Subscriber.recv_timeout(subscriber, 1000)
{:ok, "Hello Zenoh Dragon"}
iex(6)> Zenohex.Subscriber.recv_timeout(subscriber, 1000)
{:error, :timeout}
```

### Practical examples

We implemented following practical examples under the [lib/zenohex/examples](lib/zenohex/examples) with moduledoc.

(from hexdocs please refer to MODULES tab's EXAMPLE section)

- [Publisher](lib/zenohex/examples/publisher.ex)
- [Subscriber](lib/zenohex/examples/subscriber.ex)
- [PullSubscriber](lib/zenohex/examples/pull_subscriber.ex)
- [Session](lib/zenohex/examples/session.ex)
- [Queryable](lib/zenohex/examples/queryable.ex)
- [Storage](lib/zenohex/examples/storage.ex)

Use them as reference for your implementation.

## For developer

### How to release

1. Change versions, `mix.exs`, `native/zenohex_nif/Cargo.toml`
2. Run test, this step changes `native/zenohex_nif/Cargo.lock` version
3. Commit them and put the version tag, like v0.2.0-rc.2
4. Puth the tag, like `git push origin v0.2.0-rc.2`. this step triggers the `.github/workflows/nif_precompile.yml`
5. After the artifacts are made, run `mix rustler_precompiled.download Zenohex.Nif --all` to update `checksum-Elixir.Zenohex.Nif.exs` and commit it.
6. Then publish to Hex

(These steps just follows [Recommended flow](https://hexdocs.pm/rustler_precompiled/precompilation_guide.html#recommended-flow).)
18 changes: 0 additions & 18 deletions checksum-Elixir.NifZenoh.exs

This file was deleted.

11 changes: 11 additions & 0 deletions checksum-Elixir.Zenohex.Nif.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%{
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-aarch64-apple-darwin.so.tar.gz" => "sha256:50123c9e497693e616daf10fcc3731329de3b2b25d7201bdfa06d4e1b430383e",
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-aarch64-unknown-linux-gnu.so.tar.gz" => "sha256:d5fa11e706bdf974511c2a2ea4731e16460a272a5752ba9721201b3f6b435ae4",
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-aarch64-unknown-linux-musl.so.tar.gz" => "sha256:4957bd71810dbff7d5685f3a6469cbf1adbe849e0e88c00607910441c701d0db",
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-arm-unknown-linux-gnueabihf.so.tar.gz" => "sha256:db0dcbf78eea7fc7c8f9bfd6b9acd816da560c6ea345494195df8f9b967a2714",
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-x86_64-apple-darwin.so.tar.gz" => "sha256:3413ab2f8f8772a690b59c43b6e5db5e3fcec721bc481ea14da20c890b22f561",
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-x86_64-unknown-linux-gnu.so.tar.gz" => "sha256:c835b87013dc722c647851358deabd17abdc274c79b42fab617662ed06b8866c",
"libzenohex_nif-v0.2.0-rc.2-nif-2.15-x86_64-unknown-linux-musl.so.tar.gz" => "sha256:bc614603b0424618d5e18440cd9637b6deaf835d52f5523f936935b2f863a45f",
"zenohex_nif-v0.2.0-rc.2-nif-2.15-x86_64-pc-windows-gnu.dll.tar.gz" => "sha256:f4acdab20483a65e7e2f85aa139df5856e6ba1db7827e729af8b77fe46562779",
"zenohex_nif-v0.2.0-rc.2-nif-2.15-x86_64-pc-windows-msvc.dll.tar.gz" => "sha256:c9091043d80c1e6183002472cb2bc630767a783980665785836f8644921fae57",
}
3 changes: 3 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Config

config :rustler_precompiled, :force_build, zenohex: true
59 changes: 0 additions & 59 deletions lib/nif_zenoh.ex

This file was deleted.

Loading