Skip to content

Commit

Permalink
Google Cloud Functions Codestart
Browse files Browse the repository at this point in the history
  • Loading branch information
loicmathieu authored and gsmet committed Jan 11, 2021
1 parent 0b64f6e commit 205fc41
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Google Cloud Functions Integration examples

Examples of Google Cloud HTTP and Background Functions for Quarkus.

Guide: https://quarkus.io/guides/gcp-functions

Two examples have been generated under `src/main/java/org/acme/googlecloudfunctions`, you must remove them before deploying to
Google Cloud Functions or setup multi-functions support, see https://quarkus.io/guides/gcp-functions#choose-your-function.

> :warning: **INCOMPATIBLE WITH DEV MODE**: Google Cloud Functions is not compatible with dev mode yet!
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: google-cloud-functions-example
ref: google-cloud-functions
type: code
tags:
- example
- singleton-example
language:
base:
dependencies:
- io.quarkus:quarkus-google-cloud-functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.acme.googlecloudfunctions;

import javax.enterprise.context.ApplicationScoped;

import com.google.cloud.functions.BackgroundFunction;
import com.google.cloud.functions.Context;

@ApplicationScoped
public class HelloWorldBackgroundFunction implements BackgroundFunction<HelloWorldBackgroundFunction.StorageEvent> {

@Override
public void accept(StorageEvent event, Context context) throws Exception {
System.out.println("Receive event on file: " + event.name);
}

public static class StorageEvent {
public String name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.acme.googlecloudfunctions;

import java.io.Writer;

import javax.enterprise.context.ApplicationScoped;

import com.google.cloud.functions.HttpFunction;
import com.google.cloud.functions.HttpRequest;
import com.google.cloud.functions.HttpResponse;

@ApplicationScoped
public class HelloWorldHttpFunction implements HttpFunction {

@Override
public void service(HttpRequest httpRequest, HttpResponse httpResponse) throws Exception {
Writer writer = httpResponse.getWriter();
writer.write("Hello World");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ metadata:
- "cloud"
guide: "https://quarkus.io/guides/gcp-functions"
status: "experimental"
codestart: google-cloud-functions

0 comments on commit 205fc41

Please sign in to comment.