This commit is contained in:
梁显优 2023-07-18 01:11:42 +08:00
parent 6448bd8709
commit 5fbc3082c7
45 changed files with 516 additions and 666 deletions

View File

@ -1,12 +0,0 @@
---
slug: first-blog-post
title: First Blog Post
authors:
name: Gao Wei
title: Docusaurus Core Team
url: https://github.com/wgao19
image_url: https://github.com/wgao19.png
tags: [hola, docusaurus]
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

View File

@ -1,44 +0,0 @@
---
slug: long-blog-post
title: Long Blog Post
authors: endi
tags: [hello, docusaurus]
---
This is the summary of a very long blog post,
Use a `<!--` `truncate` `-->` comment to limit blog post size in the list view.
<!--truncate-->
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet

View File

@ -1,20 +0,0 @@
---
slug: mdx-blog-post
title: MDX Blog Post
authors: [slorber]
tags: [docusaurus]
---
Blog posts support [Docusaurus Markdown features](https://docusaurus.io/docs/markdown-features), such as [MDX](https://mdxjs.com/).
:::tip
Use the power of React to create interactive blog posts.
```js
<button onClick={() => alert('button clicked!')}>Click me!</button>
```
<button onClick={() => alert('button clicked!')}>Click me!</button>
:::

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

View File

@ -1,25 +0,0 @@
---
slug: welcome
title: Welcome
authors: [slorber, yangshun]
tags: [facebook, hello, docusaurus]
---
[Docusaurus blogging features](https://docusaurus.io/docs/blog) are powered by the [blog plugin](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog).
Simply add Markdown files (or folders) to the `blog` directory.
Regular blog authors can be added to `authors.yml`.
The blog post date can be extracted from filenames, such as:
- `2019-05-30-welcome.md`
- `2019-05-30-welcome/index.md`
A blog post folder can be convenient to co-locate blog post images:
![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg)
The blog supports tags as well!
**And if you don't want a blog**: just delete this directory, and use `blog: false` in your Docusaurus config.

View File

@ -15,3 +15,9 @@ slorber:
title: Docusaurus maintainer title: Docusaurus maintainer
url: https://sebastienlorber.com url: https://sebastienlorber.com
image_url: https://github.com/slorber.png image_url: https://github.com/slorber.png
lxy:
name: 绝尘
title: 软件工程师
url: https://gitee.com/tc608
image_url: https://img.1216.top/art/u93.png

51
blog/system-keep-live.md Normal file
View File

@ -0,0 +1,51 @@
---
slug: using-systemd-to-keep-a-program-running
title: "使用 Systemd 保持 Linux 系统中的程序长时间保活"
authors: lxy
tags: [ Linux, Systemd ]
---
假设我们有一个可执行程序 `app.sh`(类比 Windows 下的 `app.exe`),我们想用 systemd 进行管理,并保证其在任何情况下都能够保活。下面是具体步骤:
1. 编写 systemd 服务管理配置文件 `/opt/app/app.service`
`[Unit]` 段落中编写一个描述性语句,让人们了解你正在管理什么。在 `[Service]` 段落中定义服务的各个参数:
- `Type=forking` 表示当该服务启动时systemd 假定它会再派生出一个子进程(即父子进程)。这是最常见的 service 类型。
- `ExecStart=` 定义将要启动的可执行程序路径。
- `ExecReload=` 定义重新加载服务时要运行的命令或脚本。
- `Restart=` 当服务失败时自动重启,`always` 是指总是重启,其他选项为 `on-failure``never`
- `WantedBy=multi-user.target` 将这个服务加入启动所需的目标之一。在多用户系统中,`multi-user.target`
是把计算机带到用户登录界面的主要目标。
示例配置如下:
```shell
[Unit]
Description=app daemon
[Service]
Type=forking
ExecStart=/opt/app/app.sh
ExecReload=/opt/app/app.sh
Restart=always
[Install]
WantedBy=multi-user.target
```
2. 将服务管理配置文件做软链接到 `/usr/lib/systemd/system/` 目录下。
通过软链接可以方便地维护服务管理配置文件。示例命令如下:
```shell
ln -s /opt/app/app.service /usr/lib/systemd/system/app.service
```
3. 将 `app.service` 加入系统开机自启动。
```shell
systemctl enable app.service
```
4. 启动程序。
```shell
systemctl start app
```
到此为止,原本的可执行程序 `app.sh` 就已经被 systemd 管理,并保证其在任何情况下都能够保活。

View File

@ -2,46 +2,69 @@
sidebar_position: 1 sidebar_position: 1
--- ---
# Tutorial Intro # 快速开始
Let's discover **Docusaurus in less than 5 minutes**. 让我们在 **5分钟内完成 zhub 组件安装**.
## Getting Started ## 开始
Get started by **creating a new site**. 从零开始 **搭建 zhub 服务**.
Or **try Docusaurus immediately** with **[docusaurus.new](https://docusaurus.new)**. ### 下载软件包
### What you'll need - [zhub.zip](https://baidu.com) 包含以下内容:
- 绿色版本 Window 和 Linux 运行包
- [Node.js](https://nodejs.org/en/download/) version 16.14 or above: - 配置文件: app.ini
- When installing Node.js, you are recommended to check all checkboxes related to dependencies. - java连接驱动zhub-clien.jar
![zhub-zip.png](https://img.1216.top/docs/zhub-zip.png)
## Generate a new site ### 配置 app.ini
Generate a new Docusaurus site using the **classic template**.
The classic template will automatically be added to your project after you run the command:
```bash ```bash
npm init docusaurus@latest my-website classic # app.ini
[log]
handlers=console # console|file
level=debug # info|debug|error
file=zhub.log
[service]
watch=0.0.0.0:711
addr=0.0.0.0:1216
auth=1 # 是否开启连接授权
[data]
dir=D:/data # 数据目录
[ztimer] # timer 使用的数据库配置
db.addr=47.111.150.118:6063
db.user=root
db.password=*Zhong@0510!
db.database=zhub
[auth]
admin=123456 # 授权连接账号 admin@123456
lxy=123456
``` ```
You can type this command into Command Prompt, Powershell, Terminal, or any other integrated terminal of your code editor. ### 启动服务
The command also installs all necessary dependencies you need to run Docusaurus.
## Start your site
Run the development server:
```bash ```bash
cd my-website # window
npm run start ./zhub.exe
# linux
./zhub.sh
``` ```
The `cd` command changes the directory you're working with. In order to work with your newly created Docusaurus site, you'll need to navigate the terminal there. ## 使用
### Java 客户端连接
```java
ZhubClient zhub = new ZhubClient("", "");
zhub.subscribe("topic-x", x -> {
// do something.
});
```
### Java 客户端连接
The `npm run start` command builds your website locally and serves it through a development server, ready for you to view at http://localhost:3000/.
Open `docs/intro.md` (this page) and edit some lines: the site **reloads automatically** and displays your changes.

7
docs/oth/_category_.json Normal file
View File

@ -0,0 +1,7 @@
{
"label": "其他常用",
"position": 5,
"link": {
"type": "generated-index"
}
}

18
docs/oth/a.md Normal file
View File

@ -0,0 +1,18 @@
---
sidebar_position: 1
---
# 一些命令
```shell title='在 Windows 环境下,项目打包成 zip 文件:'
# rem 请将“my-site”替换为您想要命名的 zip 文件名称,这将创建一个名为 "my-site.zip" 的 zip 文件。
powershell Compress-Archive -Path build -DestinationPath my-site.zip
```
```shell title='docusaurus 常用命令'
pnpm run build # 构建
pnpm run start # 启动
pnpm run serve # 启动(服务模式)
```

View File

@ -0,0 +1,7 @@
{
"label": "Redkale",
"position": 4,
"link": {
"type": "generated-index"
}
}

View File

@ -0,0 +1,5 @@
---
sidebar_position: 3
---
# 进阶功能

View File

@ -0,0 +1,7 @@
{
"label": "进阶功能",
"position": 3,
"link": {
"type": "generated-index"
}
}

View File

@ -0,0 +1,6 @@
---
sidebar_position: 2
---
# 核心功能

View File

@ -0,0 +1,7 @@
{
"label": "核心功能",
"position": 2,
"link": {
"type": "generated-index"
}
}

View File

@ -0,0 +1,77 @@
---
sidebar_position: 1
---
# 快速开始
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
<Tabs>
<TabItem value="apple" label="Apple" default>
This is an apple 🍎
</TabItem>
<TabItem value="orange" label="Orange">
This is an orange 🍊
</TabItem>
<TabItem value="banana" label="Banana">
This is a banana 🍌
</TabItem>
</Tabs>
好的,以下是对应的文件名和目录结构:
- 1.md : 入门指南
- 1.1 安装和配置.md
- 1.2 Hello World.md
- 1.3 架构概述.md
- 2.md : 核心功能
- 2.1 控制器.md
- 2.2 过滤器.md
- 2.3 模板引擎.md
- 2.4 数据库访问.md
- 2.5 缓存.md
- 2.6 安全.md
- 2.7 日志.md
- 2.8 监控.md
- 3.md : 进阶功能
- 3.1 异步处理.md
- 3.2 高并发支持.md
- 3.3 集群部署.md
- 3.4 扩展机制.md
- 4.md : 工具支持
- 4.1 IDEA 插件.md
- 4.2 Maven 插件.md
- 4.3 工具集成.md
----
好的,以下是使用英文文件名的 Redkale 文档目录结构:
- getting-started: Getting Started
- 1-installation-and-configuration.md: Installation and Configuration
- 2-hello-world.md: Hello World
- 3-architecture-overview.md: Architecture Overview
- core-features: Core Features
- 1-controller.md: Controller
- 2-filter.md: Filter
- 3-template-engine.md: Template Engine
- 4-database-access.md: Database Access
- 5-cache.md: Cache
- 6-security.md: Security
- 7-logging.md: Logging
- 8-monitoring.md: Monitoring
- advanced-features.md: Advanced Features
- 1-asynchronous-processing.md: Asynchronous Processing
- 2-high-concurrency-support.md: High Concurrency Support
- 3-clustering-deployment.md: Clustering Deployment
- 4-extension-mechanism.md: Extension Mechanism
- tool-support.md: Tool Support
- 1-idea-plugin.md: IDEA Plugin
- 2-maven-plugin.md: Maven Plugin
- 3-tool-integration.md: Tool Integration
请注意,文件名以及目录结构只是一种规范,您可以根据实际需求进行修改和扩展。同时编写文档时要尽可能地清晰简洁、易于阅读和理解,并且遵循文档写作的标准规范和最佳实践。
请注意,本程序只能进行文档基础目录结构的整理,具体内容需要您自己针对 Redkale 进行整理编写。另外,如有需要,您还可以进一步细分和拓展目录结构,以适应实际需求。

View File

@ -0,0 +1,7 @@
{
"label": "快速开始",
"position": 1,
"link": {
"type": "generated-index"
}
}

View File

@ -0,0 +1,5 @@
---
sidebar_position: 3
---
# 架构概述

View File

@ -0,0 +1,5 @@
---
sidebar_position: 2
---
# 第一个程序

View File

@ -0,0 +1,5 @@
---
sidebar_position: 1
---
# 安装配置

View File

@ -0,0 +1,5 @@
---
sidebar_position: 4
---
# 工具支持

View File

@ -0,0 +1,7 @@
{
"label": "工具支持",
"position": 4,
"link": {
"type": "generated-index"
}
}

View File

@ -1,8 +1,8 @@
{ {
"label": "Tutorial - Basics", "label": "基础使用",
"position": 2, "position": 2,
"link": { "link": {
"type": "generated-index", "type": "generated-index",
"description": "5 minutes to learn the most important Docusaurus concepts." "description": "完成 ZHub 服务安装后,来看看一遍就会的基础使用文档~"
} }
} }

View File

@ -0,0 +1,32 @@
---
sidebar_position: 3
title: 广播消息
description: 发送、接收广播消息
---
:::tip
消息接收
广播消息的消息接收,与主题消息、延时消息 api一致且使用了相同 topic 命名空间
- 消息接收
- 广播消息发送
:::
## 消息接收
> [广播消息接收](publish-subscribe.md#订阅主题消息)
## 广播消息发送
> 和发布订阅消息基本差不多
```java
private ZHubClient zhub;
@RestMapping(name = "publish_test", auth = false, comment = "发送广播消息测试")
public String publishTest(String value) {
zhub.broadcast("topic-a", value);
return "send ok!";
}
```

View File

@ -1,23 +0,0 @@
---
sidebar_position: 6
---
# Congratulations!
You have just learned the **basics of Docusaurus** and made some changes to the **initial template**.
Docusaurus has **much more to offer**!
Have **5 more minutes**? Take a look at **[versioning](../tutorial-extras/manage-docs-versions.md)** and **[i18n](../tutorial-extras/translate-your-site.md)**.
Anything **unclear** or **buggy** in this tutorial? [Please report it!](https://github.com/facebook/docusaurus/discussions/4610)
## What's next?
- Read the [official documentation](https://docusaurus.io/)
- Modify your site configuration with [`docusaurus.config.js`](https://docusaurus.io/docs/api/docusaurus-config)
- Add navbar and footer items with [`themeConfig`](https://docusaurus.io/docs/api/themes/configuration)
- Add a custom [Design and Layout](https://docusaurus.io/docs/styling-layout)
- Add a [search bar](https://docusaurus.io/docs/search)
- Find inspirations in the [Docusaurus showcase](https://docusaurus.io/showcase)
- Get involved in the [Docusaurus Community](https://docusaurus.io/community/support)

View File

@ -1,34 +0,0 @@
---
sidebar_position: 3
---
# Create a Blog Post
Docusaurus creates a **page for each blog post**, but also a **blog index page**, a **tag system**, an **RSS** feed...
## Create your first Post
Create a file at `blog/2021-02-28-greetings.md`:
```md title="blog/2021-02-28-greetings.md"
---
slug: greetings
title: Greetings!
authors:
- name: Joel Marcey
title: Co-creator of Docusaurus 1
url: https://github.com/JoelMarcey
image_url: https://github.com/JoelMarcey.png
- name: Sébastien Lorber
title: Docusaurus maintainer
url: https://sebastienlorber.com
image_url: https://github.com/slorber.png
tags: [greetings]
---
Congratulations, you have made your first post!
Feel free to play around and edit this post as much you like.
```
A new blog post is now available at [http://localhost:3000/blog/greetings](http://localhost:3000/blog/greetings).

View File

@ -1,57 +0,0 @@
---
sidebar_position: 2
---
# Create a Document
Documents are **groups of pages** connected through:
- a **sidebar**
- **previous/next navigation**
- **versioning**
## Create your first Doc
Create a Markdown file at `docs/hello.md`:
```md title="docs/hello.md"
# Hello
This is my **first Docusaurus document**!
```
A new document is now available at [http://localhost:3000/docs/hello](http://localhost:3000/docs/hello).
## Configure the Sidebar
Docusaurus automatically **creates a sidebar** from the `docs` folder.
Add metadata to customize the sidebar label and position:
```md title="docs/hello.md" {1-4}
---
sidebar_label: 'Hi!'
sidebar_position: 3
---
# Hello
This is my **first Docusaurus document**!
```
It is also possible to create your sidebar explicitly in `sidebars.js`:
```js title="sidebars.js"
module.exports = {
tutorialSidebar: [
'intro',
// highlight-next-line
'hello',
{
type: 'category',
label: 'Tutorial',
items: ['tutorial-basics/create-a-document'],
},
],
};
```

View File

@ -1,43 +0,0 @@
---
sidebar_position: 1
---
# Create a Page
Add **Markdown or React** files to `src/pages` to create a **standalone page**:
- `src/pages/index.js``localhost:3000/`
- `src/pages/foo.md``localhost:3000/foo`
- `src/pages/foo/bar.js``localhost:3000/foo/bar`
## Create your first React Page
Create a file at `src/pages/my-react-page.js`:
```jsx title="src/pages/my-react-page.js"
import React from 'react';
import Layout from '@theme/Layout';
export default function MyReactPage() {
return (
<Layout>
<h1>My React page</h1>
<p>This is a React page</p>
</Layout>
);
}
```
A new page is now available at [http://localhost:3000/my-react-page](http://localhost:3000/my-react-page).
## Create your first Markdown Page
Create a file at `src/pages/my-markdown-page.md`:
```mdx title="src/pages/my-markdown-page.md"
# My Markdown page
This is a Markdown page
```
A new page is now available at [http://localhost:3000/my-markdown-page](http://localhost:3000/my-markdown-page).

View File

@ -0,0 +1,60 @@
---
sidebar_position: 0
title: 创建连接
description: 初始化客户端连接对象
---
:::tip
目前已提供三种客户端连接使用
- Java 项目
- [普通 Java 项目](#java通用)
- [使用 Redkale 的 Java 项目](#redkale框架-项目里面使用)
- [Golang 项目](#golang-项目中使用)
:::
---
## Java通用
> 在Java 项目中引入 zhub-client.jar
```java
private ZHubClient zhub;
@Before
public void init() {
// 参数说明:① ip:端⼝, ②消费者组名称, ③项⽬实例名(名称需全局唯⼀)④授权码
zhub = new ZHubClient("127.0.0.1:6066", "test-hub", "DEV-LOCAL", "user@pwd123");
}
```
---
## Redkale框架 项目里面使用
> 在Java的redkale 项目中引入 zhub-rekale.jar
> 在配置文件中配置zhub组件
```
# source.properties 中配置
############ ClusterSource @Resource(name="hub") ############
redkale.cluster.zhub[hub].addr = 127.0.0.1:6066
redkale.cluster.zhub[hub].auth = user@pwd123
redkale.cluster.zhub[hub].groupid = test-hub
```
> 在 service 中注入组件
>
```java
@Resource(name = "hub")
protected ZHubClient zhub;
```
## Golang 项目中使用
> 待补充
---

View File

@ -0,0 +1,35 @@
---
sidebar_position: 2
title: 延时消息
description: zhub 的延时消息使用
---
:::tip
首先完成 **[连接创建](create-connection.md)** ,便可进行**延时消息**的发送和接收,
- [订阅主题消息](#订阅主题消息)
- [发送延时消息](#发送延时消息)
:::
## 订阅主题消息
> 见 [主题的订阅](publish-subscribe.md#订阅主题消息)
## 发送延时消息
> 参数说明:①主题名称 ②消息内容 ③延时多久单位ms
> zhub.delay("topic-delay-a", "delay-value", 1000);
>
示例代码:
```java
private ZHubClient zhub;
@RestMapping(name = "delay_test", auth = false, comment = "发送延时主题消息测试")
public String delayTest(String value) {
zhub.delay("topic-delay-a", "delay-value", 1000);
return "send ok!";
}
```

View File

@ -1,31 +0,0 @@
---
sidebar_position: 5
---
# Deploy your site
Docusaurus is a **static-site-generator** (also called **[Jamstack](https://jamstack.org/)**).
It builds your site as simple **static HTML, JavaScript and CSS files**.
## Build your site
Build your site **for production**:
```bash
npm run build
```
The static files are generated in the `build` folder.
## Deploy your site
Test your production build locally:
```bash
npm run serve
```
The `build` folder is now served at [http://localhost:3000/](http://localhost:3000/).
You can now deploy the `build` folder **almost anywhere** easily, **for free** or very small cost (read the **[Deployment Guide](https://docusaurus.io/docs/deployment)**).

View File

@ -1,150 +0,0 @@
---
sidebar_position: 4
---
# Markdown Features
Docusaurus supports **[Markdown](https://daringfireball.net/projects/markdown/syntax)** and a few **additional features**.
## Front Matter
Markdown documents have metadata at the top called [Front Matter](https://jekyllrb.com/docs/front-matter/):
```text title="my-doc.md"
// highlight-start
---
id: my-doc-id
title: My document title
description: My document description
slug: /my-custom-url
---
// highlight-end
## Markdown heading
Markdown text with [links](./hello.md)
```
## Links
Regular Markdown links are supported, using url paths or relative file paths.
```md
Let's see how to [Create a page](/create-a-page).
```
```md
Let's see how to [Create a page](./create-a-page.md).
```
**Result:** Let's see how to [Create a page](./create-a-page.md).
## Images
Regular Markdown images are supported.
You can use absolute paths to reference images in the static directory (`static/img/docusaurus.png`):
```md
![Docusaurus logo](/img/docusaurus.png)
```
![Docusaurus logo](/img/docusaurus.png)
You can reference images relative to the current file as well. This is particularly useful to colocate images close to the Markdown files using them:
```md
![Docusaurus logo](./img/docusaurus.png)
```
## Code Blocks
Markdown code blocks are supported with Syntax highlighting.
```jsx title="src/components/HelloDocusaurus.js"
function HelloDocusaurus() {
return (
<h1>Hello, Docusaurus!</h1>
)
}
```
```jsx title="src/components/HelloDocusaurus.js"
function HelloDocusaurus() {
return <h1>Hello, Docusaurus!</h1>;
}
```
## Admonitions
Docusaurus has a special syntax to create admonitions and callouts:
:::tip My tip
Use this awesome feature option
:::
:::danger Take care
This action is dangerous
:::
:::tip My tip
Use this awesome feature option
:::
:::danger Take care
This action is dangerous
:::
## MDX and React Components
[MDX](https://mdxjs.com/) can make your documentation more **interactive** and allows using any **React components inside Markdown**:
```jsx
export const Highlight = ({children, color}) => (
<span
style={{
backgroundColor: color,
borderRadius: '20px',
color: '#fff',
padding: '10px',
cursor: 'pointer',
}}
onClick={() => {
alert(`You clicked the color ${color} with label ${children}`)
}}>
{children}
</span>
);
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
This is <Highlight color="#1877F2">Facebook blue</Highlight> !
```
export const Highlight = ({children, color}) => (
<span
style={{
backgroundColor: color,
borderRadius: '20px',
color: '#fff',
padding: '10px',
cursor: 'pointer',
}}
onClick={() => {
alert(`You clicked the color ${color} with label ${children}`);
}}>
{children}
</span>
);
This is <Highlight color="#25c2a0">Docusaurus green</Highlight> !
This is <Highlight color="#1877F2">Facebook blue</Highlight> !

View File

@ -0,0 +1,41 @@
---
sidebar_position: 1
title: 订阅&发布
description: zhub 创建客户端连接、订阅主题、发送主题消息
---
:::tip
发布-订阅Publish-Subscribe消息中间件可以用于实现发布-订阅模式。发布者将消息发布到一个或多个主题Topic而订阅者订阅感兴趣的主题。当有新的消息发布到主题时所有订阅了该主题的订阅者都会接收到消息。这样可以实现一对多的消息传递降低发送方和接收方之间的耦合性。
首先完成 **[连接创建](create-connection.md)** ,便可进行消息的发送和接收,
- [订阅主题消息](#订阅主题消息)
- [发送主题消息](#发送主题消息)
:::
## 订阅主题消息
```java
// 事件订阅
zhub.subscribe("topic-a", x -> {
System.out.println("接收到主题 topic-a 事件,消息内容:" + x);
});
```
## 发送主题消息
测试发送主题消息
```java
private ZHubClient zhub;
@RestMapping(name = "publish_test", auth = false, comment = "发送主题消息测试")
public String publishTest(String value) {
zhub.publish("topic-a", value);
return "send ok!";
}
```
这个时候,将会在订阅端收到主题订阅消息,并在控制台输出: `接收到主题 topic-a 事件消息内容xx` 的消息内容

View File

@ -1,5 +1,5 @@
{ {
"label": "Tutorial - Extras", "label": "其他组件",
"position": 3, "position": 3,
"link": { "link": {
"type": "generated-index" "type": "generated-index"

View File

@ -0,0 +1,5 @@
---
sidebar_position: 2
---
# 分布式锁

View File

@ -1,55 +0,0 @@
---
sidebar_position: 1
---
# Manage Docs Versions
Docusaurus can manage multiple versions of your docs.
## Create a docs version
Release a version 1.0 of your project:
```bash
npm run docusaurus docs:version 1.0
```
The `docs` folder is copied into `versioned_docs/version-1.0` and `versions.json` is created.
Your docs now have 2 versions:
- `1.0` at `http://localhost:3000/docs/` for the version 1.0 docs
- `current` at `http://localhost:3000/docs/next/` for the **upcoming, unreleased docs**
## Add a Version Dropdown
To navigate seamlessly across versions, add a version dropdown.
Modify the `docusaurus.config.js` file:
```js title="docusaurus.config.js"
module.exports = {
themeConfig: {
navbar: {
items: [
// highlight-start
{
type: 'docsVersionDropdown',
},
// highlight-end
],
},
},
};
```
The docs version dropdown appears in your navbar:
![Docs Version Dropdown](./img/docsVersionDropdown.png)
## Update an existing version
It is possible to edit versioned docs in their respective folder:
- `versioned_docs/version-1.0/hello.md` updates `http://localhost:3000/docs/hello`
- `docs/hello.md` updates `http://localhost:3000/docs/next/hello`

View File

@ -0,0 +1,7 @@
---
sidebar_position: 1
---
# RPC远程调用
#

View File

@ -0,0 +1,5 @@
---
sidebar_position: 2
---
# 定时调度

View File

@ -1,88 +0,0 @@
---
sidebar_position: 2
---
# Translate your site
Let's translate `docs/intro.md` to French.
## Configure i18n
Modify `docusaurus.config.js` to add support for the `fr` locale:
```js title="docusaurus.config.js"
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr'],
},
};
```
## Translate a doc
Copy the `docs/intro.md` file to the `i18n/fr` folder:
```bash
mkdir -p i18n/fr/docusaurus-plugin-content-docs/current/
cp docs/intro.md i18n/fr/docusaurus-plugin-content-docs/current/intro.md
```
Translate `i18n/fr/docusaurus-plugin-content-docs/current/intro.md` in French.
## Start your localized site
Start your site on the French locale:
```bash
npm run start -- --locale fr
```
Your localized site is accessible at [http://localhost:3000/fr/](http://localhost:3000/fr/) and the `Getting Started` page is translated.
:::caution
In development, you can only use one locale at a same time.
:::
## Add a Locale Dropdown
To navigate seamlessly across languages, add a locale dropdown.
Modify the `docusaurus.config.js` file:
```js title="docusaurus.config.js"
module.exports = {
themeConfig: {
navbar: {
items: [
// highlight-start
{
type: 'localeDropdown',
},
// highlight-end
],
},
},
};
```
The locale dropdown now appears in your navbar:
![Locale Dropdown](./img/localeDropdown.png)
## Build your localized site
Build your site for a specific locale:
```bash
npm run build -- --locale fr
```
Or build your site to include all the locales at once:
```bash
npm run build
```

View File

@ -1,20 +1,24 @@
// @ts-check // @ts-check
// Note: type annotations allow type checking and IDEs autocompletion // Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require('prism-react-renderer/themes/github'); const lightCodeTheme = require('prism-react-renderer/themes/github')
const darkCodeTheme = require('prism-react-renderer/themes/dracula'); const darkCodeTheme = require('prism-react-renderer/themes/dracula')
/** @type {import('@docusaurus/types').Config} */ /** @type {import('@docusaurus/types').Config} */
const config = { const config = {
title: 'My Site', title: 'ZHub',
tagline: 'Dinosaurs are cool', tagline: '轻量级消息中间件',
favicon: 'img/favicon.ico', favicon: 'img/favicon.ico',
// Set the production url of your site here // Set the production url of your site here
url: 'https://your-docusaurus-test-site.com', url: 'https://zhub.1216.top',
// Set the /<baseUrl>/ pathname under which your site is served // Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/' // For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/', baseUrl: '/',
customFields: {
// 添加自定义输出目录
outDir: 'dist',
},
// GitHub pages deployment config. // GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these. // If you aren't using GitHub pages, you don't need these.
@ -41,16 +45,16 @@ const config = {
sidebarPath: require.resolve('./sidebars.js'), sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo. // Please change this to your repo.
// Remove this to remove the "edit this page" links. // Remove this to remove the "edit this page" links.
editUrl: // editUrl: 'https://gitee.com/tc608/doc-zhub/main',
'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
}, },
blog: { blog: {
showReadingTime: true, showReadingTime: true,
// Please change this to your repo. // Please change this to your repo.
// Remove this to remove the "edit this page" links. // Remove this to remove the "edit this page" links.
editUrl: // editUrl: 'https://gitee.com/tc608/doc-zhub/main',
'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
}, },
theme: { theme: {
customCss: require.resolve('./src/css/custom.css'), customCss: require.resolve('./src/css/custom.css'),
}, },
@ -59,12 +63,12 @@ const config = {
], ],
themeConfig: themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */ /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({ ({
// Replace with your project's social card // Replace with your project's social card
image: 'img/docusaurus-social-card.jpg', image: 'img/docusaurus-social-card.jpg',
navbar: { navbar: {
title: 'My Site', title: 'ZHub',
logo: { logo: {
alt: 'My Site Logo', alt: 'My Site Logo',
src: 'img/logo.svg', src: 'img/logo.svg',
@ -74,50 +78,47 @@ const config = {
type: 'docSidebar', type: 'docSidebar',
sidebarId: 'tutorialSidebar', sidebarId: 'tutorialSidebar',
position: 'left', position: 'left',
label: 'Tutorial', label: '文档',
}, },
{to: '/blog', label: 'Blog', position: 'left'}, { to: '/blog', label: 'Blog', position: 'left' },
{ {
href: 'https://github.com/facebook/docusaurus', href: 'https://gitee.com/tc608/zhub',
label: 'GitHub', label: 'Gitee',
position: 'right', position: 'right',
}, },
], ],
}, },
footer: { footer: {
style: 'dark', style: 'dark',
links: [ links: [
{ {
title: 'Docs', title: '文档',
items: [ items: [
{ {
label: 'Tutorial', label: '快速开始',
to: '/docs/intro', to: '/docs/intro',
}, },
],
},
{
title: 'Community',
items: [
{ {
label: 'Stack Overflow', label: '基础使用',
href: 'https://stackoverflow.com/questions/tagged/docusaurus', to: '/docs/category/基础使用',
},
{
label: 'Discord',
href: 'https://discordapp.com/invite/docusaurus',
},
{
label: 'Twitter',
href: 'https://twitter.com/docusaurus',
}, },
], ],
}, },
{ {
title: 'More', title: '社区',
items: [ items: [
{ {
label: 'Blog', label: 'Gitee',
href: 'https://gitee.com/tc608',
},
],
},
{
title: '更多',
items: [
{
label: '博客',
to: '/blog', to: '/blog',
}, },
{ {
@ -127,13 +128,14 @@ const config = {
], ],
}, },
], ],
copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`, copyright: `Copyright © ${new Date().getFullYear()} ZHub, Inc. Built with Docusaurus.`,
}, },
prism: { prism: {
theme: lightCodeTheme, theme: lightCodeTheme,
darkTheme: darkCodeTheme, darkTheme: darkCodeTheme,
additionalLanguages: ['java'],
}, },
}), }),
}; }
module.exports = config; module.exports = config

View File

@ -19,8 +19,8 @@
"@mdx-js/react": "^1.6.22", "@mdx-js/react": "^1.6.22",
"clsx": "^1.2.1", "clsx": "^1.2.1",
"prism-react-renderer": "^1.3.5", "prism-react-renderer": "^1.3.5",
"react": "^17.0.2", "react": "^18.0.0",
"react-dom": "^17.0.2" "react-dom": "^18.0.0"
}, },
"devDependencies": { "devDependencies": {
"@docusaurus/module-type-aliases": "2.4.1" "@docusaurus/module-type-aliases": "2.4.1"

View File

@ -4,32 +4,29 @@ import styles from './styles.module.css';
const FeatureList = [ const FeatureList = [
{ {
title: 'Easy to Use', title: '易于使用',
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default, Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
description: ( description: (
<> <>
Docusaurus was designed from the ground up to be easily installed and ZHub 从新设计易于安装和用于快速启动运行您的项目
used to get your website up and running quickly.
</> </>
), ),
}, },
{ {
title: 'Focus on What Matters', title: '专注于重要的事情',
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default, Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
description: ( description: (
<> <>
Docusaurus lets you focus on your docs, and we&apos;ll do the chores. Go ZHub 让你专注于你的业务我们专注于消息收发数据传递让你多个工程进行之间通讯变得如此的简单
ahead and move your docs into the <code>docs</code> directory.
</> </>
), ),
}, },
{ {
title: 'Powered by React', title: 'Powered by ZHUB',
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default, Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
description: ( description: (
<> <>
Extend or customize your website layout by reusing React. Docusaurus can 通过 Golang 编写通讯组件自定义消息协议专注提升服务性能
be extended while reusing the same header and footer.
</> </>
), ),
}, },

View File

@ -6,7 +6,7 @@
/* You can override the default Infima variables here. */ /* You can override the default Infima variables here. */
:root { :root {
--ifm-color-primary: #2e8555; --ifm-color-primary: #852e79;
--ifm-color-primary-dark: #29784c; --ifm-color-primary-dark: #29784c;
--ifm-color-primary-darker: #277148; --ifm-color-primary-darker: #277148;
--ifm-color-primary-darkest: #205d3b; --ifm-color-primary-darkest: #205d3b;
@ -19,7 +19,7 @@
/* For readability concerns, you should choose a lighter palette in dark mode. */ /* For readability concerns, you should choose a lighter palette in dark mode. */
[data-theme='dark'] { [data-theme='dark'] {
--ifm-color-primary: #25c2a0; --ifm-color-primary: #852e79;
--ifm-color-primary-dark: #21af90; --ifm-color-primary-dark: #21af90;
--ifm-color-primary-darker: #1fa588; --ifm-color-primary-darker: #1fa588;
--ifm-color-primary-darkest: #1a8870; --ifm-color-primary-darkest: #1a8870;

View File

@ -18,7 +18,7 @@ function HomepageHeader() {
<Link <Link
className="button button--secondary button--lg" className="button button--secondary button--lg"
to="/docs/intro"> to="/docs/intro">
Docusaurus Tutorial - 5min 快速上手安装使用
</Link> </Link>
</div> </div>
</div> </div>
@ -30,7 +30,7 @@ export default function Home() {
const {siteConfig} = useDocusaurusContext(); const {siteConfig} = useDocusaurusContext();
return ( return (
<Layout <Layout
title={`Hello from ${siteConfig.title}`} title={`${siteConfig.title}`}
description="Description will go into a meta tag in <head />"> description="Description will go into a meta tag in <head />">
<HomepageHeader /> <HomepageHeader />
<main> <main>

View File

@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1088" height="687.962" viewBox="0 0 1088 687.962"> <svg xmlns="http://www.w3.org/2000/svg" width="1088" height="687.962" viewBox="0 0 1088 687.962">
<title>Easy to Use</title> <title>易于使用</title>
<g id="Group_12" data-name="Group 12" transform="translate(-57 -56)"> <g id="Group_12" data-name="Group 12" transform="translate(-57 -56)">
<g id="Group_11" data-name="Group 11" transform="translate(57 56)"> <g id="Group_11" data-name="Group 11" transform="translate(57 56)">
<path id="Path_83" data-name="Path 83" d="M1017.81,560.461c-5.27,45.15-16.22,81.4-31.25,110.31-20,38.52-54.21,54.04-84.77,70.28a193.275,193.275,0,0,1-27.46,11.94c-55.61,19.3-117.85,14.18-166.74,3.99a657.282,657.282,0,0,0-104.09-13.16q-14.97-.675-29.97-.67c-15.42.02-293.07,5.29-360.67-131.57-16.69-33.76-28.13-75-32.24-125.27-11.63-142.12,52.29-235.46,134.74-296.47,155.97-115.41,369.76-110.57,523.43,7.88C941.15,276.621,1036.99,396.031,1017.81,560.461Z" transform="translate(-56 -106.019)" fill="#3f3d56"/> <path id="Path_83" data-name="Path 83" d="M1017.81,560.461c-5.27,45.15-16.22,81.4-31.25,110.31-20,38.52-54.21,54.04-84.77,70.28a193.275,193.275,0,0,1-27.46,11.94c-55.61,19.3-117.85,14.18-166.74,3.99a657.282,657.282,0,0,0-104.09-13.16q-14.97-.675-29.97-.67c-15.42.02-293.07,5.29-360.67-131.57-16.69-33.76-28.13-75-32.24-125.27-11.63-142.12,52.29-235.46,134.74-296.47,155.97-115.41,369.76-110.57,523.43,7.88C941.15,276.621,1036.99,396.031,1017.81,560.461Z" transform="translate(-56 -106.019)" fill="#3f3d56"/>

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB