Skip to content

Commit 320d56b

Browse files
Add a function type for functions that receive CloudEvents. (GoogleCloudPlatform#51)
This is not yet connected to anything.
1 parent 118c407 commit 320d56b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

functions-framework-api/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
<tag>HEAD</tag>
4949
</scm>
5050

51+
<dependencies>
52+
<dependency>
53+
<groupId>io.cloudevents</groupId>
54+
<artifactId>cloudevents-api</artifactId>
55+
<version>2.0.0-milestone1</version>
56+
</dependency>
57+
</dependencies>
58+
5159
<build>
5260
<plugins>
5361
<plugin>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.google.cloud.functions;
2+
3+
import io.cloudevents.CloudEvent;
4+
5+
/**
6+
* Represents a Cloud Function that is activated by an event and parsed into a {@link CloudEvent} object.
7+
* Because the {@link CloudEvent} API is not yet stable, a function implemented using this class may not
8+
* build or work correctly with later versions of that API. Once the API is stable, this interface will
9+
* become {@code CloudEventsFunction} and will also be stable.
10+
*/
11+
@FunctionalInterface
12+
public interface ExperimentalCloudEventsFunction {
13+
/**
14+
* Called to service an incoming event. This interface is implemented by user code to
15+
* provide the action for a given background function. If this method throws any exception
16+
* (including any {@link Error}) then the HTTP response will have a 500 status code.
17+
*
18+
* @param event the event.
19+
* @throws Exception to produce a 500 status code in the HTTP response.
20+
*/
21+
void accept(CloudEvent event) throws Exception;
22+
}

0 commit comments

Comments
 (0)