Class GoogleCloudEventsFunction<T>
java.lang.Object
io.micronaut.function.executor.AbstractExecutor
io.micronaut.function.executor.FunctionInitializer
io.micronaut.gcp.function.GoogleFunctionInitializer
io.micronaut.gcp.function.cloudevents.GoogleCloudEventsFunction<T>
- Type Parameters:
T
- Google Cloud Events Type
- All Implemented Interfaces:
com.google.cloud.functions.CloudEventsFunction
,io.micronaut.context.ApplicationContextProvider
,Closeable
,AutoCloseable
public abstract class GoogleCloudEventsFunction<T>
extends GoogleFunctionInitializer
implements com.google.cloud.functions.CloudEventsFunction
A super class that extends
GoogleFunctionInitializer
and can be used to map cloud events payloads. To be used with CloudEvents POJOs issued by Google.- Since:
- 4.8.0
- Author:
- Guillermo Calvo
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.function.executor.FunctionInitializer
io.micronaut.function.executor.FunctionInitializer.ParseContext
-
Field Summary
Fields inherited from class io.micronaut.function.executor.FunctionInitializer
closeContext
Fields inherited from class io.micronaut.function.executor.AbstractExecutor
applicationContext
-
Constructor Summary
-
Method Summary
Methods inherited from class io.micronaut.gcp.function.GoogleFunctionInitializer
newApplicationContextBuilder
Methods inherited from class io.micronaut.function.executor.FunctionInitializer
close, injectThis, run, startThis
Methods inherited from class io.micronaut.function.executor.AbstractExecutor
buildApplicationContext, getApplicationContext, resolveFunction, resolveFunctionName, startEnvironment
-
Constructor Details
-
GoogleCloudEventsFunction
protected GoogleCloudEventsFunction()
-
-
Method Details
-
accept
- Specified by:
accept
in interfacecom.google.cloud.functions.CloudEventsFunction
- Throws:
Exception
-
accept
protected abstract void accept(@NonNull @NonNull io.cloudevents.CloudEventContext context, @Nullable T data) throws Exception Called to service an incoming event. If this method throws any exception (including anyError
) then the HTTP response will have a 500 status code.- Parameters:
context
- Cloud Event contextdata
- Google Cloud Event- Throws:
Exception
- to produce a 500 status code in the HTTP response.
-
getType
- Returns:
- Google Cloud Event Type.
-
map
@NonNull protected @NonNull Optional<T> map(@NonNull @NonNull io.cloudevents.CloudEvent event, @NonNull @NonNull Class<T> type) Maps a cloud event to the target type.- Parameters:
event
- The Cloud Eventtype
- The target mapping type.- Returns:
- The bound type if possible, or an empty optional in case of error.
-