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

Native loading refactor #162

Merged
merged 84 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
e275db2
Alignment: bytes package
DariusIMP Oct 21, 2024
bd94fe3
Alignment: encoding update
DariusIMP Oct 21, 2024
9b62e1e
Alignment: config package
DariusIMP Oct 21, 2024
e9ba08a
Alignment: replacing all exceptions with ZError
DariusIMP Oct 21, 2024
941efe8
Alignment: ext package
DariusIMP Oct 21, 2024
1ee563b
Alignment: jni callbacks
DariusIMP Oct 21, 2024
95a13e5
Alignment: config
DariusIMP Oct 21, 2024
7f372b9
Alignment: JNIKeyExpr
DariusIMP Oct 21, 2024
9cb1dcc
Alignment: JNIPublisher
DariusIMP Oct 21, 2024
4390040
Alignment: JNIQuery
DariusIMP Oct 21, 2024
c9e0416
Alignment: JNIScout
DariusIMP Oct 21, 2024
5b2194f
Alignment: JNISession
DariusIMP Oct 21, 2024
5ed9777
Alignment JNIZBytes & JNIZenohId
DariusIMP Oct 22, 2024
aee2546
Alignment: KeyExpr & SetIntersectionLevel
DariusIMP Oct 22, 2024
52300e5
Alignment: pubsub package
DariusIMP Oct 22, 2024
afe3766
Alignment: Publisher & qos package
DariusIMP Oct 22, 2024
c68cef3
Alignment: query package - wip
DariusIMP Oct 22, 2024
a643bca
Alignment: adding scouting package
DariusIMP Oct 22, 2024
1d2121c
Alignment: removing Value
DariusIMP Oct 22, 2024
377661a
Alignment: logger
DariusIMP Oct 23, 2024
5d3705c
Alignmment: Zenoh.kt - wip
DariusIMP Oct 23, 2024
ba0fd31
Alignment: publisher - adding encoding and reliability to builder
DariusIMP Oct 23, 2024
14844c6
Alignment: subscriber
DariusIMP Oct 23, 2024
383f86e
Alignment: sample
DariusIMP Oct 23, 2024
eb9eeb8
Alignment: query & reply - wip
DariusIMP Oct 25, 2024
1f9b13d
Alignment: Put & Session
DariusIMP Oct 28, 2024
283c1f3
Alignment: fix 'IntoSelector'
DariusIMP Oct 28, 2024
6dcfe69
Alignment: updating zenoh-jni
DariusIMP Oct 29, 2024
68b18cf
Alignment: wip - converting tests to java tests. Added config tests.
DariusIMP Nov 12, 2024
4869b07
Alignment: wip - converting tests to java tests. Added delete test.
DariusIMP Nov 12, 2024
f2d666d
Alignment: wip - converting tests to java tests. Added encoding tests.
DariusIMP Nov 13, 2024
8badd0c
Alignment: wip - converting tests to java tests. Added get tests.
DariusIMP Nov 13, 2024
5f1c920
Alignment: wip - converting tests to java tests. Added key expr tests.
DariusIMP Nov 13, 2024
ce8147a
Alignment: wip - converting tests to java tests. Added parameters tests.
DariusIMP Nov 13, 2024
faccac9
Alignment: wip - converting tests to java tests. Added publisher tests.
DariusIMP Nov 13, 2024
6b9d6e1
Alignment: wip - converting tests to java tests. Added Queryable tests.
DariusIMP Nov 13, 2024
163b953
Alignment: wip - converting tests to java tests. Added Put tests.
DariusIMP Nov 14, 2024
790a131
Alignment: wip - Added Scouting tests + adding scouting builder.
DariusIMP Nov 14, 2024
f94ee4b
Alignment: wrapping up scouting, closing queue upon scout close.
DariusIMP Nov 18, 2024
5426942
Alignment: adding selector tests
DariusIMP Nov 18, 2024
98db96e
Alignment: fix SessionInfo + adding tests
DariusIMP Nov 18, 2024
1fa7d9d
Alignment: fix Scouting queue test
DariusIMP Nov 18, 2024
9a859e1
amend! Alignment: fix SessionInfo + adding tests
DariusIMP Nov 18, 2024
384ba33
Alignment: session tests
DariusIMP Nov 18, 2024
2424498
Alignment: user attachment tests
DariusIMP Nov 20, 2024
025bcf4
Alignment: subscriber tests
DariusIMP Nov 20, 2024
f5565f2
Alignment: removing the zenoh-ext package (to be added later in anoth…
DariusIMP Nov 21, 2024
14a615e
Alignment: Publisher config params
DariusIMP Nov 22, 2024
5d53262
Alignment: Subscriber config params
DariusIMP Nov 22, 2024
a98180d
Alignment: Queryable config params
DariusIMP Nov 25, 2024
66f158f
Alignment: Subscriber config params refactor
DariusIMP Nov 25, 2024
d9eca7d
Alignment: Queryable declaration and Query.reply config params.
DariusIMP Nov 26, 2024
bebd45f
Alignment: Get config params
DariusIMP Nov 26, 2024
73fad03
Alignment: Subscriber config params refactor
DariusIMP Nov 26, 2024
9962353
Fix config test
DariusIMP Nov 27, 2024
6e6c86d
Alignment - Scouting config params
DariusIMP Nov 27, 2024
95f86aa
Alignment: adding Liveliness
DariusIMP Nov 28, 2024
8c59360
Gitignore update
DariusIMP Nov 28, 2024
6b35c68
Alignment: fix logging
DariusIMP Nov 28, 2024
b580619
Alignment: publisher put and delete config param
DariusIMP Nov 29, 2024
2cc4260
Alignment: examples - adding picocli for CLI args
DariusIMP Nov 29, 2024
931b980
Alignment: examples - adding missing examples
DariusIMP Nov 29, 2024
bbf20c2
Alignment: examples - adding ping and pong examples
DariusIMP Nov 29, 2024
da98b95
Alignment: examples refactor + refactor queryable config logic
DariusIMP Dec 2, 2024
e18807a
Alignment: fix publisher put encoding fallback
DariusIMP Dec 2, 2024
997108a
Alignment: removing SubscriberConfig.kt
DariusIMP Dec 4, 2024
4e1bc01
Alignment: renaming PublisherConfig to PublisherOptions
DariusIMP Dec 4, 2024
7affa19
Alignment: renaming DeleteConfig to DeleteOptions and removing 'build…
DariusIMP Dec 4, 2024
3b916ed
Alignment: renaming GetConfig to GetOptions and removing 'builder' fu…
DariusIMP Dec 4, 2024
4d9dfe8
Alignment: renaming PutConfig to PutOptions and removing 'builder' fu…
DariusIMP Dec 4, 2024
569438f
Alignment: renaming ReplyConfig to ReplyOptions and removing 'builder…
DariusIMP Dec 5, 2024
94bbab4
Alignment: renaming ReplyDelConfig to ReplyDelOptions and removing 'b…
DariusIMP Dec 5, 2024
07f22dc
Alignment: renaming ReplyErrConfig to ReplyErrOptions and removing 'b…
DariusIMP Dec 5, 2024
c5d92dd
Alignment: renaming QueryableConfig to QueryableOptions and removing …
DariusIMP Dec 5, 2024
752c453
Alignment: renaming ScoutConfig to ScoutOptions and removing 'builder…
DariusIMP Dec 5, 2024
0577e5b
Alignment: renaming Liveliness.SubscriberConfig + renaming variables
DariusIMP Dec 5, 2024
1e72dd6
Alignment: queryable options refactor
DariusIMP Dec 5, 2024
1dffad8
Alignment: removing Resolvable
DariusIMP Dec 5, 2024
e3cdd11
Alignment: splitting Queryable, Subscriber and Get into Handler and C…
DariusIMP Dec 10, 2024
795fbff
Alignment: removing JNIZBytes
DariusIMP Dec 11, 2024
2f74120
Alignment: removing unused kotlin json dependency
DariusIMP Dec 11, 2024
1645dab
Alignment: options refactor on QoS param
DariusIMP Dec 18, 2024
3f49774
Native loading refactor
DariusIMP Dec 18, 2024
0743f9b
Merge branch 'main' of github.com:eclipse-zenoh/zenoh-java into zenoh…
DariusIMP Dec 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
Prev Previous commit
Next Next commit
Alignment: wip - converting tests to java tests. Added config tests.
DariusIMP committed Nov 12, 2024
commit 68b18cf31614b148cdf4a38f5e82b5e52679b09f
6 changes: 3 additions & 3 deletions examples/src/main/java/io/zenoh/ZDelete.java
Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;

public class ZDelete {
public static void main(String[] args) throws ZenohException {
public static void main(String[] args) throws ZError {
System.out.println("Opening session...");
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("demo/example/zenoh-java-put")) {
System.out.println("Deleting resources matching '" + keyExpr + "'...");
session.delete(keyExpr).res();
8 changes: 4 additions & 4 deletions examples/src/main/java/io/zenoh/ZGet.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.exceptions.ZError;
import io.zenoh.query.Reply;
import io.zenoh.query.Selector;

@@ -23,9 +23,9 @@

public class ZGet {

public static void main(String[] args) throws ZenohException, InterruptedException {
public static void main(String[] args) throws ZError, InterruptedException {
System.out.println("Opening session...");
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (Selector selector = Selector.tryFrom("demo/example/**")) {
System.out.println("Performing Get on '" + selector + "'...");
BlockingQueue<Optional<Reply>> receiver = session.get(selector).res();
@@ -38,7 +38,7 @@ public static void main(String[] args) throws ZenohException, InterruptedExcepti
Reply reply = wrapper.get();
if (reply instanceof Reply.Success) {
Reply.Success successReply = (Reply.Success) reply;
System.out.println("Received ('" + successReply.getSample().getKeyExpr() + "': '" + successReply.getSample().getValue() + "')");
System.out.println("Received ('" + successReply.getSample().getKeyExpr() + "': '" + successReply.getSample().getPayload() + "')");
} else {
Reply.Error errorReply = (Reply.Error) reply;
System.out.println("Received (ERROR: '" + errorReply.getError() + "')");
9 changes: 5 additions & 4 deletions examples/src/main/java/io/zenoh/ZPub.java
Original file line number Diff line number Diff line change
@@ -14,14 +14,15 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.bytes.ZBytes;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.pubsub.Publisher;

public class ZPub {
public static void main(String[] args) throws ZenohException, InterruptedException {
public static void main(String[] args) throws ZError, InterruptedException {
System.out.println("Opening session...");
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("demo/example/zenoh-java-pub")) {
System.out.println("Declaring publisher on '" + keyExpr + "'...");
try (Publisher publisher = session.declarePublisher(keyExpr).res()) {
@@ -31,7 +32,7 @@ public static void main(String[] args) throws ZenohException, InterruptedExcepti
Thread.sleep(1000);
String payload = String.format("[%4s] Pub from Java!", idx);
System.out.println("Putting Data ('" + keyExpr + "': '"+payload+"')...");
publisher.put(payload).res();
publisher.put(ZBytes.from(payload)).res();
idx++;
}
}
15 changes: 6 additions & 9 deletions examples/src/main/java/io/zenoh/ZPubThr.java
Original file line number Diff line number Diff line change
@@ -14,29 +14,26 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.bytes.ZBytes;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.qos.CongestionControl;
import io.zenoh.prelude.Encoding;
import io.zenoh.pubsub.Publisher;
import io.zenoh.value.Value;

public class ZPubThr {

public static void main(String[] args) throws ZenohException {
public static void main(String[] args) throws ZError {
int size = 8;
byte[] data = new byte[size];
for (int i = 0; i < size; i++) {
data[i] = (byte) (i % 10);
}
Value value = new Value(data, new Encoding(Encoding.ID.ZENOH_BYTES, null));
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("test/thr")) {
try (Publisher publisher = session.declarePublisher(keyExpr).congestionControl(CongestionControl.BLOCK).res()) {
try (Publisher publisher = session.declarePublisher(keyExpr).res()) {
System.out.println("Publisher declared on test/thr.");
System.out.println("Press CTRL-C to quit...");
while (true) {
publisher.put(value).res();
publisher.put(ZBytes.from(data)).res();
}
}
}
9 changes: 5 additions & 4 deletions examples/src/main/java/io/zenoh/ZPut.java
Original file line number Diff line number Diff line change
@@ -14,18 +14,19 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.bytes.ZBytes;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.qos.CongestionControl;
import io.zenoh.qos.Priority;

public class ZPut {
public static void main(String[] args) throws ZenohException {
public static void main(String[] args) throws ZError {
System.out.println("Opening session...");
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("demo/example/zenoh-java-put")) {
String value = "Put from Java!";
session.put(keyExpr, value)
session.put(keyExpr, ZBytes.from(value))
.congestionControl(CongestionControl.BLOCK)
.priority(Priority.REALTIME)
.res();
11 changes: 6 additions & 5 deletions examples/src/main/java/io/zenoh/ZQueryable.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.bytes.ZBytes;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.query.Query;
import io.zenoh.query.Queryable;
@@ -25,9 +26,9 @@

public class ZQueryable {

public static void main(String[] args) throws ZenohException, InterruptedException {
public static void main(String[] args) throws ZError, InterruptedException {
String keyExprString = "demo/example/zenoh-java-queryable";
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom(keyExprString)) {
System.out.println("Declaring Queryable on " + keyExprString + "...");
try (Queryable<BlockingQueue<Optional<Query>>> queryable = session.declareQueryable(keyExpr).res()) {
@@ -47,10 +48,10 @@ private static void handleRequests(BlockingQueue<Optional<Query>> receiver, KeyE
break;
}
Query query = wrapper.get();
String valueInfo = query.getValue() != null ? " with value '" + query.getValue() + "'" : "";
String valueInfo = query.getPayload() != null ? " with value '" + query.getPayload() + "'" : "";
System.out.println(">> [Queryable] Received Query '" + query.getSelector() + "'" + valueInfo);
try {
query.reply(keyExpr).success("Queryable from Java!").timestamp(TimeStamp.getCurrentTime()).res();
query.reply(keyExpr, ZBytes.from("Queryable from Java!")).timestamp(TimeStamp.getCurrentTime()).res();
} catch (Exception e) {
System.out.println(">> [Queryable] Error sending reply: " + e);
}
14 changes: 10 additions & 4 deletions examples/src/main/java/io/zenoh/ZSub.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.sample.Sample;
import io.zenoh.pubsub.Subscriber;
@@ -24,9 +24,9 @@

public class ZSub {

public static void main(String[] args) throws ZenohException, InterruptedException {
public static void main(String[] args) throws ZError, InterruptedException {
System.out.println("Opening session...");
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("demo/example/**")) {
System.out.println("Declaring Subscriber on '" + keyExpr + "'...");
try (Subscriber<BlockingQueue<Optional<Sample>>> subscriber = session.declareSubscriber(keyExpr).res()) {
@@ -39,10 +39,16 @@ public static void main(String[] args) throws ZenohException, InterruptedExcepti
break;
}
Sample sample = wrapper.get();
System.out.println(">> [Subscriber] Received " + sample.getKind() + " ('" + sample.getKeyExpr() + "': '" + sample.getValue() + "')");
System.out.println(">> [Subscriber] Received " + sample.getKind() + " ('" + sample.getKeyExpr() + "': '" + sample.getPayload() + "')");
}
} catch (ZError e) {
throw new RuntimeException(e);
}
}
}
}

public static void handleSample(Sample sample) {

}
}
8 changes: 4 additions & 4 deletions examples/src/main/java/io/zenoh/ZSubThr.java
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

package io.zenoh;

import io.zenoh.exceptions.ZenohException;
import io.zenoh.exceptions.ZError;
import io.zenoh.keyexpr.KeyExpr;
import io.zenoh.pubsub.Subscriber;
import kotlin.Unit;
@@ -58,11 +58,11 @@ public static void report() {
": averaged " + avg + " msgs/sec");
}

public static void main(String[] args) throws ZenohException, InterruptedException {
public static void main(String[] args) throws ZError, InterruptedException {
System.out.println("Opening Session");
try (Session session = Session.open()) {
try (Session session = Zenoh.open(Config.loadDefault())) {
try (KeyExpr keyExpr = KeyExpr.tryFrom("test/thr")) {
try (Subscriber<Unit> subscriber = session.declareSubscriber(keyExpr).with(sample -> listener()).res()) {
try (Subscriber<Unit> subscriber = session.declareSubscriber(keyExpr).callback(sample -> listener()).res()) {
System.out.println("Press CTRL-C to quit...");
while (true) {
Thread.sleep(1000);
1 change: 1 addition & 0 deletions zenoh-java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ kotlin {
val zenohPaths = "../zenoh-jni/target/$buildMode"
jvmArgs("-Djava.library.path=$zenohPaths")
}
withJava()
}
if (androidEnabled) {
androidTarget {
28 changes: 18 additions & 10 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/Config.kt
Original file line number Diff line number Diff line change
@@ -132,7 +132,8 @@ class Config internal constructor(internal val jniConfig: JNIConfig) {
/**
* Returns the default config.
*/
fun default(): Config {
@JvmStatic
fun loadDefault(): Config {
return JNIConfig.loadDefaultConfig()
}

@@ -143,6 +144,7 @@ class Config internal constructor(internal val jniConfig: JNIConfig) {
* Note the format is determined after the file extension.
* @return The [Config].
*/
@JvmStatic
@Throws(ZError::class)
fun fromFile(file: File): Config {
return JNIConfig.loadConfigFile(file)
@@ -155,6 +157,7 @@ class Config internal constructor(internal val jniConfig: JNIConfig) {
* Note the format is determined after the file extension.
* @return The [Config].
*/
@JvmStatic
@Throws(ZError::class)
fun fromFile(path: Path): Config {
return JNIConfig.loadConfigFile(path)
@@ -192,6 +195,7 @@ class Config internal constructor(internal val jniConfig: JNIConfig) {
* @param config Json formatted config.
* @return The [Config].
*/
@JvmStatic
@Throws(ZError::class)
fun fromJson(config: String): Config {
return JNIConfig.loadJsonConfig(config)
@@ -229,6 +233,7 @@ class Config internal constructor(internal val jniConfig: JNIConfig) {
* @param config Json5 formatted config
* @return The [Config].
*/
@JvmStatic
@Throws(ZError::class)
fun fromJson5(config: String): Config {
return JNIConfig.loadJson5Config(config)
@@ -262,26 +267,29 @@ class Config internal constructor(internal val jniConfig: JNIConfig) {
* @param config Yaml formatted config
* @return The [Config].
*/
@JvmStatic
@Throws(ZError::class)
fun fromYaml(config: String): Config {
return JNIConfig.loadYamlConfig(config)
}

/**
* Loads the configuration from the [jsonElement] specified.
*
* @param jsonElement The zenoh config as a [JsonElement].
*/
@Throws(ZError::class)
fun fromJsonElement(jsonElement: JsonElement): Config {
return JNIConfig.loadJsonConfig(jsonElement.toString())
}
// /** TODO
// * Loads the configuration from the [jsonElement] specified.
// *
// * @param jsonElement The zenoh config as a [JsonElement].
// */
// @JvmStatic
// @Throws(ZError::class)
// fun fromJsonElement(jsonElement: JsonElement): Config {
// return JNIConfig.loadJsonConfig(jsonElement.toString())
// }

/**
* Loads the configuration from the env variable [CONFIG_ENV].
*
* @return The config.
*/
@JvmStatic
@Throws(ZError::class)
fun fromEnv(): Config {
val envValue = System.getenv(CONFIG_ENV)
7 changes: 6 additions & 1 deletion zenoh-java/src/commonMain/kotlin/io/zenoh/Zenoh.kt
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ object Zenoh {
* @param config The configuration for the session.
* @return The [Session] on success.
*/
@JvmStatic
@Throws(ZError::class)
fun open(config: Config): Session {
return Session.open(config)
@@ -48,6 +49,7 @@ object Zenoh {
* @param config Optional [Config] for the scout.
* @return A result with the [Scout] object.
*/
@JvmStatic
@Throws(ZError::class)
fun scout(
callback: Callback<Hello>,
@@ -69,6 +71,7 @@ object Zenoh {
* @param config Optional [Config] for the scout.
* @return A result with the [Scout] object.
*/
@JvmStatic
@Throws(ZError::class)
fun <R> scout(
handler: Handler<Hello, R>,
@@ -84,7 +87,7 @@ object Zenoh {
)
}

// /**
// /** TODO
// * Scout for routers and/or peers.
// *
// * Scout spawns a task that periodically sends scout messages and waits for Hello replies.
@@ -119,6 +122,7 @@ object Zenoh {
*
* @see Logger
*/
@JvmStatic
fun tryInitLogFromEnv() {
val logEnv = System.getenv(LOG_ENV)
if (logEnv != null) {
@@ -137,6 +141,7 @@ object Zenoh {
* @param fallbackFilter: The fallback filter if the `RUST_LOG` environment variable is not set.
* @see Logger
*/
@JvmStatic
fun initLogFromEnvOr(fallbackFilter: String): Result<Unit> = runCatching {
ZenohLoad
val logLevelProp = System.getenv(LOG_ENV)
2 changes: 2 additions & 0 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/bytes/ZBytes.kt
Original file line number Diff line number Diff line change
@@ -38,11 +38,13 @@ class ZBytes internal constructor(internal val bytes: ByteArray) : IntoZBytes {
/**
* Creates a [ZBytes] instance from a [String].
*/
@JvmStatic
fun from(string: String) = ZBytes(string.encodeToByteArray())

/**
* Creates a [ZBytes] instance from a [ByteArray].
*/
@JvmStatic
fun from(bytes: ByteArray) = ZBytes(bytes)
}

1 change: 1 addition & 0 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/pubsub/Put.kt
Original file line number Diff line number Diff line change
@@ -130,6 +130,7 @@ class Put private constructor(
/** Resolves the put operation, returning a [Result]. */
@Throws(ZError::class)
override fun res() {
// TODO: rename res() to put()
val put = Put(keyExpr, payload.into(), encoding ?: Encoding.default(), qosBuilder.build(), reliability, attachment)
session.run { resolvePut(keyExpr, put) }
}
Loading