无服务器框架v1-一项服务中的多个资源 [英] Serverless framework v1 - multiple resources in one service

查看:64
本文介绍了无服务器框架v1-一项服务中的多个资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个资源,游戏和玩家,都具有基本功能. 这些应该在同一无服务器服务中吗?我想将它们分开,但是如何将它们放在相同的api网关中?

I have two resources, games and players, both have crud functions. Are these supposed to be in the same serverless service? I would like to separate them, but how do I then put them in the same api gateway?

推荐答案

一种方法是使用无服务器来部署lambda,而手动设置API Gateway以将端点链接到lambda.

One way of doing what you want is to use serverless to deploy the lambdas but to manually set API Gateway to link the endpoints to the lambdas.

无服务器的限制如下: https://serverless .com/framework/docs/providers/aws/guide/services/

There is a restriction in serverless stated here: https://serverless.com/framework/docs/providers/aws/guide/services/

其中指出:

当前,每个服务都将在AWS API Gateway上创建一个单独的REST API.由于AWS API Gateway的限制,每个一个REST API只能有一个自定义域.如果您打算制作大型REST API,请注意此限制.此外,修复工作正在进行中,并且是当务之急.

Currently, every service will create a separate REST API on AWS API Gateway. Due to a limitation with AWS API Gateway, you can only have a custom domain per one REST API. If you plan on making a large REST API, please make note of this limitation. Also, a fix is in the works and is a top priority.

根据我们的经验,我们设法在客户端中提供具有不同API和路由对象的服务.

In our experience, we manage to have Services with different API and a routing object in our clients.

要确定它们是否应在同一无服务器服务中,您需要进入建模".在我们的情况下,我们回答以下问题:

To decide if they should be in the same serverless service, you need to get into Modeling. In our case, we answer this questions:

  1. 实体是否相关?
  2. 实体和方法是否会以相同的速度变化?
  3. 消费者是否要消费一组实体而不消费另一组实体?

当您更改游戏时,是否要更改玩家等?

When you change games are you going to change players, etc?

此链接可以为您提供答案: https://martinfowler.com/articles/microservices. html

This link can help you with that answer: https://martinfowler.com/articles/microservices.html

这篇关于无服务器框架v1-一项服务中的多个资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆