001package com.google.cloud.functions;
002
003import io.cloudevents.CloudEvent;
004
005/**
006 * Represents a Cloud Function that is activated by an event and parsed into a {@link CloudEvent} object.
007 * Because the {@link CloudEvent} API is not yet stable, a function implemented using this class may not
008 * build or work correctly with later versions of that API. Once the API is stable, this interface will
009 * become {@code CloudEventsFunction} and will also be stable.
010 */
011@FunctionalInterface
012public interface ExperimentalCloudEventsFunction {
013  /**
014   * Called to service an incoming event. This interface is implemented by user code to
015   * provide the action for a given background function. If this method throws any exception
016   * (including any {@link Error}) then the HTTP response will have a 500 status code.
017   *
018   * @param event the event.
019   * @throws Exception to produce a 500 status code in the HTTP response.
020   */
021  void accept(CloudEvent event) throws Exception;
022}