小编Loh*_*eek的帖子

使用 node.js 标准环境在 AppEngine 上找不到模块 @google-cloud/firestore

我已经使用node.js 标准环境AppEngine上部署了一个 cron ,以便定期更新我的 Firestore 数据库。

此文档之后,链接到此可用 npm 模块列表,我应该可以使用@google-cloud/firestore,但之后:

npm i --save @google-cloud/firestore

我收到以下错误:

Error: Cannot find module '@google-cloud/firestore'

在线:

var firestore = require('@google-cloud/firestore');
Run Code Online (Sandbox Code Playgroud)

我的 package.json 与 Hello World 示例相同:

{
  "name": "appengine-hello-world",
  "description": "Simple Hello World Node.js sample for Google App Engine Standard Environment.",
  "version": "0.0.1",
  "private": true,
  "license": "Apache-2.0",
  "author": "Google Inc.",
  "repository": {
    "type": "git",
    "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
  },
  "engines": {
    "node": "8.x.x"
  },
  "scripts": { …
Run Code Online (Sandbox Code Playgroud)

google-app-engine node.js firebase google-cloud-platform google-cloud-firestore

8
推荐指数
1
解决办法
2809
查看次数

在 Google App Engine 上持续集成/部署/交付,风险太大?

我们最近在 Google App Engine 上设置了一个 nodejs webapp 的持续集成/部署/交付。CI 服务器 (GitLabCI) 根据分支 (develop/master) 运行依赖项安装、构建、测试和部署到集成/生产。

在今天,我们面临的唯一错误是在依赖步骤期间,所以我们并没有太在意它。但是昨天(21/10/16)发生了大规模的 DNS 中断,并且管道在部署步骤中间失败,导致生产中断。只需重新运行管道即可完成工作,但问题随时可能重现。

我的问题是:

  • 在持续部署过程中,我们如何处理此类网络问题?
  • 在 Google App Engine 上持续部署真的是个好主意吗?
  • 如果是这样,App Engine 部署方法是什么?我没有找到任何相关的文档...

目前我们只有两个版本“dev”和“prod”在提交后更新,但在随机时间我可以观察到奇怪的行为。

非常欢迎任何回应/建议/反馈!

关于我正在谈论的网络问题的堆栈跟踪示例:

DEBUG: Error sending result: 'MetadataServerException(HTTPError(),)'. Reason: 'PicklingError("Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed",)'
Traceback (most recent call last):
  File "/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 733, in Execute
    resources = args.calliope_command.Run(cli=self, args=args)
  File "/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 1630, in Run
    resources = command_instance.Run(args)
  File "/google-cloud-sdk/lib/surface/app/deploy.py", line 53, in Run
    return deploy_util.RunDeploy(self, args)
  File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", …
Run Code Online (Sandbox Code Playgroud)

google-app-engine continuous-integration continuous-deployment continuous-delivery gitlab-ci

5
推荐指数
1
解决办法
1608
查看次数

核心模块是否应该在 Angular2 中导入共享模块

遵循关于如何构建 Angular 应用程序的几个建议,我最终得到了这个文件组织:

- app
    - core
        - header
        - sidenav
        core.module.ts
    - shared
        - material
            custom-material.module.ts
        shared.module.ts
    - features
    app.module.ts
Run Code Online (Sandbox Code Playgroud)
  • 我有一个核心模块和一个共享模块
  • 核心模块产品出口全球组件,如HeaderComponentSidenavComponent
  • 共享模块出口CustomMaterial子模块(我听说这是做事情的方式)
  • CustomMaterial子模块出口,我需要不同的材料成分
  • 应用模块仅导入芯模块(因为共享模块只能由需要它的元件被导入)
  • 中的模块features/是延迟加载的

但是现在,我的问题是:我的标题组件需要一些材料组件。

我应该将共享模块导入核心模块还是应用模块?但这对我来说似乎是一种反模式。

javascript angular-material angular

5
推荐指数
1
解决办法
916
查看次数

将Firebase模拟器与AngularFire结合使用

我正在尝试在Angular7应用程序中使用刚引入的Firestore模拟器

根据此文档,我使用以下命令运行开发服务器127.0.0.1:8080

firebase serve --only firestore
Run Code Online (Sandbox Code Playgroud)

然后,之后ng serve如何使AngularFire模块使用数据库模拟器

我尝试了以下内容environment.ts

export const environment = {
  production: false,
  name: 'local',
  firebase: {
    databaseURL: "http://127.0.0.1:8080"
  }
};
Run Code Online (Sandbox Code Playgroud)

但是它不起作用,因为它需要一个“ projectId”。我尝试将其设置为预生产的Firestore数据库,但随后未使用开发服务器。

有什么想法吗?

这是我的app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from '@app/app-routing.module';
import { AppComponent } from '@app/app.component';
import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore'; …
Run Code Online (Sandbox Code Playgroud)

javascript firebase angularfire2 angular google-cloud-firestore

5
推荐指数
5
解决办法
335
查看次数

带有父路由参数的角度延迟加载

我有ProfileModule以下路由:

// profile-routing.module

const routes: Routes = [
  {
    path: ':id',
    component: ProfilePageComponent,
    children: [
      {
        path: '',
        redirectTo: 'feed',
        pathMatch: 'full'
      },
      {
        path: 'feed',
        component: NewsFeedComponent
      },
      {
        path: 'gallery',
        component: MediasGalleryComponent
      }
    ]
  }
];
Run Code Online (Sandbox Code Playgroud)

它的工作原理如下:

  1. ProfilePageComponent 获取路由参数中的配置文件 ID 并将其发送到 ProfilePageService
  2. NewsFeedComponentMediasGalleryComponentProfilePageService

现在,这两个页面已移入两个单独的模块(分别为NewsModuleMediasModule),我希望在此路由中延迟加载。我不能再使用 ProfilePageService。我想出了这个解决方案:

// profile-routing.module

const routes: Routes = [
  {
    path: ':id',
    component: ProfilePageComponent,
    children: [
      {
        path: '',
        redirectTo: 'news/:id/feed', …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-routing angular

3
推荐指数
1
解决办法
1473
查看次数

具有关联类型的多态结构向量

我试图了解当使用具有关联类型的特征时多态性是如何工作的。考虑以下特征:

trait Animal {
    fn talk (&self);
}
Run Code Online (Sandbox Code Playgroud)

此特征由以下结构使用:

struct Dog;
struct Cow;

impl Animal for Dog {
    fn talk (&self) {
        println!("Woof");
    }
}

impl Animal for Cow {
    fn talk (&self) {
        println!("Moo");
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我循环 a Vec<&Animal>,多态性在这里工作得很好:

fn main() {
    let animals: Vec<&Animal> = vec![&Dog, &Cow];
    for animal in &animals {
        animal.talk();
    }
}
// output:
// Woof
// Moo
Run Code Online (Sandbox Code Playgroud)

到目前为止,一切都很好。现在,我向特征添加一个关联类型 Food(该类型未使用,但仅用于最小重现)。

struct Meat;
struct Herb;

trait Animal {
    type Food; …
Run Code Online (Sandbox Code Playgroud)

polymorphism rust

3
推荐指数
1
解决办法
1055
查看次数

使用多个免费套餐在 GAE 上托管 Web 应用程序

我有几个 Web 应用程序,我想将它们托管在 Google App Engine 上。最近,在我看来,定价发生了变化,免费套餐现在基于配额。我思考过以下问题:

考虑到应用程序要求和新配额,GCP 上的免费套餐应该允许我仅自由托管一个 Web 应用程序。为我的每个客户提供一个收费的 GCP 帐户,并使用他的帐户在他自己的 google 项目上托管他的 web 应用程序,以获得与 web 应用程序一样多的免费套餐怎么样?我错过了什么吗?

google-app-engine google-cloud-platform

0
推荐指数
1
解决办法
247
查看次数

为什么移位运算符似乎循环64位整数?

我正在尝试使用C++中的位数组数据结构.这是一种简单的好奇心,但我该如何解释:

uint64_t a = 1;
uint64_t b = a << 1;

cout << (a == (a << 64)) << endl; // get 1
cout << (a == (b << 63)) << endl; // get 0
Run Code Online (Sandbox Code Playgroud)

看起来像<< x是循环的时候x >= 64,但是填充用零填充x < 64.我错了吗 ?

如果没有,解释是什么?我认为64位整数不是自然周期性的.

c++ bit-manipulation bit-shift

-2
推荐指数
1
解决办法
58
查看次数