This repository has been archived by the owner on Mar 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Java Controller and Metadata support
I've only added metadata support inputs for event sourcing and crdts, I haven't added it for outputs yet. Controller support is in full.
- Loading branch information
Showing
37 changed files
with
2,636 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
java-support/src/main/java/io/cloudstate/javasupport/CloudEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
package io.cloudstate.javasupport; | ||
|
||
import java.net.URI; | ||
import java.time.ZonedDateTime; | ||
import java.util.Optional; | ||
|
||
/** CloudEvent representation of Metadata. */ | ||
public interface CloudEvent { | ||
|
||
/** | ||
* The CloudEvent spec version. | ||
* | ||
* @return The spec version. | ||
*/ | ||
String specversion(); | ||
|
||
/** | ||
* The id of this CloudEvent. | ||
* | ||
* @return The id. | ||
*/ | ||
String id(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given id. | ||
* | ||
* @param id The id to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withId(String id); | ||
|
||
/** | ||
* The source of this CloudEvent. | ||
* | ||
* @return The source. | ||
*/ | ||
URI source(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given source. | ||
* | ||
* @param source The source to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withSource(URI source); | ||
|
||
/** | ||
* The type of this CloudEvent. | ||
* | ||
* @return The type. | ||
*/ | ||
String type(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given type. | ||
* | ||
* @param type The type to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withType(String type); | ||
|
||
/** | ||
* The data content type of this CloudEvent. | ||
* | ||
* @return The data content type, if set. | ||
*/ | ||
Optional<String> datacontenttype(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given data content type. | ||
* | ||
* @param datacontenttype The data content type to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withDatacontenttype(String datacontenttype); | ||
|
||
/** | ||
* Clear the data content type of this CloudEvent, if set. | ||
* | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent clearDatacontenttype(); | ||
|
||
/** | ||
* The data schema of this CloudEvent. | ||
* | ||
* @return The data schema, if set. | ||
*/ | ||
Optional<URI> dataschema(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given data schema. | ||
* | ||
* @param dataschema The data schema to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withDataschema(URI dataschema); | ||
|
||
/** | ||
* Clear the data schema of this CloudEvent, if set. | ||
* | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent clearDataschema(); | ||
|
||
/** | ||
* The subject of this CloudEvent. | ||
* | ||
* @return The subject, if set. | ||
*/ | ||
Optional<String> subject(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given subject. | ||
* | ||
* @param subject The subject to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withSubject(String subject); | ||
|
||
/** | ||
* Clear the subject of this CloudEvent, if set. | ||
* | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent clearSubject(); | ||
|
||
/** | ||
* The time of this CloudEvent. | ||
* | ||
* @return The time, if set. | ||
*/ | ||
Optional<ZonedDateTime> time(); | ||
|
||
/** | ||
* Return a new CloudEvent with the given time. | ||
* | ||
* @param time The time to set. | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent withTime(ZonedDateTime time); | ||
|
||
/** | ||
* Clear the time of this CloudEvent, if set. | ||
* | ||
* @return A copy of this CloudEvent. | ||
*/ | ||
CloudEvent clearTime(); | ||
|
||
/** | ||
* Return this CloudEvent represented as Metadata. | ||
* | ||
* <p>If this CloudEvent was created by {{@link Metadata#asCloudEvent()}}, then any non CloudEvent | ||
* metadata that was present will still be present. | ||
* | ||
* @return This CloudEvent expressed as Cloudstate metadata. | ||
*/ | ||
Metadata asMetadata(); | ||
|
||
/** | ||
* Create a CloudEvent. | ||
* | ||
* @param id The id of the CloudEvent. | ||
* @param source The source of the CloudEvent. | ||
* @param type The type of the CloudEvent. | ||
* @return The newly created CloudEvent. | ||
*/ | ||
static CloudEvent of(String id, URI source, String type) { | ||
return Metadata.EMPTY.asCloudEvent(id, source, type); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.