-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a function type for functions that receive CloudEvents. (#51)
This is not yet connected to anything.
- Loading branch information
1 parent
118c407
commit 320d56b
Showing
2 changed files
with
30 additions
and
0 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
22 changes: 22 additions & 0 deletions
22
...amework-api/src/main/java/com/google/cloud/functions/ExperimentalCloudEventsFunction.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,22 @@ | ||
package com.google.cloud.functions; | ||
|
||
import io.cloudevents.CloudEvent; | ||
|
||
/** | ||
* Represents a Cloud Function that is activated by an event and parsed into a {@link CloudEvent} object. | ||
* Because the {@link CloudEvent} API is not yet stable, a function implemented using this class may not | ||
* build or work correctly with later versions of that API. Once the API is stable, this interface will | ||
* become {@code CloudEventsFunction} and will also be stable. | ||
*/ | ||
@FunctionalInterface | ||
public interface ExperimentalCloudEventsFunction { | ||
/** | ||
* Called to service an incoming event. This interface is implemented by user code to | ||
* provide the action for a given background function. If this method throws any exception | ||
* (including any {@link Error}) then the HTTP response will have a 500 status code. | ||
* | ||
* @param event the event. | ||
* @throws Exception to produce a 500 status code in the HTTP response. | ||
*/ | ||
void accept(CloudEvent event) throws Exception; | ||
} |