< 返回版块

长琴 发表于 2021-07-18 22:32

Tags:rust,日报

Quickwit:亚秒级延迟的对象存储搜索引擎

如果用过 ES,会感到非常熟悉,具体包括以下步骤:

第一步:编写索引配置文件 wiki_index_config.json(以 wiki 为例),保存到当前目录:

{
    "default_search_fields": ["body", "title"], // If you do not specify fields in your query, those fields will be used. 
    "field_mappings": [
        {
            "name": "body",
            "type": "text"
        },
        {
            "name": "title",
            "type": "text"
        },
        {
            "name": "url",
            "type": "text",
            "indexed": false, // Field not indexed, you will not be able to search on this field.
            "stored": false  // Field not stored. 
        }
    ]
}

第二步:创建索引:

$ ./quickwit new --index-uri file:///$(pwd)/wikipedia --index-config-path ./wiki_index_config.json

其中,wikipedia 是空文件夹

第三步:添加一些文档(需提前下载文档文件到当前目录):

./quickwit index --index-uri file:///$(pwd)/wikipedia --input-path wiki-articles-10000.json

文档看起来是这样:

$ head -1  wiki-articles-10000.json
{"url":"https://en.wikipedia.org/wiki?curid=48687903","title":"Jeon Hye-jin (actress, born 1988)","body":"\nJeon Hye-jin (actress, born 1988)\n\nJeon Hye-jin (born June 17, 1988) is a South Korean actress.\nPersonal life.\nJeon married his \"Smile, You\" co-star Lee Chun-hee on March 11, 2011. Their daughter, Lee So Yu, was born on July 30, 2011.\n\n"}

第四步:启动 Server:

$ ./quickwit serve --index-uri file:///$(pwd)/wikipedia

然后就可以进行 Query 了:

$ curl "http://0.0.0.0:8080/api/v1/wikipedia/search?query=barack+AND+obama"
# 指定 field
$ curl "http://0.0.0.0:8080/api/v1/wikipedia/search?query=body:barack+AND+obama"

文件目录如下:

$ tree . -L 2
.
├── quickwit
├── wiki-articles-10000.json
├── wiki_index_config.json
└── wikipedia
    ├── 7fc17075-3a78-4071-be53-e7941023c94a
    └── quickwit.json

噢,差点忘了,它还同时提供 gRPC 接口,默认 8082 端口;)

文档:Search more with less | Search more with less

GitHub 地址:quickwit-inc/quickwit: Quickwit is a highly cost-efficient search engine in Rust.

最后,顺带再安利一下另一个酷炫的搜索引擎:meilisearch/MeiliSearch: Powerful, fast, and an easy to use search engine

libreddit:用 Rust 编写的 Reddit 私有前端

一旦 cargo install libreddit 后,只需:

$ libreddit

Reddit 就启动了。

主页:Libreddit

GitHub 地址:spikecodes/libreddit: Private front-end for Reddit written in Rust

quiche:QUIC 和 HTTP/3 的实现

QUIC: QUIC - Wikipedia

GitHub 地址:cloudflare/quiche: 🥧 Savoury implementation of the QUIC transport protocol and HTTP/3

debug2:省空间的 Printer

正常打出来是这样的:

let complex_structure = vec![
    vec![Some(1), Some(2), Some(3), None],
    vec![Some(2), None],
    vec![Some(4), Some(7)],
    vec![Some(1), Some(2), Some(3), None],
];
// 单行
let one_line = format!("{:?}", complex_structure);
assert_eq!(one_line, "[[Some(1), Some(2), Some(3), None], [Some(2), None], [Some(4), Some(7)], [Some(1), Some(2), Some(3), None]]");
// 多行
let many_lines = format!("{:#?}", complex_structure);
assert_eq!(many_lines, "[
    [
        Some(
            1,
        ),
        Some(
            2,
        ),
        Some(
            3,
        ),
        None,
    ],
    [
        Some(
            2,
        ),
        None,
    ],
    [
        Some(
            4,
        ),
        Some(
            7,
        ),
    ],
    [
        Some(
            1,
        ),
        Some(
            2,
        ),
        Some(
            3,
        ),
        None,
    ],
]")

使用本模块转为 String 打出来是这样的:

use debug2::pprint;
let complex_structure = vec![
    vec![Some(1), Some(2), Some(3), None],
    vec![Some(2), None],
    vec![Some(4), Some(7)],
    vec![Some(1), Some(2), Some(3), None],
    vec![Some(2), None],
    vec![Some(4), Some(7)],
    vec![Some(1), Some(2), Some(3), None],
    vec![Some(2), None],
    vec![Some(4), Some(7)],
];
assert_eq!(
    pprint(complex_structure),
    "\
[
    [Some(1), Some(2), Some(3), None],
    [Some(2), None],
    [Some(4), Some(7)],
    [Some(1), Some(2), Some(3), None],
    [Some(2), None],
    [Some(4), Some(7)],
    [Some(1), Some(2), Some(3), None],
    [Some(2), None],
    [Some(4), Some(7)],
]"
);

看起来舒服多了。

GitHub 地址:aDotInTheVoid/debug2: Space Efficient Pretty Printer

quilkin:用于大型多人专用游戏服务器部署的非透明 UDP 代理

Quilkin 是一种非透明 UDP 代理,专门设计用于大型多人专用游戏服务器部署,以确保安全性、访问控制、遥测数据、指标等。

GitHub 地址:googleforgames/quilkin: Quilkin is a non-transparent UDP proxy specifically designed for use with large scale multiplayer dedicated game server deployments, to ensure security, access control, telemetry data, metrics and more.

一个教学目的的轻量 Web 浏览器

pubby

GitHub 地址:lmt-swallow/puppy-browser: An example implementation of a tiny Web browser for educational purposes.


From 日报小组 长琴

社区学习交流平台订阅:

评论区

写评论

还没有评论

1 共 0 条评论, 1 页