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

UTransport Interface & Data Model #18

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3349ba9
Start of uTransport
Aug 21, 2023
2aa3f03
Interface & data model complete
Aug 24, 2023
4bf89a8
Adding documentation
Aug 24, 2023
ed8e57e
Added more Test coverage
Aug 25, 2023
b824eeb
Additional Test coverage
Aug 28, 2023
301dcf7
Added the start of a Micro Uri
Aug 30, 2023
1594da8
Added UUri id
Aug 30, 2023
cf18951
Finished the micro Uri
Aug 30, 2023
96db5b6
Many more changes
Sep 1, 2023
fa95280
working on UPayload
Sep 4, 2023
15a719b
More tests for URI validation
Sep 6, 2023
81949c6
Moved SerializationHint into UPayload
Sep 6, 2023
2928e93
working on UStatus
Sep 6, 2023
7279ddd
More micro URI factory tests
Sep 6, 2023
fee9c0c
Merge branch 'utransport' of https://github.com/eclipse-uprotocol/upr…
Sep 7, 2023
a625774
testing UStatus a bit more
Sep 7, 2023
b83985f
working on UAttributes
Sep 7, 2023
92eb9c9
More coverage for UUri updates
Sep 8, 2023
e48f772
Added UriFormat definitions
Sep 8, 2023
3087519
Fixing the Generics syntax for uTransport
Sep 8, 2023
adf77d4
working on UAttributes
Sep 10, 2023
70df16e
adding tests for UPriority and UMessageType
Sep 10, 2023
393c0b5
adding tests for USerializationHint
Sep 10, 2023
cfec839
working on UAttributesValidator and UAttributesValidatorTest
Sep 10, 2023
7fdbe96
fixing error messages for uAttributesValidator
Sep 11, 2023
a968959
Reverting the UriFormat change
Sep 11, 2023
be60c59
Adding experimental UriSerializer
Sep 11, 2023
e97fe7b
Additional clean up and improvements for UUri
Sep 12, 2023
e623b8c
Added isResolved() and isLocalFormat()
Sep 13, 2023
99eb686
Replace UriFactory with UriSerializer
Sep 14, 2023
dda8f72
Changed UEntity version from String to Integer
Sep 14, 2023
8c02ab6
cleanup, remove File event and add payload size
Sep 14, 2023
af5ee68
RpcClient Implementation
Sep 14, 2023
093c5bd
Fixed documentation & rename serializer
Sep 15, 2023
a33b789
working on UUri
Sep 18, 2023
d19bc64
Fixing all the builds for the refactored code
Sep 19, 2023
d9d8f2b
Rename UriParts to UriFormat
Sep 19, 2023
29b3bc6
Added deserialize(String,byte[]) API
Sep 19, 2023
d33db74
Further test coverage
Sep 20, 2023
d2d1e02
more test coverage
Sep 20, 2023
dbf1a07
Fix coverage in UUIDValidator
Sep 20, 2023
4a1786d
working on UUri
Sep 20, 2023
64bedb6
fixing the broken build and failing tests
Sep 20, 2023
454c014
fixing some dead code and tests
Sep 20, 2023
bf5dc24
working on serialization
Sep 21, 2023
4bf168b
Rename utransport to transport
Sep 22, 2023
cc54899
Adding uMessage
Sep 25, 2023
48f782b
Revert "Adding uMessage"
Sep 26, 2023
901a960
Merge branch 'main' into utransport
Sep 26, 2023
b91e950
Cleanup of unused imports and various fixes
Sep 26, 2023
e4f794e
Add 100% test coverage
Sep 27, 2023
5bf2bf4
Added back Short URI and finished code coverage
Sep 28, 2023
4b34d01
Update Micro Uri Format
Oct 20, 2023
b03bf9a
1.5 uuri (#28)
Oct 31, 2023
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
76 changes: 21 additions & 55 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
image:https://github.com/eclipse-uprotocol/.github/raw/main/logo/uprotocol_logo.png[alt=uProtocol,640]

image:https://img.shields.io/badge/License-Apache%202.0-blue.svg[License,link=https://opensource.org/licenses/Apache-2.0]

= Eclipse uProtocol Java SDK
:toc:

== Overview

The main object of this module is to enable constructing and deconstructing uProtocol CloudEvents.

The core module contains functional factory methods for creating CloudEvents as well as functional factory methods that make it more intuitive to create URIs that are used to configure source and sink (destination) elements in the uProtocol CloudEvents.
The purpose of this module is to provide language specific code that builds the various data types defined in . The SDK also defines https://github.com/eclipse-uprotocol/uprotocol-spec/tree/main[uProtocol Specifications].

This module contains the data model structures as well as core functionality for building uProtocol CloudEvents and URIs for sink and source attributes.
The module contains factory methods and validators for all data types used in uProtocol.

The SDKs are then used by the code generators to auto-populate service stubs with generated code that builds CloudEvents. For more information on auto-generating service stubs, please refer to http://github.com/eclipse-uprotocol/uprotocol[uProtocol Main Project]

Expand All @@ -28,57 +22,29 @@ The SDKs are then used by the code generators to auto-populate service stubs wit
</dependency>
----

=== Using the sdk

=== UriFactory

Matches the uProtocol URI Format. and is used to define source and sink (destination) attributes of uProtocol CloudEvents.
The factory builds URIs.

URI is used as a method to uniquely identify devices, services, and resources on the network.

*An Uri is built from the following elements:*

* *UAuthority* - represents the device and domain of the software, the deployment. You can specify local or remote options.
* *UEntity* - The Software Entity defines the software name and version.
* *UResource* - The resource of the software can be a service name, and instance in the service and the name of the protobuf IDL message.

==== UAuthority

An Authority consists of a device and a domain per uProtocol URI format.

An Authority represents the deployment location of a specific Software Entity.

==== UEntity - uE

An Software Entity is a piece of software deployed somewhere on a device. The uE is used in the source and sink parts of communicating software.

A uE that *publishes* events is a *Service* role.

A uE that *consumes* events is an *Application* role.

A uE may combine bother Service and Application roles.


==== UResource

A service API - defined in the uE - has Resources and Methods. Both of these are represented by the UResource class.

An UResource is something that can be manipulated/controlled/exposed by a service.

Resources are unique when prepended with UAuthority that represents the device and Software Entity that represents the service.

An Resource represents a resource from a Service such as "door" and an optional specific instance such as "front_left".
In addition, it can optionally contain the name of the resource Message type, such as "Door".
The SDK is composed of 4 main packages as shown in <<sdk-packages>> below:

The Message type matches the protobuf service IDL that defines structured data types. A message is a data structure type used to define data that is passed in events and rpc methods.
.SDK Packages
[#sdk-packages,width=100%,cols="15%,25%,60%"]
|===
| Package | https://github.com/eclipse-uprotocol/uprotocol-spec[uprotocol-spec] | Purpose

=== CloudEventFactory
Factory class that builds the various types of CloudEvents for uProtocol (publish, notification, request, response)
| link:src/main/java/org/eclipse/uprotocol/uri/README.adoc[`uuri`]
| https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/basics/uri.adoc[URI, UAthority, UEntity, UResource]
| Uniform Resource Identifier (RFC3986) used to address things (devices, software, methods, topics, etc...) on the network

== Examples
| link:src/main/java/org/eclipse/uprotocol/cloudevent/README.adoc[`cloudevent`]
| https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/up-l1/cloudevents.adoc[uProtocol CloudEvents]
| Common way to represent uProtocol messages using CloudEvent data model

The SDK contains comprehensive tests, the best place to look at how all the APIs are used are at:
| link:src/main/java/org/eclipse/uprotocol/uuid/README.adoc[`uuid`]
| https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/basics/uuid.adoc[uProtocol UUIDs]
| Identifier used to uniquely identify messages that are sent between devices. also includes timestamp for the message

* link:src/test/java/org/eclipse/uprotocol/uri/factory/UriFactoryTest.java[UriFactoryTest.java]
| link:src/main/java/org/eclipse/uprotocol/utransport/README.adoc[`utransport`]
| https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/up-l1/README.adoc[uP-L1 Specifications]
| Interface (and data model) used for bidirectional point-2-point communication between uEs. Interface is to be implemented by the different communication technologies (ex. Binder, MQTT, Zenoh, SOME/IP, DDS, HTTP, etc…​)

* link:src/test/java/org/eclipse/uprotocol/cloudevent/factory/CloudEventFactoryTest.java[CloudEventFactoryTest.java]
|===
47 changes: 37 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,27 @@

<dependencyManagement>
<dependencies>

<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-protobuf</artifactId>
<version>2.4.2</version>
</dependency>


<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
<version>2.11.0</version>
</dependency>


<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-bom</artifactId>
Expand All @@ -153,7 +174,7 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.10.1</version>
<version>3.14.1</version>
<scope>test</scope>
</dependency>

Expand All @@ -173,6 +194,7 @@
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.14.1</version>
<scope>test</scope>
</dependency>

Expand All @@ -188,7 +210,7 @@
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-protobuf</artifactId>
<version>2.2.0</version>

</dependency>

<!-- CloudEvents support https://cloudevents.github.io/sdk-java/ https://github.com/cloudevents/sdk-java-->
Expand Down Expand Up @@ -223,21 +245,26 @@
</dependency>


<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-proto-extension</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>


<!-- https://search.maven.org/artifact/com.github.f4b6a3/uuid-creator -->
<dependency>
<groupId>com.github.f4b6a3</groupId>
<artifactId>uuid-creator</artifactId>
<version>5.1.2</version>
</dependency>

<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.eclipse.uprotocol </groupId>
<artifactId>uprotocol-core-api</artifactId>
<version>1.4.9-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/uprotocol-core-api-1.4.9-SNAPSHOT.jar</systemPath>
</dependency>

</dependencies>

</project>
21 changes: 21 additions & 0 deletions src/main/java/org/eclipse/uprotocol/cloudevent/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
= uProtocol CloudEvents
:toc:
:sectnums:


== Overview

https://github.com/eclipse-uprotocol/uprotocol-spec/blob/main/up-l1/cloudevents.adoc[uProtocol CloudEvents] is a common message envelope that could be used to carry way to represent uProtocol transport layer information `UUri` (source), `UPayload`, and `UAttributes`. `CloudEvents` are used by a number of Device-2-Cloud and Cloud-2-Device based transports such as MQTT and HTTP, however it could also be used by any transport (ex. Binder).

NOTE: CloudEvent is not, nor was not, meant to be _the_ only message format used below or above the transport layer.

=== CloudEventFactory
Factory class that builds the various types of CloudEvents for uProtocol (publish, notification, request, response)

== Examples

The SDK contains comprehensive tests, the best place to look at how all the APIs are used are at:

* link:src/test/java/org/eclipse/uprotocol/uri/factory/UriFactoryTest.java[UriFactoryTest.java]

* link:src/test/java/org/eclipse/uprotocol/cloudevent/factory/CloudEventFactoryTest.java[CloudEventFactoryTest.java]
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
*/
public enum UCloudEventType {
PUBLISH ("pub.v1"),
FILE ("file.v1"),
REQUEST ("req.v1"),
RESPONSE ("res.v1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

import org.eclipse.uprotocol.cloudevent.datamodel.UCloudEventAttributes;
import org.eclipse.uprotocol.cloudevent.datamodel.UCloudEventType;
import org.eclipse.uprotocol.uri.datamodel.UUri;
import org.eclipse.uprotocol.uri.factory.UriFactory;

import com.google.protobuf.Any;
import com.google.protobuf.Empty;
import com.google.rpc.Code;
Expand Down Expand Up @@ -159,8 +158,7 @@ static String generateCloudEventId() {
*
* @param id Event unique identifier.
* @param source Identifies who is sending this event in the format of a uProtocol URI that
* can be built from a {@link UUri} object using
* the {@link UriFactory}
* can be built from a {@link UUri} object.
* @param protoPayloadBytes The serialized Event data with the content type of "application/x-protobuf".
* @param protoPayloadSchema The schema of the proto payload bytes, for example you can use <code>protoPayload.getTypeUrl()</code> on your service/app object.
* @param attributes Additional cloud event attributes that can be passed in. All attributes are optional and will be added only if they
Expand Down
Loading
Loading