-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/firebase realtime database #724
Open
jfbenckhuijsen
wants to merge
7
commits into
quarkiverse:main
Choose a base branch
from
jfbenckhuijsen:feature/firebase-realtime-database
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
02a59ea
Add extension for Firebase Realtime Database
jfbenckhuijsen acc428f
Merge branch 'main' into feature/firebase-realtime-database
jfbenckhuijsen 80bac7c
Formatting fixes
jfbenckhuijsen 4761243
Fix realtime database hostoverride config property
jfbenckhuijsen d04a18c
Fix realtime database hostoverride config property
jfbenckhuijsen df1e910
Realtime database URLs must be prefixed with a scheme
jfbenckhuijsen 54a60d5
Merge branch 'quarkiverse:main' into feature/firebase-realtime-database
jfbenckhuijsen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
= Google Cloud Services - Firebase Admin | ||
|
||
This extension allows to inject a `com.google.cloud.firestore.Firestore` object inside your Quarkus application. | ||
|
||
This extension will pickup on any available `com.google.firebase.FirebaseApp` (see https://quarkiverse.github.io/quarkiverse-docs/quarkus-google-cloud-services/main/firebase-admin.html[Firebase Admin extension] for more info) to configure the Realtime Database. | ||
|
||
Be sure to have read the https://quarkiverse.github.io/quarkiverse-docs/quarkus-google-cloud-services/main/index.html[Google Cloud Services extension pack global documentation] before this one, it contains general configuration and information. | ||
|
||
== Bootstrapping the project | ||
|
||
First, we need a new project. Create a new project with the following command (replace the version placeholder with the correct one): | ||
|
||
[source, shell script] | ||
---- | ||
mvn io.quarkus:quarkus-maven-plugin:${quarkusVersion}:create \ | ||
-DprojectGroupId=org.acme \ | ||
-DprojectArtifactId=firebase-admin-quickstart \ | ||
-Dextensions="resteasy-reactive-jackson,quarkus-google-cloud-firebase-realtime-database" | ||
cd firebase-admin-quickstart | ||
---- | ||
|
||
This command generates a Maven project, importing the Google Cloud Firebase Realtime Database extension.) | ||
|
||
If you already have your Quarkus project configured, you can add the `quarkus-google-cloud-firebase-realtime-database` extension to your project by running the following command in your project base directory: | ||
|
||
[source, shell script] | ||
---- | ||
./mvnw quarkus:add-extension -Dextensions="quarkus-google-cloud-firebase-realtime-database" | ||
---- | ||
|
||
This will add the following to your pom.xml: | ||
|
||
[source, xml] | ||
---- | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-realtime-database</artifactId> | ||
</dependency> | ||
---- | ||
|
||
== Some example | ||
|
||
This is an example usage of the extension: we create a REST resource with a single endpoint that creates a 'persons' collection, inserts three persons in it, then search for persons with last name Doe and returns them. | ||
|
||
[source,java] | ||
---- | ||
import javax.inject.Inject; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import com.google.firebase.database.FirebaseDatabase; | ||
|
||
@Path("/database") | ||
public class RealtimeDatabaseResource { | ||
|
||
@Inject | ||
FirebaseDatabase database; // Inject database | ||
|
||
@POST | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
public void database(String data) { | ||
var dbRef = firebaseDatabase.getReference("test"); | ||
dbRef.setValueAsync(fields); | ||
} | ||
} | ||
---- | ||
|
||
== Dev Service | ||
|
||
This extension uses the https://quarkiverse.github.io/quarkiverse-docs/quarkus-google-cloud-services/main/firebase-devservices.html[Firebase Devservices] extension to provide a Dev Service. Refer the documentation of this extension for more info. | ||
|
||
== Configuration Reference | ||
|
||
include::./includes/quarkus-google-cloud-firebase-realtime-database.adoc[] |
28 changes: 28 additions & 0 deletions
28
...odules/ROOT/pages/includes/quarkus-google-cloud-firebase-realtime-database.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[.configuration-legend] | ||
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime | ||
[.configuration-reference.searchable, cols="80,.^10,.^10"] | ||
|=== | ||
|
||
h|[.header-title]##Configuration property## | ||
h|Type | ||
h|Default | ||
|
||
a| [[quarkus-google-cloud-firebase-realtime-database_quarkus-google-cloud-firebase-database-host-override]] [.property-path]##link:#quarkus-google-cloud-firebase-realtime-database_quarkus-google-cloud-firebase-database-host-override[`quarkus.google.cloud.firebase.database.host-override`]## | ||
|
||
[.description] | ||
-- | ||
Overrides the default service host. This is most commonly used for development or testing activities with a local Firebase Realtime Database emulator instance. | ||
|
||
|
||
ifdef::add-copy-button-to-env-var[] | ||
Environment variable: env_var_with_copy_button:+++QUARKUS_GOOGLE_CLOUD_FIREBASE_DATABASE_HOST_OVERRIDE+++[] | ||
endif::add-copy-button-to-env-var[] | ||
ifndef::add-copy-button-to-env-var[] | ||
Environment variable: `+++QUARKUS_GOOGLE_CLOUD_FIREBASE_DATABASE_HOST_OVERRIDE+++` | ||
endif::add-copy-button-to-env-var[] | ||
-- | ||
|string | ||
| | ||
|
||
|=== | ||
|
28 changes: 28 additions & 0 deletions
28
...es/includes/quarkus-google-cloud-firebase-realtime-database_quarkus.google.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[.configuration-legend] | ||
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime | ||
[.configuration-reference.searchable, cols="80,.^10,.^10"] | ||
|=== | ||
|
||
h|[.header-title]##Configuration property## | ||
h|Type | ||
h|Default | ||
|
||
a| [[quarkus-google-cloud-firebase-realtime-database_quarkus-google-cloud-firebase-database-host-override]] [.property-path]##link:#quarkus-google-cloud-firebase-realtime-database_quarkus-google-cloud-firebase-database-host-override[`quarkus.google.cloud.firebase.database.host-override`]## | ||
|
||
[.description] | ||
-- | ||
Overrides the default service host. This is most commonly used for development or testing activities with a local Firebase Realtime Database emulator instance. | ||
|
||
|
||
ifdef::add-copy-button-to-env-var[] | ||
Environment variable: env_var_with_copy_button:+++QUARKUS_GOOGLE_CLOUD_FIREBASE_DATABASE_HOST_OVERRIDE+++[] | ||
endif::add-copy-button-to-env-var[] | ||
ifndef::add-copy-button-to-env-var[] | ||
Environment variable: `+++QUARKUS_GOOGLE_CLOUD_FIREBASE_DATABASE_HOST_OVERRIDE+++` | ||
endif::add-copy-button-to-env-var[] | ||
-- | ||
|string | ||
| | ||
|
||
|=== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ public class FirebaseDevServiceProcessor { | |
FirebaseEmulatorContainer.Emulator.FIREBASE_HOSTING, "quarkus.google.cloud.firebase.hosting.emulator-host", | ||
FirebaseEmulatorContainer.Emulator.CLOUD_FUNCTIONS, "quarkus.google.cloud.functions.emulator-host", | ||
FirebaseEmulatorContainer.Emulator.EVENT_ARC, "quarkus.google.cloud.eventarc.emulator-host", | ||
FirebaseEmulatorContainer.Emulator.REALTIME_DATABASE, "quarkus.google.cloud.database.emulator-host", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it a backward incompatible change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That property was not yet actively used from the dev service, so I synced it with the other modules |
||
FirebaseEmulatorContainer.Emulator.REALTIME_DATABASE, "quarkus.google.cloud.firebase.database.host-override", | ||
FirebaseEmulatorContainer.Emulator.CLOUD_FIRESTORE, "quarkus.google.cloud.firestore.host-override", | ||
FirebaseEmulatorContainer.Emulator.CLOUD_STORAGE, "quarkus.google.cloud.storage.host-override", | ||
FirebaseEmulatorContainer.Emulator.PUB_SUB, "quarkus.google.cloud.pubsub.emulator-host"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-devservices-parent</artifactId> | ||
<version>2.14.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-google-cloud-firebase-realtime-database-deployment</artifactId> | ||
<name>Quarkus - Google Cloud Services - Firebase Realtime Database - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-common-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-realtime-database</artifactId> | ||
</dependency> | ||
<!-- Needed as Firebase Database depends on Firebase App --> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-admin</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-admin-deployment</artifactId> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-grpc-common</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-common-grpc</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${quarkus.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
22 changes: 22 additions & 0 deletions
22
...rkiverse/googlecloudservices/firebase/database/deployment/FirebaseDatabaseBuildSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.quarkiverse.googlecloudservices.firebase.database.deployment; | ||
|
||
import io.quarkiverse.googlecloudservices.firebase.database.FirebaseDatabaseProducer; | ||
import io.quarkus.arc.deployment.AdditionalBeanBuildItem; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.FeatureBuildItem; | ||
|
||
public class FirebaseDatabaseBuildSteps { | ||
|
||
private static final String FEATURE = "google-cloud-firebase-realtime-database"; | ||
|
||
@BuildStep | ||
public FeatureBuildItem feature() { | ||
return new FeatureBuildItem(FEATURE); | ||
} | ||
|
||
@BuildStep | ||
public AdditionalBeanBuildItem producer() { | ||
return new AdditionalBeanBuildItem(FirebaseDatabaseProducer.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-services-parent</artifactId> | ||
<version>2.14.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-google-cloud-firebase-realtime-database-parent</artifactId> | ||
<name>Quarkus - Google Cloud Services - Firebas Realtime Database</name> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>runtime</module> | ||
<module>deployment</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-realtime-database-parent</artifactId> | ||
<version>2.14.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-google-cloud-firebase-realtime-database</artifactId> | ||
<name>Quarkus - Google Cloud Services - Firebase Realtime Database - Runtime</name> | ||
<description>Use Google Cloud Firebase</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-common</artifactId> | ||
</dependency> | ||
<!-- Needed as Firebase Database depends on Firebase App --> | ||
<dependency> | ||
<groupId>io.quarkiverse.googlecloudservices</groupId> | ||
<artifactId>quarkus-google-cloud-firebase-admin</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-maven-plugin</artifactId> | ||
<version>${quarkus.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>extension-descriptor</goal> | ||
</goals> | ||
<phase>compile</phase> | ||
<configuration> | ||
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version} | ||
</deployment> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${quarkus.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
...ain/java/io/quarkiverse/googlecloudservices/firebase/database/FirebaseDatabaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.quarkiverse.googlecloudservices.firebase.database; | ||
|
||
import java.util.Optional; | ||
|
||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.smallrye.config.ConfigMapping; | ||
|
||
/** | ||
* Root configuration class for Google Cloud Firebase Realtime database setup. | ||
* | ||
*/ | ||
@ConfigMapping(prefix = "quarkus.google.cloud.firebase.database") | ||
@ConfigRoot(phase = ConfigPhase.RUN_TIME) | ||
public interface FirebaseDatabaseConfig { | ||
|
||
/** | ||
* Overrides the default service host. | ||
* This is most commonly used for development or testing activities with a local Firebase Realtime Database emulator | ||
* instance. | ||
*/ | ||
Optional<String> hostOverride(); | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't seems to be accurate as Firestore is from a different extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, good catch