我写了一个vibe.d
web-UI clang-format
,当使用LLVM样式时显示此输入时,服务器挂起.
处理POST的代码:
void post(string style, string code)
{
import std.algorithm;
import std.file;
import std.conv;
import std.process;
auto pipes = pipeProcess(["clang-format", "-style="~style], Redirect.stdout | Redirect.stdin);
scope(exit) wait(pipes.pid);
pipes.stdin.write(code);
pipes.stdin.close;
pipes.pid.wait;
code = pipes.stdout.byLine.joiner.to!string;
string selectedStyle = style;
render!("index.dt", styles, code, selectedStyle);
}
Run Code Online (Sandbox Code Playgroud)
这可能不应该以阻塞的方式完成,但我不知道如何异步地执行它.我已经尝试包装函数的内容runTask
,但我找不到正确调用它的方法.
我怎样才能让它可靠?
我无法理解使用ArangoDB进行日期存储的格式.尝试以这种格式插入日期:
{"name": "vasia", "date": date("2013-01-15")}
std.json.JSONException@C:\vibe-d-0.7.24\source\vibe\data\json.d(1116): (1): Error: Expected valid JSON token, got 'date("2013-0'.
看起来这个字符串上的振动JSON模块失败了,但使用Arango的格式是什么?
{"name":"vasia","date":"2013-01-15"}
在DB中成功插入格式的字符串,但我无法理解它是作为文本还是作为Date对象插入?
当库通过静态初始化程序运行时,Vibe.D 是否具有内置终止函数?我想在 vibe.d 抛出异常时终止应用程序,例如打开文件。
我有一个服务器正在使用该listenHTTP
功能进行侦听。
我知道Vibe.D实现基于Fibers.但我不知道Vibe.D如何处理高负载情况.它是Vibe.D中的调度程序在多个线程上分配光纤还是仅为所有光纤分配一个线程?
这种考虑非常重要,因为即使纤维的高效率浪费了大量的CPU时间,也只有一个线程用于参与所有传入的请求.
我想使用 CTFE 遍历 JSON。我已经尝试过 std.json 和 vibe.data.json,但没有运气。我不确定我错过了什么。
import std.stdio;
import std.json;
import std.array;
import vibe.data.json;
void main()
{
enum string config = `{ "ModelNames": [ "Bank", "Biller", "Aggregator" ] }`;
const auto c1 = parseJSON(config);
immutable auto c2 = parseJsonString(config);
foreach (key; c1["ModelNames"].array)
writeln(key.get!string);
foreach (key; c2["ModelNames"])
writeln(key.get!string);
// static foreach (key; c1["ModelNames"].array)
// pragma(msg, key.get!string);
// static foreach (key; c2["ModelNames"])
// pragma(msg, key.get!string);
}
Run Code Online (Sandbox Code Playgroud)