我试图了解nodeJS中的线程池。通过创建运行代码process.env.UV_THREADPOOL_SIZE = 5;
process.env.UV_THREADPOOL_SIZE = 5;
const https = require('https');
const crypto = require('crypto');
const fs = require('fs');
const start = Date.now()
function doRequest() {
https.request('https://google.com', res => {
res.on('data', () => {});
res.on('end', () => {
console.log('Request:', Date.now() - start)
})
})
.end()
}
function doHash(){
crypto.pbkdf2("a", "b", 100000, 512, 'sha512', () => {
console.log("Hash:", Date.now() - start);
})
}
doRequest();
fs.readFile('multitask.js', 'utf8', () => {
console.log('fs:', Date.now() - start)
});
doHash();
doHash();
doHash();
doHash();Run Code Online (Sandbox Code Playgroud)
我在终端中得到输出:
我刚刚开始使用 docker。我安装了 docker 的 Windows 版本,并遵循了https://hub.docker.com/?overlay=onboarding 中给出的一些基本步骤。无法构建 docker 文件。
我刚刚通过以下方式克隆了一个 git repo:
git clone https://github.com/docker/doodle.git
然后尝试构建docker
cd doodle\cheers2019 ;
docker build -t myrepo/cheers2019 .
我在命令行上收到响应:
Sending build context to Docker daemon 13.31kB
Step 1/9 : FROM golang:1.11-alpine AS builder
1.11-alpine: Pulling from library/golang
no matching manifest for windows/amd64 10.0.18362 in the manifest list entries
DokerFile 有
FROM golang:1.11-alpine AS builder
RUN apk add --no-cache git
RUN go get github.com/pdevine/go-asciisprite
WORKDIR /project
COPY cheers.go .
RUN CGO_ENABLED=0 GOOS=linux go …Run Code Online (Sandbox Code Playgroud) 有没有办法切换Stancl/Tenancy模块中的DB环境?由于我之前使用过一些其他租赁模块,因此当我想要从租户内的中央域访问某些资源时,我会切换环境,反之亦然。
为什么要添加这个我试图获取租户的计划和功能,并希望从中央域 (DB) 获取更多数据。例如,我为租户和中央用户命名了订阅和计划表,当我尝试从中央域获取租户用户的订阅时,它会从租户数据库返回数据。
namespace App\Helpers;
use App\Models\System\Admin\Subscription;
public static function checkTenantPlan()
{
// Find the tenant
// get the tenantId and find that
$tenant_user_id = tenant()->user_id;
// Find the subscription of the tenant User
$subscription = Subscription::where('user_id', $tenant_user_id)
->orderBy('created_at', 'desc')
->first();
return $subscription->plan(); //returning the data from the current tenant db
}
Run Code Online (Sandbox Code Playgroud)