Skip to content

Commit

Permalink
Add a function type for functions that receive CloudEvents. (#51)
Browse files Browse the repository at this point in the history
This is not yet connected to anything.
  • Loading branch information
eamonnmcmanus authored Aug 21, 2020
1 parent 118c407 commit 320d56b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions functions-framework-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
<tag>HEAD</tag>
</scm>

<dependencies>
<dependency>
<groupId>io.cloudevents</groupId>
<artifactId>cloudevents-api</artifactId>
<version>2.0.0-milestone1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
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;
}

0 comments on commit 320d56b

Please sign in to comment.