如何在一个不使用任何加载器的旧javascript应用程序中加载RxJS?
对于RxJS 4.x,我可以这样做:
<script src="//cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.7/rx.lite.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
RxJS 5怎么样?他们的文档假设您正在使用某种类型的加载器来处理所有事情,但是对于遗留应用程序的中间步骤,当没有加载器时,只是在构建时打包的文件?
他们还提到了通过仅包含用于"尺寸敏感捆绑"的功能来创建自己的捆绑包的能力,这听起来很棒.
所以我应该创建一个入口点文件然后将其添加到我的构建过程并使用某种工具(browserify/gluejs/webmake)将所有内容构建到一个文件中,就像在RxJS4中将Rx(或简称Observable)暴露为全局变量?,例如:
// run this through some tool to make it available in browser simply as Observable
var Observable = require('rxjs/Observable').Observable;
require('rxjs/add/operator/map');
exports=Observable
Run Code Online (Sandbox Code Playgroud) 有没有办法查看吊舱终止状态的历史记录?例如。如果查看pod describe命令,则会看到类似以下的输出:
State: Running
Started: Mon, 10 Jul 2017 13:09:20 +0300
Last State: Terminated
Reason: OOMKilled
Exit Code: 137
Started: Thu, 06 Jul 2017 11:01:21 +0300
Finished: Mon, 10 Jul 2017 13:09:18 +0300
Run Code Online (Sandbox Code Playgroud)
pod describePod事件中没有显示相同的内容:
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
10m 10m 1 kubelet, gke-dev-default-d8f2dbc5-mbkb spec.containers{demo} Normal Pulled Container image "eu.gcr.io/project/image:v1" already present on machine
10m 10m 1 kubelet, gke-dev-default-d8f2dbc5-mbkb spec.containers{demo} Normal Created Created container …Run Code Online (Sandbox Code Playgroud) 目前我有几个html文件,如下所示:
<!-- build:js({.tmp,app}) scripts/moduleX-scripts.js -->
<script src="scripts/moduleX/moduleXConfig.js"></script>
<script src="scripts/moduleX/featureX/controller.js"></script>
<script src="scripts/moduleX/featureX/service.js"></script>
<script src="scripts/moduleX/featureY/controller.js"></script>
<script src="scripts/moduleX/featureY/service.js"></script>
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/moduleY-scripts.js -->
<script src="scripts/moduleY/moduleYConfig.js"></script>
<script src="scripts/moduleY/featureW/controller.js"></script>
<script src="scripts/moduleY/featureW/service.js"></script>
<script src="scripts/moduleY/featureZ/controller.js"></script>
<script src="scripts/moduleY/featureZ/service.js"></script>
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)
由于这是一个角度应用程序,我想使用ocLazyLoad来管理我的模块,所以我的配置看起来像这样:
angular.module('MyMainModule', [
{
name: 'moduleX',
files: [
'scripts/moduleX/moduleXConfig.js',
'scripts/moduleX/featureX/controller.js',
'scripts/moduleX/featureX/service.js',
'scripts/moduleX/featureY/controller.js',
'scripts/moduleX/featureY/service.js',
]
},
{
name: 'moduleY',
files: [
'scripts/moduleY/moduleYConfig.js',
'scripts/moduleY/featureW/controller.js',
'scripts/moduleY/featureW/service.js',
'scripts/moduleY/featureZ/controller.js',
'scripts/moduleY/featureZ/service.js',
]
}
])
Run Code Online (Sandbox Code Playgroud)
是否有任何grunt插件可以处理这个.js文件并files用缩小和修订版本替换该数组?
我正在尝试将大型节点代码库迁移到TypeScript.为了简化操作,我只想首先将.js文件重命名为.ts文件,修复任何语义问题,不需要太多重构,然后逐步改进代码库.
让我们考虑以下示例:
logger.js:
exports = function(string) {
console.log(string);
}
Run Code Online (Sandbox Code Playgroud)
moduleA.js:
var logger = require('./logger')
exports.someAction = function() {
logger.log('i'm in module a')
}
Run Code Online (Sandbox Code Playgroud)
moduleB.js:
//var logger = require('./logger')
exports.someOtherAction = function() {
logger.log('i'm in module B')
}
Run Code Online (Sandbox Code Playgroud)
moduleC.js:
var moduleA = require('./moduleA');
var moduleB = require('./moduleB');
exports.run = function(string) {
moduleA.someAction();
moduleB.someOtherAction(); //exception here - logger not defined
}
Run Code Online (Sandbox Code Playgroud)
因此,如果我执行moduleB.someOtherAction(),我将得到一个异常,因为logB没有在moduleB.js的范围中定义.
但是typescript编译得很好,因为logger是在moduleA中声明的,这是因为(如果我理解的话)typescript将所有这些文件视为单个编译单元.
那么无论如何都要避免这种情况而不进行太多重构?
更新
我已经创建了一个示例项目,可以在这里找到 如果我运行typescript编译器,我没有得到任何错误,虽然logB在moduleB.ts中被注释掉了:
g@w (master) ~/projects/ts-demo: gulp generate
[10:39:46] Using gulpfile ~/projects/ts-demo/gulpfile.js
[10:39:46] Starting 'generate'...
[10:39:46] Starting …Run Code Online (Sandbox Code Playgroud) 我有postgresql,它将一些数据存储为json字段,例如:
{"adults":2,"children":{"total":0,"ages":[]}}
Run Code Online (Sandbox Code Playgroud)
我正在使用logstash-input-jdbc插件来处理数据
如何从jdbc解析json?从日志中我看到字段作为PGObject到达:
"travelers_json" => #<Java::OrgPostgresqlUtil::PGobject:0x278826b2>
Run Code Online (Sandbox Code Playgroud)
它有value和type属性.
我尝试过使用json过滤器,但我不知道如何访问该value属性以提供给json过滤器?我尝试过的:
source => "[travelers_json][value]"
source => "travelers_json.value"
source => "%{travelers_json.value}"
Run Code Online (Sandbox Code Playgroud)
我一定错过了一些非常明显的东西吗?
我正在尝试解决从 node.js 到远程 http api 的请求花费太长时间的问题。首先,我决定向我的节点应用程序添加计时:
'use strict';
let logger = require('./logger');
let request = require('request');
module.exports = function(uri, done) {
// set full url.
let options = {
uri: `http://example.org/${uri}`,
timeout: 60000,
json: true,
gzip: true,
encoding: null
};
const startDate = new Date().getTime();
const start = process.hrtime();
request(options, function(error, response, body) {
const endDate = new Date().getTime();
const end = process.hrtime(start);
const durationDate = endDate - startDate;
const duration = end[1] / 1000000;
const diff = Math.abs(Math.round(durationDate - …Run Code Online (Sandbox Code Playgroud) 我需要在运行我们的应用程序之前更新我的数据库架构。为此,基于此线程和此答案,我决定使用 init 容器来完成这项工作。
由于我的 SQL 实例是托管的 Google Cloud SQL 实例,因此我需要gce-proxy能够连接到数据库。我的 initContainers 看起来像这样:
initContainers:
- name: cloudsql-proxy-init
image: gcr.io/cloudsql-docker/gce-proxy:1.09
command: ["/cloud_sql_proxy"]
args:
- --dir=/cloudsql
- -instances=xxxx:europe-west1:yyyyy=tcp:5432
- -credential_file=/secrets/cloudsql/credentials.json
volumeMounts:
- name: dev-db-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
- name: ssl-certs
mountPath: /etc/ssl/certs
- name: cloudsql
mountPath: /cloudsql
- name: liquibase
image: eu.gcr.io/xxxxx/liquibase:v1
imagePullPolicy: Always
command: ["./liquibase.sh"]
env:
- name: DB_TYPE
value: postgresql
- name: DB_URL
value: jdbc:postgresql://localhost/test
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-credentials
key: password …Run Code Online (Sandbox Code Playgroud) 具有RxJs的角度1.5分量的伪代码:
component('demo', {
template: `<div>
<div ng-if="verificationFailed">Sorry, failed to verify</div>
<button ng-if="continueEnabled">Continue</button>
<button ng-click="verify()">Verify</button>
</div>`,
controllerAs: 'ctrl',
bindings: {
someOptions: '='
},
controller: ($scope, someService) => {
var ctrl = this;
ctrl.continueEnabled = false;
ctrl.verificationFailed = false;
ctrl.verify = function() {
Rx
.Observable
.interval(10 * 1000)
.timeout(2 * 60 * 1000)
.flatMapLatest(_ => { someService.verify(ctrl.someOptions.id)})
.retry(1)
.filter((result) => { result.completed })
.take(1)
.subscribe(_ => {
$scope.$evalAsync(_ => {
ctrl.continueEnabled = true
});
}, _ => {
$scope.$evalAsync(() => {
ctrl.verificationFailed …Run Code Online (Sandbox Code Playgroud) 我们有一个在GKE Kubernetes上运行的应用程序,它希望auth url(用户将通过他的浏览器重定向)作为环境变量传递.
我们在每个环境中使用不同的命名空间
所以我们当前的pod配置看起来像这样:
env:
- name: ENV
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: AUTH_URL
value: https://auth.$(ENV).example.org
Run Code Online (Sandbox Code Playgroud)
所有工作都令人惊讶,我们可以拥有任意数量的动态环境,我们只需要应用-f config.yaml,它可以完美地工作而无需更改单个配置文件和任何第三方脚本.
现在生产我们想要使用不同的域,因此一般模式https://auth.$(ENV).example.org不再起作用.
我们有什么选择?
prod环境创建一个单独的分支prod-config.yaml然后使用它,否则使用config.yaml) - 但是这种方法我们不能再直接使用kubectl了prodenv 配置单独的配置文件- 但这种情况与12factor应用程序相反?我一般会从客户端转到kubernetes集群进行身份验证,我看到我有两个选择:
因此,很容易从clusterA访问clusterA,但不能从clusterA访问clusterB。
我在这里有什么选择?看来我只是无法过关GOOGLE_APPLICATION_CREDENTIALS,希望客户去照顾自己。
所以我的想法是:
gcloud container clusters get-credentials clusterA和gcloud container clusters get-credentials clusterBBuildConfigFromFlags上clusteA在这是正确的方法,还是有更简单的方法?我看到代币有有效期吗?
更新:
看来我也可以用CLOUDSDK_CONTAINER_USE_CLIENT_CERTIFICATE=True gcloud beta container clusters get-credentials clusterB --zone。这将证书添加到我可以使用的kube conf中。但是AFAIK不能撤消那些证书
kubernetes ×4
javascript ×3
angularjs ×2
node.js ×2
grunt-usemin ×1
gruntjs ×1
logstash ×1
rxjs ×1
rxjs5 ×1
typescript ×1