Skip to content

Commit

Permalink
Merge pull request #38 from ZettaScaleLabs/user_attachment
Browse files Browse the repository at this point in the history
User attachment
  • Loading branch information
p-avital authored Feb 22, 2024
2 parents 1a04e09 + 87f8f23 commit cf38f5a
Show file tree
Hide file tree
Showing 38 changed files with 1,583 additions and 555 deletions.
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Add an issue to the next release
description: |
Add an issue as part of next release.
This will be added to the current release project.
You must be a contributor to use this template.
labels: ["release"]
body:
- type: markdown
attributes:
value: |
**Guidelines for a good issue**
*Is your release item related to a problem?*
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
*Describe the solution you'd like*
A clear and concise description of what you want to happen.
*Describe alternatives you've considered*
A clear and concise description of any alternative solutions or features you've considered.
*Additional context*
Add any other context about the release item request here.
- type: textarea
id: item
attributes:
label: "Describe the release item"
validations:
required: true
31 changes: 27 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: CI

on:
push:
branches: ["**"]
branches: [ "**" ]
pull_request:
branches: ["**"]
branches: [ "**" ]
schedule:
- cron: "0 6 * * 1-5"
workflow_dispatch:
Expand All @@ -18,11 +18,11 @@ env:
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ["${{ matrix.os }}"]
runs-on: [ "${{ matrix.os }}" ]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
os: [ ubuntu-latest, macOS-latest ]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -79,3 +79,26 @@ jobs:
steps:
- name: Check whether all jobs pass
run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")'

# Publish snapshot packages. These jobs will only be triggered when the CI is executed on main.
publish_jvm_snapshot_package:
name: Publish JVM snapshot package
if: github.ref == 'refs/heads/main'
needs: ci
uses: ./.github/workflows/publish_jvm.yml
permissions:
contents: read
packages: write
with:
snapshot: true

publish_android_snapshot_package:
name: Publish Android snapshot package
if: github.ref == 'refs/heads/main'
needs: ci
uses: ./.github/workflows/publish_android.yml
permissions:
contents: read
packages: write
with:
snapshot: true
10 changes: 10 additions & 0 deletions .github/workflows/enforce-linking-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Enforce linking issues

on:
pull_request_target:
types: [opened, edited, labeled]

jobs:
main:
uses: eclipse-zenoh/zenoh/.github/workflows/enforce-linking-issues.yml@main
secrets: inherit
19 changes: 18 additions & 1 deletion .github/workflows/publish_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name: Publish Android
on:
release:
types: [published]
workflow_call:
inputs:
snapshot:
required: true
type: boolean
description: 'If the publication is for a snapshot version.'
default: false
workflow_dispatch:

env:
Expand Down Expand Up @@ -49,9 +56,19 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set pub mode env var
# Note: This step is intended to allow publishing snapshot packages.
# It allows to optionally append the property -PSNAPSHOT to the gradle
# publication task on the next step, resulting in the package version
# following the convention '<version>-SNAPSHOT'.
run: |
if [[ "${{ inputs.snapshot }}" == "true" ]]; then
echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV
fi
- name: Gradle Publish Android Package
uses: gradle/gradle-build-action@v2
with:
arguments: publishAndroidReleasePublicationToGithubPackagesRepository
arguments: publishAndroidReleasePublicationToGithubPackagesRepository ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 19 additions & 2 deletions .github/workflows/publish_jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ name: Publish JVM

on:
release:
types: [published]
types: [ published ]
workflow_call:
inputs:
snapshot:
required: true
type: boolean
description: 'If the publication is for a snapshot version.'
default: false
workflow_dispatch:

env:
Expand Down Expand Up @@ -153,9 +160,19 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Set pub mode env var
# Note: This step is intended to allow publishing snapshot packages.
# It allows to optionally append the property -PSNAPSHOT to the gradle
# publication task on the next step, resulting in the package version
# following the convention '<version>-SNAPSHOT'.
run: |
if [[ "${{ inputs.snapshot }}" == "true" ]]; then
echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV
fi
- name: Gradle Publish JVM Package
uses: gradle/gradle-build-action@v2
with:
arguments: publishJvmPublicationToGithubPackagesRepository
arguments: publishJvmPublicationToGithubPackagesRepository ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/update-release-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Update release project

on:
issues:
types: [opened, edited, labeled]
pull_request_target:
types: [closed]
branches:
- main

jobs:
main:
uses: eclipse-zenoh/zenoh/.github/workflows/update-release-project.yml@main
secrets: inherit
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// ZettaScale Zenoh Team, <[email protected]>
//

val zenohGroup = "io.zenoh"
val zenohVersion = "1.0.0"

buildscript {
repositories {
Expand All @@ -35,6 +37,9 @@ plugins {
}

subprojects {
group = zenohGroup
version = zenohVersion

repositories {
google()
mavenCentral()
Expand Down
3 changes: 0 additions & 3 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// ZettaScale Zenoh Team, <[email protected]>
//

group = "io.zenoh"
version = "0.11.0-dev"

plugins {
kotlin("jvm")
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.72.0
1.74.0
7 changes: 4 additions & 3 deletions zenoh-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// ZettaScale Zenoh Team, <[email protected]>
//

group = "io.zenoh"
version = "0.11.0-dev"

plugins {
id("com.android.library")
kotlin("multiplatform")
Expand Down Expand Up @@ -121,6 +118,10 @@ kotlin {
}

publishing {
publications.withType<MavenPublication> {
version = project.version.toString() + if (project.hasProperty("SNAPSHOT")) "-SNAPSHOT" else ""
}

repositories {
maven {
name = "GithubPackages"
Expand Down
6 changes: 4 additions & 2 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/Session.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import io.zenoh.publication.Put
import io.zenoh.query.*
import io.zenoh.queryable.Query
import io.zenoh.queryable.Queryable
import io.zenoh.sample.Attachment
import io.zenoh.sample.Sample
import io.zenoh.selector.Selector
import io.zenoh.subscriber.Reliability
Expand Down Expand Up @@ -387,12 +388,13 @@ class Session private constructor(private val config: Config) : AutoCloseable {
timeout: Duration,
target: QueryTarget,
consolidation: ConsolidationMode,
value: Value?
value: Value?,
attachment: Attachment?,
): R? {
if (jniSession == null) {
throw sessionClosedException
}
return jniSession?.performGet(selector, callback, onClose, receiver, timeout, target, consolidation, value)
return jniSession?.performGet(selector, callback, onClose, receiver, timeout, target, consolidation, value, attachment)
}

@Throws(ZenohException::class)
Expand Down
42 changes: 33 additions & 9 deletions zenoh-java/src/commonMain/kotlin/io/zenoh/jni/JNIPublisher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import io.zenoh.exceptions.ZenohException
import io.zenoh.prelude.SampleKind
import io.zenoh.publication.CongestionControl
import io.zenoh.publication.Priority
import io.zenoh.sample.Attachment
import io.zenoh.value.Value

/**
Expand All @@ -32,20 +33,39 @@ internal class JNIPublisher(private val ptr: Long) {
* Put value through the publisher.
*
* @param value The [Value] to be put.
* @param attachment Optional [Attachment].
*/
@Throws(ZenohException::class)
fun put(value: Value) {
putViaJNI(value.payload, value.encoding.knownEncoding.ordinal, ptr)
fun put(value: Value, attachment: Attachment?) {
putViaJNI(value.payload, value.encoding.knownEncoding.ordinal, attachment?.let { encodeAttachment(it) }, ptr)
}

/**
* Write operation.
*
* @param kind The [SampleKind].
* @param value The [Value] to be written.
* @param attachment Optional [Attachment].
*/
@Throws(ZenohException::class)
fun write(kind: SampleKind, value: Value) {
writeViaJNI(value.payload, value.encoding.knownEncoding.ordinal, kind.ordinal, ptr)
fun write(kind: SampleKind, value: Value, attachment: Attachment?) {
writeViaJNI(
value.payload,
value.encoding.knownEncoding.ordinal,
kind.ordinal,
attachment?.let { encodeAttachment(it) },
ptr
)
}

/**
* Delete operation.
*
* @param attachment Optional [Attachment].
*/
@Throws(ZenohException::class)
fun delete() {
deleteViaJNI(ptr)
fun delete(attachment: Attachment?) {
deleteViaJNI(attachment?.let { encodeAttachment(it) }, ptr)
}

/**
Expand Down Expand Up @@ -106,13 +126,17 @@ internal class JNIPublisher(private val ptr: Long) {

/** Puts through the native Publisher. */
@Throws(ZenohException::class)
private external fun putViaJNI(valuePayload: ByteArray, valueEncoding: Int, ptr: Long)
private external fun putViaJNI(
valuePayload: ByteArray, valueEncoding: Int, encodedAttachment: ByteArray?, ptr: Long
)

@Throws(ZenohException::class)
private external fun writeViaJNI(payload: ByteArray, encoding: Int, sampleKind: Int, ptr: Long)
private external fun writeViaJNI(
payload: ByteArray, encoding: Int, sampleKind: Int, encodedAttachment: ByteArray?, ptr: Long
)

@Throws(ZenohException::class)
private external fun deleteViaJNI(ptr: Long)
private external fun deleteViaJNI(encodedAttachment: ByteArray?, ptr: Long)

/** Frees the underlying native Publisher. */
private external fun freePtrViaJNI(ptr: Long)
Expand Down
4 changes: 3 additions & 1 deletion zenoh-java/src/commonMain/kotlin/io/zenoh/jni/JNIQuery.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal class JNIQuery(private val ptr: Long) {
sample.kind.ordinal,
timestampEnabled,
if (timestampEnabled) sample.timestamp!!.ntpValue() else 0,
sample.attachment?.let { encodeAttachment(it) },
)
}

Expand All @@ -58,7 +59,8 @@ internal class JNIQuery(private val ptr: Long) {
valueEncoding: Int,
sampleKind: Int,
timestampEnabled: Boolean,
timestampNtp64: Long
timestampNtp64: Long,
attachment: ByteArray?,
)

@Throws(ZenohException::class)
Expand Down
Loading

0 comments on commit cf38f5a

Please sign in to comment.