谷歌firebase_如何使用Firebase和Google Cloud Firestore构建事件记录系统

论坛 期权论坛     
选择匿名的用户   2021-5-29 21:39   204   0
<article style="font-size: 16px;">
<p>谷歌firebase</p>
<div>
  <section>
   <div>
    <div>
     <p>Firebase and Google Cloud Platform offer an excellent way to build apps and systems that can rapidly scale while providing a fantastic developer experience. At <a href="https://estatesync.io" rel="noopener noreferrer" target="_blank">EstateSync</a>, we use GCP services as the backend for our API to allow the fast distribution of real estate data to multiple vendors. Given the requirement to be able to scale to large amounts of data, we built our architecture on the premise of asynchronicity.</p>
     <p> Firebase和Google Cloud Platform提供了一种极好的方式来构建可快速扩展的应用程序和系统,同时提供出色的开发人员体验。 在<a href="https://estatesync.io" rel="noopener noreferrer" target="_blank">EstateSync</a> ,我们将GCP服务用作API的后端,以允许将房地产数据快速分发给多个供应商。 考虑到能够扩展到大量数据的要求,我们在异步性的前提下构建了体系结构。 </p>
     <p>Because of this, there is an obvious need to keep users informed about what is going on within the system.</p>
     <p> 因此,很明显需要使用户了解系统中正在发生的事情。 </p>
     <h1> 问题 <span style="font-weight: bold;">(</span>The Problem<span style="font-weight: bold;">)</span></h1>
     <p>Naturally in an asynchronous system, we can only provide the user with direct feedback for direct requests (e.g. when a request resource is invalid). To check if some event has occurred in the background, the user would need to query the API every time.</p>
     <p> 自然地,在异步系统中,我们只能为用户提供直接请求的直接反馈(例如,当请求资源无效时)。 为了检查后台是否发生了某些事件,用户每次都需要查询API。 </p>
     <p>This can be solved by webhooks — instead of having the user query our service for changes, we can notify the user. In Firebase, asynchronous work usually happens in Cloud Functions. Easily enough, at the end of whatever we do in a Cloud Function, we can just fire the user’s webhook by making a request to an URL he provided with a relevant payload (e.g. the entity that has been created in the background).</p>
     <p> 这可以通过webhooks来解决-我们可以通知用户,而不是让用户查询我们的服务以进行更改。 在Firebase中,异步工作通常在Cloud Functions中进行。 足够容易地,在我们执行Cloud Function的任何操作结束时,我们只要向用户提供的URL提供相关有效负载(例如,已在后台创建的实体)的请求,就可以触发用户的Webhook。 </p>
     <p>This does not scale, though. If the webhook response takes long (even with a reasonable timeout) this setup will prolong the processing time of the Cloud Function. It also means that we would be tying two systems (the asynchronous work and the webhook) together that should be independent. Also, this setup provides no option to deal with retries for failed webhook calls — no state is persisted, which means there is no easy way to retry failed requests or log errors.</p>
     <p> 但是,这不会扩展。 如果Webhook响应花费的时间很长(即使超时时间合理),此设置也会延长Cloud Function的处理时间。 这也意味着我们将把两个相互独立的系统(异步工作和Webhook)捆绑在一起。 另外,此设置没有选项来处理失败的Webhook调用的重试-没有状态保持不变,这意味着没有简单的方法可以重试失败的请求或记录错误。 </p>
     <p>Also, there is a different kind of information that can be produced asynchronously: Errors. These are the kind of events that developers receive email notifications about and that need to be addressed by the developer (e.g. by changing a configuration). For these there is usually no webhook implemented because they are supposed to not occur again after the initial cause is fixed. They too come with some form of payload to help with debugging. The user often wants access to these kinds of errors through a UI to check past issues and have a single source of truth and not just email notifications.</p>
     <p> 另外,还可以异步产生另一种信息:错误。 这些是开发人员接收有关电子邮件通知的事件,开发人员需要处理这些事件(例如,通过更改配置)。 对于这些,通常不实施任何Webhook,因为在确定了最初的原因之后,它们应该不会再出现。 它们也带有某种形式的有效负载以帮助调试。 用户通常希望通过UI访问这些类型的错误以检查过去的问题,并拥有单一的真实来源,而不仅仅是电子邮件通知。 </p>
     <p>So here we are, asynchronously generating both recurring system information and occasional errors. How can we build a robust architecture that takes both of them into account?</p>
     <p> 因此,在这里,我们异步生成重复出现的系统信息和偶然的错误。 我们如何建立一个将两者都考虑在内的健壮架构? </p>
     <h1> 一个办法 <span style="font-weight: bold;">(</span>A Solution<span s
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP