我正在尝试使用提供的文档将 redux 项目转换为打字稿:
https://redux.js.org/usage/usage-with-typescript#type-checking-middleware
但是我在使用自定义中间件时遇到了麻烦。这是导致我出错的最小化和提取的代码。
商店.ts:
import { configureStore } from '@reduxjs/toolkit';
import reducer from './customReducer';
import { customMiddleware } from "./customMiddleware";
const store = configureStore({
reducer: {
custom: customReducer
},
middleware: getDefaultMiddleware => getDefaultMiddleware().prepend(customMiddleware)
})
export type RootState = ReturnType<typeof store.getState>
export default store
Run Code Online (Sandbox Code Playgroud)
自定义中间件.ts:
import { Middleware } from 'redux';
import { RootState } from './store';
export const customMiddleware = (): Middleware<{}, RootState> => {
return store => next => action => {
return next(action);
}
}
Run Code Online (Sandbox Code Playgroud)
这会导致几条错误消息: …
我有一个大型的node.js monorepo,其中包含多个应用程序和程序包以及相互依存关系。全部由纱线工作区和一些lerna管理。一切对我来说都很好,但是我在尝试将此Monorepo中的应用程序之一部署到Google App Engine时遇到了麻烦。
主要问题是应用程序引擎想要安装仅位于本地且不在npm上的软件包,并且会引发错误。
我已经搜索了Google Cloud文档,但没有找到我可以用来指定自定义节点程序包的任何内容或类似内容。
有没有办法在不将本地软件包发布到npm的情况下进行这种部署?
我要部署的应用程序的基本结构如下所示:
-root
-packages
-packageA
-package.json
-apps
-deployable-app
-package.json <-contains dependency: "packageA": "0.0.1"
-app.yaml
Run Code Online (Sandbox Code Playgroud) google-app-engine node.js google-cloud-platform monorepo yarn-workspaces
我想使用 Google Cloud Build 来构建我的 docker 镜像。这些 docker 镜像使用从 Google Artifact Registry 下载的私有包。
构建器本身已通过身份验证并且可以使用该npx google-artifactregistry-auth命令。但我无法在 docker 构建过程中调用它。
当我在本地构建映像时,我将凭据传递到 Dockerfile 中,如下所示:
--build-arg GOOGLE_CREDS=\"$(cat $GOOGLE_APPLICATION_CREDENTIALS)\"
有没有办法让这项工作开箱即用,或者我是否必须创建一个单独的服务帐户并将其密钥作为云构建的秘密上传?有点烦人,因为这两个服务都在谷歌云上......
编辑:根据请求,我添加了有关在本地构建工件注册表时如何处理工件注册表的信息。我的泊坞窗命令是:
docker build --rm --build-arg GOOGLE_CREDS=\"$(cat $GOOGLE_APPLICATION_CREDENTIALS)\" -f 'Dockerfile' -t image:latest .
Run Code Online (Sandbox Code Playgroud)
docker 镜像的相关部分是:
ARG GOOGLE_CREDS
ENV GOOGLE_APPLICATION_CREDENTIALS=/credentials.json
RUN echo ${GOOGLE_CREDS} > $GOOGLE_APPLICATION_CREDENTIALS
COPY .npmrc_template /root/.npmrc
RUN npx google-artifactregistry-auth ~/.npmrc
RUN yarn install --silent
Run Code Online (Sandbox Code Playgroud)
.npmrc_template 包含有关私有存储库的详细信息,但没有密码。google-artifactregistry-auth然后通过命令填充
访问具有非常大表的数据库时,我当前的查询运行速度非常慢
SELECT *
FROM table1
WHERE timestamp BETWEEN 635433140000000000 AND 635433150000000000
AND ID IN ('element1', 'element2', 'element3', ... , 'element 3002');
Run Code Online (Sandbox Code Playgroud)
如您所见,该IN子句有数千个值。该查询大约每秒执行一次。
有没有另一种方法来编写它来提高性能?