### Run r-nacos from Binary (Linux/Mac) Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Download the pre-compiled binary for your system, extract it, and run the executable. This is a quick way to get started. ```shell # Extract tar -xvf rnacos-x86_64-apple-darwin.tar.gz # Run ./rnacos ``` -------------------------------- ### Run r-nacos from Binary (Linux/MacOS) Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Download the binary package, extract it, and run the executable. This is a quick way to get started for testing or development. ```shell # 解压 tar -xvf rnacos-x86_64-apple-darwin.tar.gz # 运行 ./rnacos ``` -------------------------------- ### Service Registration Log Example Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md This log output indicates successful service registration with r-nacos, including the service name, IP address, and port. It also shows the service starting up. ```log 服务 calculate 已成功注册到Nacos,IP: 192.168.1.100,端口: 8002 启动计算服务API服务器,端口: 8002... ``` -------------------------------- ### Example Configuration Output Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/java/spring-cloud-config-nacos-v3/README.md This is an example output when querying configuration. The actual output may vary based on the current configuration in `example.properties`. ```sh #output false ``` -------------------------------- ### Install and Run r-nacos with Cargo Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Install r-nacos directly from source using Cargo. This method requires Rust and Cargo to be installed. ```shell # Install cargo install rnacos # Run rnacos ``` -------------------------------- ### GET Query 加法运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 GET 请求和 URL 查询参数进行加法运算。 ```http GET /q/add?a=10&b=5 ``` -------------------------------- ### GET Query 除法运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 GET 请求和 URL 查询参数进行除法运算。 ```http GET /q/divide?a=10&b=5 ``` -------------------------------- ### GET Query 乘法运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 GET 请求和 URL 查询参数进行乘法运算。 ```http GET /q/multiply?a=10&b=5 ``` -------------------------------- ### GET Query 减法运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 GET 请求和 URL 查询参数进行减法运算。 ```http GET /q/subtract?a=10&b=5 ``` -------------------------------- ### Install r-nacos using Homebrew (MacOS) Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Install r-nacos on MacOS using Homebrew. This simplifies installation and updates. ```shell # Add r-nacos to taps brew tap r-nacos/r-nacos # brew install r-nacos brew install r-nacos # Run rnacos # Subsequent updates can be done via: # brew upgrade r-nacos ``` -------------------------------- ### Install r-nacos using Cargo Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Install the r-nacos binary directly using the cargo package manager. This method requires Rust and Cargo to be installed. ```shell # 安装 cargo install rnacos # 运行 rnacos ``` -------------------------------- ### CI/CD Integration Script Example Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md This bash script shows how to integrate the ToolSpec API tests into a CI/CD pipeline. It runs the automated test runner, checks the exit code, and reports success or failure. ```bash #!/bin/bash cd r-nacos/integration_tests/scripts ./run_toolspec_test.py --build exit_code=$? if [ $exit_code -eq 0 ]; then echo "✅ ToolSpec API tests passed" else echo "❌ ToolSpec API tests failed with code $exit_code" exit $exit_code fi ``` -------------------------------- ### Customize Test Parameters Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md These examples demonstrate how to customize test parameters, including the test namespace, group, tool name, server host and port, and request timeout duration. ```bash # Customize test namespace and identifiers ./toolspec_console_api_test.py --namespace my-ns --group my-group --tool-name my-tool # Customize server location ./toolspec_console_api_test.py --host 192.168.1.100 --port 8849 # Customize timeout ./toolspec_console_api_test.py --timeout 30 ``` -------------------------------- ### Manually Manage r-nacos Server and Run Tests Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md This approach involves manually starting the r-nacos server and then executing the integration tests against it. Custom parameters for host, port, and namespace can be provided. ```bash cd r-nacos cargo run ``` ```bash ./toolspec_console_api_test.py # Or use custom parameters ./toolspec_console_api_test.py --host 127.0.0.1 --port 8848 --namespace my-test-ns ``` -------------------------------- ### Install r-nacos using Homebrew (MacOS) Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Add the r-nacos tap to Homebrew and then install the r-nacos package. This is a convenient way to install and manage r-nacos on macOS. ```shell # 把r-nacos加入taps brew tap r-nacos/r-nacos # brew 安装 r-nacos brew install r-nacos # 运行 rnacos # 后续可以直接通过以下命令更新到最新版本 # brew upgrade r-nacos ``` -------------------------------- ### Start r-nacos Follower Nodes Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/cluster_deploy.md Commands to start follower nodes of the r-nacos cluster in the background using specified environment files. These should be run after the leader node has started successfully. ```sh nohup ./rnacos -e env02 > n02.log & nohup ./rnacos -e env03 > n03.log & ``` -------------------------------- ### Start r-nacos Leader Node Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/cluster_deploy.md Command to start the leader node of the r-nacos cluster in the background using a specified environment file. ```sh nohup ./rnacos -e env01 > n01.log & ``` -------------------------------- ### Curl 示例 - GET Query 运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 curl 命令进行 GET Query 参数的加、减、乘、除运算。 ```bash # GET Query 加法 curl "http://localhost:8002/q/add?a=15&b=7" # GET Query 减法 curl "http://localhost:8002/q/subtract?a=15&b=7" # GET Query 乘法 curl "http://localhost:8002/q/multiply?a=15&b=7" # GET Query 除法 curl "http://localhost:8002/q/divide?a=15&b=7" ``` -------------------------------- ### Access r-nacos API with curl Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/java/spring-cloud-v2/README.md Use this command to access the demo API after starting the service and API applications. Ensure r-nacos is running. ```sh curl "http://127.0.0.1:20895/hi?name=r-nacos" ``` ```text [springcloud-demo-service]: Hello, r-nacos ``` -------------------------------- ### Publish and Get Configuration via HTTP API Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/cluster_deploy.md Demonstrates publishing and retrieving configuration values using r-nacos's HTTP API across different cluster nodes. Shows that configurations published to one node are accessible from others. ```sh echo "\npublish config t001:contentTest to node 1" curl -X POST 'http://127.0.0.1:8848/nacos/v1/cs/configs' -d 'dataId=t001&group=foo&content=contentTest' sleep 1 echo "\nget config info t001 from node 1, value:" curl 'http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=t001&group=foo' echo "\nget config info t001 from node 2, value:" curl 'http://127.0.0.1:8849/nacos/v1/cs/configs?dataId=t001&group=foo' echo "\nget config info t001 from node 3, value:" curl 'http://127.0.0.1:8850/nacos/v1/cs/configs?dataId=t001&group=foo' sleep 1 echo "\npublish config t002:contentTest02 to node 2" curl -X POST 'http://127.0.0.1:8849/nacos/v1/cs/configs' -d 'dataId=t002&group=foo&content=contentTest02' sleep 1 echo "\nget config info t002 from node 1, value:" curl 'http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=t002&group=foo' echo "\nget config info t002 from node 2, value:" curl 'http://127.0.0.1:8849/nacos/v1/cs/configs?dataId=t002&group=foo' echo "\nget config info t002 from node 3, value:" curl 'http://127.0.0.1:8850/nacos/v1/cs/configs?dataId=t002&group=foo' ``` -------------------------------- ### Deploy r-nacos to Kubernetes using Helm Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Add the r-nacos Helm repository and install r-nacos using Helm charts. This is suitable for deploying r-nacos in a Kubernetes environment. ```shell helm repo add rnacos https://r-nacos.github.io/helm helm install r-nacos rnacos/rnacos ``` -------------------------------- ### Query Configuration via HTTP API Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Use `curl` to send a GET request to the r-nacos configuration center API to query a specific configuration. Requires r-nacos to be running. ```shell # Query curl 'http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=t001&group=foo' ``` -------------------------------- ### CI/CD Integration Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md Information on integrating the ToolSpec API tests into CI/CD pipelines, including exit codes and example scripts. ```APIDOC ## CI/CD Integration The test scripts return specific exit codes to facilitate integration with CI/CD pipelines: - `0`: All tests passed. - `1`: Some tests failed. - `130`: User interrupted (Ctrl+C). ### CI Usage Example ```bash #!/bin/bash cd r-nacos/integration_tests/scripts ./run_toolspec_test.py --build exit_code=$? if [ $exit_code -eq 0 ]; then echo "✅ ToolSpec API tests passed" else echo "❌ ToolSpec API tests failed with code $exit_code" exit $exit_code fi ``` ``` -------------------------------- ### Run ToolSpec Tests Automatically Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md Use this script to automatically start the r-nacos server and execute the integration tests. Options include building r-nacos first, keeping the server running after tests, and specifying custom host/port. ```bash # Automatically start the server and run tests ./run_toolspec_test.py # Build r-nacos first, then run tests ./run_toolspec_test.py --build # Keep the server running after tests for manual inspection ./run_toolspec_test.py --keep-running # Use custom host/port ./run_toolspec_test.py --host 192.168.1.100 --port 8849 ``` -------------------------------- ### 环境变量配置文件格式 Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/deplay_env.md env_file 文件的格式为 KEY=VALUE,每行一个配置项,用于 r-nacos 的参数设置。 ```properties KEY1=VALUE1 KEY2=VALUE2 KEY3=VALUE3 ``` -------------------------------- ### 运行计算服务 (默认端口) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 uv run 或 python 命令启动计算服务,默认端口为 8002。 ```bash uv run calculate_api.py ``` ```bash python calculate_api.py ``` -------------------------------- ### 运行计算服务 (自定义端口) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 通过 --port 参数指定自定义端口来启动计算服务。 ```bash python calculate_api.py --port 9000 ``` -------------------------------- ### 通过配置文件设置参数 Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/deplay_env.md 使用 -e 参数指定包含配置的 .env 文件来设置 r-nacos 的运行参数。如果未指定文件,将尝试从当前目录加载 .env 文件。 ```sh ./rnacos -e env_file ``` -------------------------------- ### Build and Run r-nacos from Source Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Clone the r-nacos repository, build the release binary using cargo, and then run the executable. This method provides the most control and allows for building specific versions. ```shell git clone https://github.com/r-nacos/r-nacos.git cd r-nacos cargo build --release cargo run --release ``` -------------------------------- ### Run grpc_naming_register Test Source: https://github.com/nacos-group/r-nacos/blob/master/loadtest/README.md Executes the grpc_naming_register performance test. This command initiates the gRPC registration test. ```shell cargo run --bin grpc_naming_register --release ``` -------------------------------- ### GET Query Parameter Arithmetic Operations Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md Perform arithmetic operations using GET requests with query parameters. This method is suitable for simple data retrieval or operations where parameters are not sensitive. ```python response = requests.get(f"{base_url}/q/add", params={"a": 15, "b": 7}) print(f"GET Query 加法结果: {response.json()}") ``` ```python response = requests.get(f"{base_url}/q/subtract", params={"a": 15, "b": 7}) print(f"GET Query 减法结果: {response.json()}") ``` ```python response = requests.get(f"{base_url}/q/multiply", params={"a": 15, "b": 7}) print(f"GET Query 乘法结果: {response.json()}") ``` ```python response = requests.get(f"{base_url}/q/divide", params={"a": 15, "b": 7}) print(f"GET Query 除法结果: {response.json()}") ``` -------------------------------- ### Compile and Run r-nacos from Source Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Clone the r-nacos repository, build the release version, and then run it. This is useful for development or if you need a specific build. ```shell git clone https://github.com/heqingpan/rnacos.git cd rnacos cargo build --release cargo run --release ``` -------------------------------- ### Access Dubbo API with curl Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/java/dubbo_v2.x/README.md Use this command to access the Dubbo API after starting the service and API applications. Ensure r-nacos is running. ```sh curl "http://127.0.0.1:20795/hi?name=r-nacos" ``` ```text [dubbo-demo-service] : Hello, r-nacos ``` -------------------------------- ### Get Specific Application Configuration with Nacos C# Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/csharp/nacos-csharp-01/README.md Fetch configuration for a specific application from Nacos. This is useful for managing configurations scoped to different services. ```bash curl -i 'http://127.0.0.1:5215/api/config/get_config_name' ``` -------------------------------- ### Access Configuration via Curl Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/java/spring-cloud-config-nacos-v3/README.md This command retrieves configuration content from the running Spring Boot application. After updating `example.properties`, re-accessing this API should reflect the latest configuration. ```sh curl "http://127.0.0.1:8083/config/get" ``` -------------------------------- ### Run Spring Boot Application Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/java/spring-cloud-config-nacos-v3/README.md Use this command to run the Spring Boot application. Alternatively, you can package it first using `mvn package` and then run the generated JAR. ```sh mvn spring-boot:run ``` -------------------------------- ### Access r-nacos API via curl Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/java/dubbo_v3.x/README.md Use this command to access the r-nacos API after starting the service and API applications. Ensure r-nacos is running and accessible. ```sh curl "http://127.0.0.1:20785/hi?name=r-nacos" ``` ```text [dubbo-demo-service] : Hello, r-nacos ``` -------------------------------- ### Running ToolSpec Console API Tests Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md Instructions on how to run the ToolSpec Console API integration tests using the provided scripts. ```APIDOC ## Running ToolSpec Console API Tests ### Automated Test Runner (Recommended) The `run_toolspec_test.py` script automates the process of starting the r-nacos server and running the tests. ```bash # Automatically start the server and run tests ./run_toolspec_test.py # Build r-nacos first, then run tests ./run_toolspec_test.py --build # Keep the server running after tests for manual inspection ./run_toolspec_test.py --keep-running # Use custom host/port ./run_toolspec_test.py --host 192.168.1.100 --port 8849 ``` ### Manual Server Management If you prefer to manage the r-nacos server manually: 1. Start the r-nacos server: ```bash cd r-nacos cargo run ``` 2. Execute tests against the running server: ```bash ./toolspec_console_api_test.py # Or with custom parameters ./toolspec_console_api_test.py --host 127.0.0.1 --port 8848 --namespace my-test-ns ``` ### Custom Test Configuration You can customize test parameters like namespace, group, tool name, server location, and timeout: ```bash # Custom test namespace and identifier ./toolspec_console_api_test.py --namespace my-ns --group my-group --tool-name my-tool # Custom server location ./toolspec_console_api_test.py --host 192.168.1.100 --port 8849 # Custom timeout ./toolspec_console_api_test.py --timeout 30 ``` ``` -------------------------------- ### 根路径 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 获取服务基本信息,包括支持的 API 端点。 ```APIDOC ## GET / ### Description 获取服务基本信息,包括支持的 API 端点。 ### Method GET ### Endpoint / ### Response #### Success Response (200) - **message** (string) - 服务状态信息 - **version** (string) - 服务版本号 - **endpoints** (object) - 支持的 API 端点列表 #### Response Example ```json { "message": "计算服务API", "version": "1.0.0", "endpoints": { "POST JSON": { "add": "/add - 加法运算", "subtract": "/subtract - 减法运算", "multiply": "/multiply - 乘法运算", "divide": "/divide - 除法运算" }, "POST Form": { "add": "/form/add - 加法运算", "subtract": "/form/subtract - 减法运算", "multiply": "/form/multiply - 乘法运算", "divide": "/form/divide - 除法运算" }, "GET Query": { "add": "/q/add?a=1&b=2 - 加法运算", "subtract": "/q/subtract?a=1&b=2 - 减法运算", "multiply": "/q/multiply?a=1&b=2 - 乘法运算", "divide": "/q/divide?a=1&b=2 - 除法运算" } } } ``` ``` -------------------------------- ### ToolSpec Data Structure Example Source: https://github.com/nacos-group/r-nacos/blob/master/integration_tests/scripts/README_TOOLSPEC_TESTS.md This JSON structure represents a ToolSpec, emphasizing the use of the 'function' field over the older 'parameters' field. It includes essential sub-fields like name, description, and parameters for the function. ```json { "namespace": "test-namespace", "group": "test-group", "toolName": "test-tool", "function": { "name": "test-tool", "description": "Test tool for test-tool", "parameters": { "input": { "type": "object", "properties": { "query": { "type": "string", "description": "The query string" }, "limit": { "type": "integer", "description": "Maximum number of results" } }, "required": ["query"] } } }, "version": 1 } ``` -------------------------------- ### 安装依赖 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 安装运行此示例所需的 Python 依赖。 ```bash uv sync ``` ```bash pip install fastapi uvicorn pydantic nacos-sdk-python ``` -------------------------------- ### Query Service Instances with Nacos HTTP API Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Use the HTTP GET method to query a list of service instances. Specify the namespace ID, service name, and group name. The `healthyOnly` parameter can filter for healthy instances. ```bash # 查询服务实例 curl "http://127.0.0.1:8848/nacos/v1/ns/instance/list?&namespaceId=public&serviceName=foo%40%40nacos.test.001&groupName=foo&clusters=&healthyOnly=true" ``` -------------------------------- ### Set Configuration with Nacos C# Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/csharp/nacos-csharp-01/README.md Use this endpoint to set configuration values in Nacos. Ensure r-nacos is running and accessible. ```bash curl -i 'http://127.0.0.1:5215/api/config/set?key=abc' ``` -------------------------------- ### Build and Test Commands for r-nacos Source: https://github.com/nacos-group/r-nacos/blob/master/AGENTS.md Commands for building the project, running integration tests, and executing unit tests. ```bash cargo build ``` ```bash python3 integration_tests/scripts/run_test.py ``` ```bash cargo test ``` ```bash cargo test test_name ``` -------------------------------- ### Run r-nacos using Docker Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Deploy r-nacos using Docker by pulling the stable image and running a container. Ensure ports are mapped correctly for access. ```shell # stable is the latest stable version number, you can also specify the image version number, e.g.: qingpan/rnacos:v0.4.0 docker pull qingpan/rnacos:stable docker run --name mynacos -p 8848:8848 -p 9848:9848 -p 10848:10848 -d qingpan/rnacos:stable ``` -------------------------------- ### 加法运算 (Query) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的加法运算,使用 URL 查询参数提交。 ```APIDOC ## GET /q/add ### Description 执行两个数字的加法运算,使用 URL 查询参数提交。 ### Method GET ### Endpoint /q/add ### Parameters #### Query Parameters - **a** (number) - Required - 加数 - **b** (number) - Required - 被加数 ### Request Example ```http GET /q/add?a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 加法运算结果 #### Response Example ```json 15.0 ``` ``` -------------------------------- ### Set Configuration via HTTP API Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Use `curl` to send a POST request to the r-nacos configuration center API to set a configuration value. Requires r-nacos to be running. ```shell # Set configuration curl -X POST 'http://127.0.0.1:8848/nacos/v1/cs/configs' -d 'dataId=t001&group=foo&content=contentTest' ``` -------------------------------- ### Set Configuration using curl Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Use this command to set configuration values in the r-nacos configuration center. Ensure the host and port are correct. ```bash curl -X POST 'http://127.0.0.1:8848/nacos/v1/cs/configs' -d 'dataId=t001&group=foo&content=contentTest' ``` -------------------------------- ### Run r-nacos using Docker Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Pull the r-nacos Docker image and run it, mapping the necessary ports. The container's data directory is /io. ```shell #stable是最新正式版本号,也可以指定镜像版本号,如: qingpan/rnacos:v0.4.0 docker pull qingpan/rnacos:stable docker run --name mynacos -p 8848:8848 -p 9848:9848 -p 10848:10848 -d qingpan/rnacos:stable ``` -------------------------------- ### Run http_naming_beat Test Source: https://github.com/nacos-group/r-nacos/blob/master/loadtest/README.md Executes the http_naming_beat performance test for rnacos. Configure host, user count, and duration. Generates an HTML report. ```shell cargo run --bin http_naming_beat --release -- --host http://127.0.0.1:8848 -r 10 -u 100 -t 60 --report-file report_naming_beat.html ``` -------------------------------- ### 除法运算错误响应 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 当除数为零时,除法运算接口返回的错误详情。 ```json { "detail": "除数不能为零" } ``` -------------------------------- ### 减法运算 (Query) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的减法运算,使用 URL 查询参数提交。 ```APIDOC ## GET /q/subtract ### Description 执行两个数字的减法运算,使用 URL 查询参数提交。 ### Method GET ### Endpoint /q/subtract ### Parameters #### Query Parameters - **a** (number) - Required - 被减数 - **b** (number) - Required - 减数 ### Request Example ```http GET /q/subtract?a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 减法运算结果 #### Response Example ```json 5.0 ``` ``` -------------------------------- ### 乘法运算 (Query) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的乘法运算,使用 URL 查询参数提交。 ```APIDOC ## GET /q/multiply ### Description 执行两个数字的乘法运算,使用 URL 查询参数提交。 ### Method GET ### Endpoint /q/multiply ### Parameters #### Query Parameters - **a** (number) - Required - 乘数 - **b** (number) - Required - 被乘数 ### Request Example ```http GET /q/multiply?a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 乘法运算结果 #### Response Example ```json 50.0 ``` ``` -------------------------------- ### 除法运算 (Query) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的除法运算,使用 URL 查询参数提交。 ```APIDOC ## GET /q/divide ### Description 执行两个数字的除法运算,使用 URL 查询参数提交。 ### Method GET ### Endpoint /q/divide ### Parameters #### Query Parameters - **a** (number) - Required - 被除数 - **b** (number) - Required - 除数 ### Request Example ```http GET /q/divide?a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 除法运算结果 #### Error Response (400) - **detail** (string) - 错误信息,例如 "除数不能为零" #### Response Example ```json 2.0 ``` #### Error Response Example ```json { "detail": "除数不能为零" } ``` ``` -------------------------------- ### Run http_naming_query Test Source: https://github.com/nacos-group/r-nacos/blob/master/loadtest/README.md Executes the http_naming_query performance test for rnacos. Configure host, user count, and duration. Generates an HTML report. ```shell cargo run --bin http_naming_query --release -- --host http://127.0.0.1:8848 -r 10 -u 100 -t 60 --report-file report_naming_query.html ``` -------------------------------- ### Query Configuration using curl Source: https://github.com/nacos-group/r-nacos/blob/master/README.md Use this command to query configuration values from the r-nacos configuration center. Specify the dataId and group to retrieve the correct configuration. ```bash curl 'http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=t001&group=foo' ``` -------------------------------- ### Register Service Instance via HTTP API Source: https://github.com/nacos-group/r-nacos/blob/master/book/src/quick-started.md Use `curl` to register service instances with the r-nacos service discovery API. Multiple instances can be registered for the same service. ```shell # Register service instance curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance' -d 'port=8000&healthy=true&ip=192.168.1.11&weight=1.0&serviceName=nacos.test.001&groupName=foo&metadata={"app":"foo","id":"001"}' curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance' -d 'port=8000&healthy=true&ip=192.168.1.12&weight=1.0&serviceName=nacos.test.001&groupName=foo&metadata={"app":"foo","id":"002"}' curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance' -d 'port=8000&healthy=true&ip=192.168.1.13&weight=1.0&serviceName=nacos.test.001&groupName=foo&metadata={"app":"foo","id":"003"}' ``` -------------------------------- ### Curl 示例 - POST JSON 运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 curl 命令进行 POST JSON 格式的加、减、乘、除运算。 ```bash # 加法 curl -X POST "http://localhost:8002/add" \ -H "Content-Type: application/json" \ -d '{"a": 15, "b": 7}' # 减法 curl -X POST "http://localhost:8002/subtract" \ -H "Content-Type: application/json" \ -d '{"a": 15, "b": 7}' # 乘法 curl -X POST "http://localhost:8002/multiply" \ -H "Content-Type: application/json" \ -d '{"a": 15, "b": 7}' # 除法 curl -X POST "http://localhost:8002/divide" \ -H "Content-Type: application/json" \ -d '{"a": 15, "b": 7}' ``` -------------------------------- ### 加法运算 (Form) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的加法运算,使用 Form 格式提交。 ```APIDOC ## POST /form/add ### Description 执行两个数字的加法运算,使用 Form 格式提交。 ### Method POST ### Endpoint /form/add ### Parameters #### Request Body - **a** (number) - Required - 加数 - **b** (number) - Required - 被加数 ### Request Example ```http POST /form/add Content-Type: application/x-www-form-urlencoded a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 加法运算结果 #### Response Example ```json 15.0 ``` ``` -------------------------------- ### 加法运算 (JSON) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的加法运算。 ```APIDOC ## POST /add ### Description 执行两个数字的加法运算。 ### Method POST ### Endpoint /add ### Parameters #### Request Body - **a** (number) - Required - 加数 - **b** (number) - Required - 被加数 ### Request Example ```json { "a": 10, "b": 5 } ``` ### Response #### Success Response (200) - **result** (number) - 加法运算结果 #### Response Example ```json 15.0 ``` ``` -------------------------------- ### Run http_config_query Test Source: https://github.com/nacos-group/r-nacos/blob/master/loadtest/README.md Executes the http_config_query performance test for rnacos. Configure host, user count, and duration. Generates an HTML report. ```shell cargo run --bin http_config_query --release -- --host http://127.0.0.1:8848 -r 10 -u 100 -t 60 --report-file report_config_query.html ``` -------------------------------- ### POST JSON 加法运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 POST 请求和 JSON 格式进行加法运算。 ```http POST /add Content-Type: application/json { "a": 10, "b": 5 } ``` -------------------------------- ### Curl 示例 - POST Form 运算 Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 使用 curl 命令进行 POST Form 格式的加、减、乘、除运算。 ```bash # POST Form 加法 curl -X POST "http://localhost:8002/form/add" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "a=15&b=7" # POST Form 减法 curl -X POST "http://localhost:8002/form/subtract" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "a=15&b=7" # POST Form 乘法 curl -X POST "http://localhost:8002/form/multiply" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "a=15&b=7" # POST Form 除法 curl -X POST "http://localhost:8002/form/divide" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "a=15&b=7" ``` -------------------------------- ### 减法运算 (Form) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的减法运算,使用 Form 格式提交。 ```APIDOC ## POST /form/subtract ### Description 执行两个数字的减法运算,使用 Form 格式提交。 ### Method POST ### Endpoint /form/subtract ### Parameters #### Request Body - **a** (number) - Required - 被减数 - **b** (number) - Required - 减数 ### Request Example ```http POST /form/subtract Content-Type: application/x-www-form-urlencoded a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 减法运算结果 #### Response Example ```json 5.0 ``` ``` -------------------------------- ### 乘法运算 (Form) Source: https://github.com/nacos-group/r-nacos/blob/master/sdk-examples/python/calculate_api/README.md 执行两个数字的乘法运算,使用 Form 格式提交。 ```APIDOC ## POST /form/multiply ### Description 执行两个数字的乘法运算,使用 Form 格式提交。 ### Method POST ### Endpoint /form/multiply ### Parameters #### Request Body - **a** (number) - Required - 乘数 - **b** (number) - Required - 被乘数 ### Request Example ```http POST /form/multiply Content-Type: application/x-www-form-urlencoded a=10&b=5 ``` ### Response #### Success Response (200) - **result** (number) - 乘法运算结果 #### Response Example ```json 50.0 ``` ```