具有 Google Cloud Functions 的 Funqy HTTP 绑定
如果您想允许 HTTP 客户端在 Google Cloud Functions 上调用您的 Funqy 函数,Quarkus 允许您通过 HTTP 公开多个 Funqy 函数,并将它们部署为一个 Google Cloud Function。 这种方法确实会比常规的 Funqy Google Cloud Function 集成增加一些开销。
|
此技术被认为是预览版。 在预览阶段,不保证向后兼容性和在生态系统中的存在。 具体改进可能需要更改配置或 API,并且正在制定稳定计划。 欢迎通过我们的邮件列表或在我们的GitHub 问题跟踪器中提出反馈意见。 有关可能的完整状态列表,请查看我们的常见问题解答条目。 |
请遵循 Google Cloud Functions Http 指南。它将指导您在 Google Cloud Functions 上使用各种 HTTP 框架,包括 Funqy。
| Funqy HTTP + Google Cloud Functions 绑定不能替代基于 HTTP 的 REST。 因为 Funqy 需要在许多不同的协议和函数提供程序之间移植,所以它的 HTTP 绑定非常精简,您将失去 REST 的功能,例如链接和利用 HTTP 功能(例如缓存控制和条件 GET)的能力。 您可能需要考虑使用 Quarkus 的 Jakarta REST、Spring MVC 或 Vert.x Web Reactive Route 支持。 它们也适用于 Quarkus 和 Google Cloud Functions。 |
附加的快速入门
除了生成 Google Cloud Functions HTTP 指南中介绍的 Google Cloud Functions 项目之外,还有一个用于在 Google Cloud Functions 上运行 Funqy HTTP 的快速入门。
克隆 Git 存储库:git clone https://github.com/quarkusio/quarkus-quickstarts.git,或下载 archive。
解决方案位于 funqy-google-cloud-functions-http-quickstart 目录中。
代码
代码没有什么特别之处,更重要的是没有任何 Google Cloud 特定的东西。 Funqy 函数可以部署到许多环境,而 Google Cloud Functions 只是其中之一。 Java 代码实际上与 funqy-http-quickstart 中的代码完全相同。
入门
运行此快速入门的步骤与 Google Cloud Functions HTTP 指南中定义的步骤完全相同。 不同之处在于您是从快速入门运行,并且 Maven 依赖项略有不同。
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-funqy-http</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-google-cloud-functions-http</artifactId>
</dependency>
implementation("io.quarkus:quarkus-funqy-http")
implementation("io.quarkus:quarkus-google-cloud-functions-http")