Forráskód Böngészése

doc(build): doc for feature selection in build

Signed-off-by: Jiyong Huang <huangjy@emqx.io>
Jiyong Huang 3 éve
szülő
commit
c472567126
5 módosított fájl, 100 hozzáadás és 14 törlés
  1. 0 14
      Makefile
  2. 4 0
      README-CN.md
  3. 4 0
      README.md
  4. 46 0
      docs/en_US/features.md
  5. 46 0
      docs/zh_CN/features.md

+ 0 - 14
Makefile

@@ -62,20 +62,6 @@ build_core: build_prepare
 	@mv ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
 	@mv ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
 	@echo "Build successfully"
 	@echo "Build successfully"
 
 
-.PHONY: build_pprof
-build_pprof: build_prepare
-	GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags pprof -o kuiperd cmd/kuiperd/main.go
-	@if [ ! -z $$(which upx) ]; then upx ./kuiperd; fi
-	@mv ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
-	@echo "Build successfully"
-
-.PHONY: build_with_plugin
-build_with_plugin: build_prepare
-	GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags plugin -o kuiperd cmd/kuiperd/main.go
-	@if [ ! -z $$(which upx) ]; then upx ./kuiperd; fi
-	@mv ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
-	@echo "Build successfully"
-
 .PHONY: pkg_with_edgex
 .PHONY: pkg_with_edgex
 pkg_with_edgex: build_with_edgex
 pkg_with_edgex: build_with_edgex
 	@make real_pkg
 	@make real_pkg

+ 4 - 0
README-CN.md

@@ -167,6 +167,8 @@ eKuiper 可以运行在各类物联网的边缘使用场景中,比如工业物
 
 
   - 编译支持 EdgeX 的二进制文件: `$ make build_with_edgex`
   - 编译支持 EdgeX 的二进制文件: `$ make build_with_edgex`
 
 
+  - 编译核心包的二进制文件: `$ make build_core`
+
 + 安装文件打包:
 + 安装文件打包:
 
 
   - 安装文件打包:: `$ make pkg`
   - 安装文件打包:: `$ make pkg`
@@ -180,6 +182,8 @@ eKuiper 可以运行在各类物联网的边缘使用场景中,比如工业物
 
 
 项目版本页面里提供了预编译的二进制文件。如果您的操作系统或架构没有预编译的文件,请使用交叉编译自行构建,请参考[此文档](docs/zh_CN/operation/compile/cross-compile.md)。
 项目版本页面里提供了预编译的二进制文件。如果您的操作系统或架构没有预编译的文件,请使用交叉编译自行构建,请参考[此文档](docs/zh_CN/operation/compile/cross-compile.md)。
 
 
+编译时,用户可通过 go build tags 选择需要编译的功能编译出自定义的仅包含所需功能的二进制包从而减少可执行文件的大小。在资源受限的环境中,包的大小尤其重要。进一步的信息,请参考[功能](docs/zh_CN/features.md)。
+
 ## 开源版权
 ## 开源版权
 
 
 [Apache 2.0](LICENSE)
 [Apache 2.0](LICENSE)

+ 4 - 0
README.md

@@ -153,6 +153,8 @@ Thank you for your contribution! Please refer to the [CONTRIBUTING.md](./docs/CO
 
 
   - Binary files that support EdgeX: `$ make build_with_edgex`
   - Binary files that support EdgeX: `$ make build_with_edgex`
 
 
+  - Minimal binary file with core runtime only: `$ make build_core`
+
 + Packages: `` $ make pkg``
 + Packages: `` $ make pkg``
 
 
   - Packages: `$ make pkg`
   - Packages: `$ make pkg`
@@ -165,6 +167,8 @@ Thank you for your contribution! Please refer to the [CONTRIBUTING.md](./docs/CO
 
 
 Prebuilt binaries are provided in the release assets. If using os or arch which does not have prebuilt binaries, please use cross-compilation, refer to [this doc](docs/en_US/operation/compile/cross-compile.md).
 Prebuilt binaries are provided in the release assets. If using os or arch which does not have prebuilt binaries, please use cross-compilation, refer to [this doc](docs/en_US/operation/compile/cross-compile.md).
 
 
+During compilation, features can be selected through go build tags so that users can build a customized product with only the desired feature set to reduce binary size. This is critical when the target deployment environment has resource constraint. Please refer to [features](docs/en_US/features.md) for more detail.
+
 ## Open source license
 ## Open source license
 
 
 [Apache 2.0](LICENSE)
 [Apache 2.0](LICENSE)

+ 46 - 0
docs/en_US/features.md

@@ -0,0 +1,46 @@
+# Features
+
+Except core runtime and REST api, there are some features that are allowed to be enabled or disabled during compilation by [go build constraints](https://pkg.go.dev/go/build#hdr-Build_Constraints). Uses can customize the built binary to include only the desired features to reduce the binary size according to the limit of the target environment. 
+
+## Feature List
+
+| Feature                                                                            | Build Tag  | Description                                                                                                                                            |
+|------------------------------------------------------------------------------------|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
+| Core                                                                               | core       | The core of eKuiper. It contains the processor and REST API for stream/table/rule, the configuration processing, the SQL parser, the rule runtime etc. |
+| [CLI](./cli/overview.md)                                                           | rpc        | The cli server                                                                                                                                         |
+| [EdgeX Foundry integration](./edgex/edgex_rule_engine_tutorial.md)                 | edgex      | The built-in edgeX source, sink and connection                                                                                                         |
+| [Native plugin](./extension/native/overview.md)                                    | plugin     | The native plugin runtime, REST API, CLI API etc.                                                                                                      |
+| [Portable plugin](./extension/portable/overview.md)                                | portable   | The portable plugin runtime, REST API, CLI API etc.                                                                                                    |
+| [External service](./extension/external/external_func.md)                          | service    | The external service runtime, REST API, CLI API etc.                                                                                                   |
+| [UI Meta API](./manager-ui/overview.md)                                            | ui         | The REST API of the metadata which is usually consumed by the ui                                                                                       |
+| [Prometheus Metrics](./operation/configuration_file.md#prometheus-configuration)   | prometheus | Support to send metrics to prometheus                                                                                                                  |
+| [Extended template functions](./rules/overview.md#functions-supported-in-template) | template   | Support additional data template function from sprig besides default go text/template functions                                                        |
+
+## Usage
+
+In makefile, we already provide three feature sets: standard, edgeX and core. The standard feature set include all features in the list except edgeX; edgeX feature set include all features; And the core feature set is the minimal which only has core feature. Build these feature sets with default makefile:
+
+```shell
+# standard
+make
+# EdgeX
+make build_with_edgex
+# core
+make build_core
+```
+
+Feature selection is useful in a limited resource target which is unlikely to run as docker container. So we only provide standard feature set in the docker images. 
+
+And users need to build from source to customize the feature sets. To build with the desired features:
+
+```shell
+go build --tags "<FEATURE>"
+```
+
+For example, to build with core and native plugin support:
+
+```shell
+go build --tags "core plugin"
+```
+
+Recommend updating the build command in the Makefile with tags and build from make.

+ 46 - 0
docs/zh_CN/features.md

@@ -0,0 +1,46 @@
+# 功能
+
+除了核心运行时和 REST API ,其他功能都可通过 [go build constraints](https://pkg.go.dev/go/build#hdr-Build_Constraints) 在编译时打开或者关闭。用户可编译自定义的,仅包含所需功能的二进制包从而减少包的大小,以便能够部署在资源敏感的环境中。
+
+## 功能列表
+
+| 功能                                                               | Build Tag  | 描述                                                           |
+|------------------------------------------------------------------|------------|--------------------------------------------------------------|
+| 核心                                                               | core       | eKuiper 的核心运行时。 包括流/表/规则的处理器和 REST API ,配置管理,SQL 解析器,规则运行时等。 |
+| [CLI](./cli/overview.md)                                         | rpc        | CLI 服务端                                                      |
+| [EdgeX Foundry 整合](./edgex/edgex_rule_engine_tutorial.md)        | edgex      | 内置的 edgeX source, sink 和共享连接支持                               |
+| [原生插件](./extension/native/overview.md)                           | plugin     | 原生插件运行时,REST API和CLI API等                                    |
+| [Portable 插件](./extension/portable/overview.md)                  | plugin     | Portable 插件运行时,REST API和CLI API等                             |
+| [外部服务](./extension/external/external_func.md)                    | service    | 外部服务运行时,REST API和CLI API等                                    |
+| [UI 元数据API](./manager-ui/overview.md)                            | ui         | 元数据的 REST API,通常由 UI 端消费                                     |
+| [Prometheus 指标](./operation/configuration_file.md#prometheus-配置) | prometheus | 支持发送指标到 prometheus 中                                         |
+| [扩展模板函数](./rules/overview.md#模版中支持的函数)                           | template   | 支持除 go 语言默认的模板函数之外的扩展函数,主要来自 sprig                           |
+
+## Usage
+
+Makefile 里已经提供了三种功能集合:标准,edgeX和核心。标准功能集合包含除了 EdgeX 之外的所有功能。edgeX 功能集合包含了所有的功能;而核心功能集合近包含最小的核心功能。可以通过以下命令,分别编译这三种功能集合:
+
+```shell
+# 标准
+make
+# EdgeX
+make build_with_edgex
+# 核心
+make build_core
+```
+
+功能选择通常应用在资源受限的目标环境中。而该环境一般不太适合运行 docker 容易。因此,我们仅提供包含标准及 edgeX 功能集合的 docker 镜像。
+
+若需要自定义功能选择,用户需要自行编译源码。其语法为:
+
+```shell
+go build --tags "<FEATURE>"
+```
+
+例如,编译带有原生插件功能的核心包,编译命令为:
+
+```shell
+go build --tags "core plugin"
+```
+
+建议用户以默认 Makefile 为模板,在里面更新编译命令,使其选择所需的 tags ,然后采用 make 命令进行编译。