### Starting Pixiu Gateway - Go/Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/springcloud/README.md This command starts the Pixiu gateway by executing its main Go program. It uses a configuration file located at `samples/springcloud/pixiu/conf.yaml` to initialize the gateway. ```bash go run cmd/pixiu/*.go gateway start -c samples/springcloud/pixiu/conf.yaml ``` -------------------------------- ### Displaying Dubbo-Go-Pixiu Start Script Help (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-simple-run.md This snippet shows the output of running `./start.sh help`, which provides a comprehensive guide to the available actions and usage of the `start.sh` script. It details commands for preparing configurations, starting Pixiu, starting the server, running unit tests, and cleaning up resources. ```bash ./start.sh help dubbo-go-pixiu start helper ./start.sh action project hint: ./start.sh prepare body for prepare config file and up docker in body project ./start.sh startPixiu body for start dubbo or http server in body project ./start.sh startServer body for start pixiu in body project ./start.sh startTest body for start unit test in body project ./start.sh clean body for clean ``` -------------------------------- ### Starting Nacos Docker Environment - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/springcloud/README.md This snippet provides commands to navigate to the Docker environment directory and start Nacos services using `docker-compose.yml`. It sets up the Nacos discovery server. ```bash cd samples/springcloud/docker run docker-compose.yml/services ``` -------------------------------- ### Starting SpringCloud Services - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/springcloud/README.md This snippet outlines the steps to start the SpringCloud `auth-service` (on port 8074) and `user-service` (on port 8071) from their respective server directory. These are Java-based services. ```bash cd samples/springcloud/server # the port is 8074 run auth-service # the port is 8071 run user-service ``` -------------------------------- ### Manually Starting Dubbo-Go Pixiu Gateway - Go Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Provides an alternative manual command to start the Dubbo-Go Pixiu gateway directly using `go run`, requiring the absolute path to the configuration file. This is useful for custom setups or debugging. ```Go go run cmd/pixiu/*.go gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbo/simple/body/pixiu/conf.yaml ``` -------------------------------- ### Navigating to Sample Directory - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Changes the current working directory to the `samples/dubbo/simple` path, which is the base location for executing the provided Dubbo-Go Pixiu examples. ```Bash cd samples/dubbo/simple ``` -------------------------------- ### Starting Zookeeper with Docker for Dubbo-Go Http Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/auth-filter.md Instructions to initialize the Zookeeper environment using Docker Compose, which serves as a dependency for the Dubbo-Go Http setup. ```bash cd samples/dubbogo/http/docker run docker-compose.yml/services ``` -------------------------------- ### Displaying Start Script Usage - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Illustrates how to use the `start.sh` script by providing an action and project, and specifically how to retrieve help information about its available commands and options. ```Bash ./start.sh [action] [project] ``` ```Bash ./start.sh help ``` -------------------------------- ### Cloning Dubbo-Go-Pixiu Samples Repository Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This command clones the `dubbo-go-pixiu-samples` repository from GitHub, which contains various demo projects for Dubbo-Go-Pixiu. It is the first step to get the sample code for quick start. ```Shell git clone https://github.com/apache/dubbo-go-pixiu-samples.git ``` -------------------------------- ### Starting Nacos with Docker for Spring Cloud Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/auth-filter.md Instructions to initialize the Nacos environment using Docker Compose, which serves as a service discovery and configuration dependency for the Spring Cloud setup. ```bash cd samples/springcloud/docker run docker-compose.yml/services ``` -------------------------------- ### Preparing Dubbo-Go Pixiu Environment - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Executes the `prepare` action of the `start.sh` script for the 'body' project, which automatically sets up necessary Dubbo server and Pixiu configuration files and starts required Docker containers. ```Bash ./start.sh prepare body ``` -------------------------------- ### Starting Dubbo-go-pixiu Gateway - Shell Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/prometheus.md This command starts the Dubbo-go-pixiu gateway, instructing it to use the provided YAML configuration file. This initiates the Pixiu service with the configured listeners, clusters, and the Prometheus metric filter. ```shell go run cmd/pixiu/*.go gateway start -c samples/http/simplep/pixiu/conf.yaml ``` -------------------------------- ### Manually Starting Dubbo-Go-Pixiu Gateway Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This command manually starts the Dubbo-Go-Pixiu gateway application directly from its source code. It requires specifying the absolute path to the `conf.yaml` configuration file, allowing for custom setup and debugging. ```Shell go run cmd/pixiu/*.go gateway start -c /[absolute-path]/dubbo-go-pixiu-samples/dubbogo/simple/direct/pixiu/conf.yaml ``` -------------------------------- ### Starting Dubbo-Go Pixiu Gateway - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Launches the Dubbo-Go Pixiu gateway for the 'body' project using the `startPixiu` action of the `start.sh` script, enabling API routing and proxying. ```Bash ./start.sh startPixiu body ``` -------------------------------- ### Starting Dubbo-Go-Pixiu Gateway for Direct Sample Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This command starts the Dubbo-Go-Pixiu gateway instance for the 'direct' sample. Once running, Pixiu will be ready to receive external requests and forward them to the backend Dubbo/HTTP server. ```Shell ./start.sh startPixiu direct ``` -------------------------------- ### Starting Dubbo or HTTP Server - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Initiates the backend Dubbo or HTTP server for the 'body' project by running the `startServer` action of the `start.sh` script, making the service available for the gateway. ```Bash ./start.sh startServer body ``` -------------------------------- ### Executing Dubbo-Go-Pixiu Sample Lifecycle Actions (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-simple-run.md This set of commands demonstrates how to use the `start.sh` script to manage the full lifecycle of a `dubbo-go-pixiu` sample, specifically for the 'body' project. It includes commands for preparing the environment, starting Pixiu, starting the server, running tests, and cleaning up all associated resources. ```bash ./start.sh prepare body ./start.sh startPixiu body ./start.sh startServer body ./start.sh startTest body ./start.sh clean body ``` -------------------------------- ### Starting Pixiu Gateway for Dubbo-Go Http Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/auth-filter.md Command to start the Apache Dubbo-Go Pixiu gateway, loading its configuration from a specific YAML file tailored for the Dubbo-Go Http environment. ```bash go run cmd/pixiu/*.go gateway start -c samples/dubbogo/simple/jwt/pixiu/conf.yaml ``` -------------------------------- ### Starting Pixiu Gateway with Configuration Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/fail-inject.md This shell command executes the Dubbo-Go Pixiu gateway application. It uses the 'go run' command to build and run the main package located in 'cmd/pixiu/' and starts the gateway with the specified configuration file 'samples/http/simplep/pixiu/conf.yaml'. ```Shell go run cmd/pixiu/*.go gateway start -c samples/http/simplep/pixiu/conf.yaml ``` -------------------------------- ### Complete Dubbo-Go Pixiu XDS Adaptor Configuration (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/pkg/config/xds/README.md This comprehensive YAML configuration demonstrates a full setup for the XDS adaptor module. It includes the unique `node` identifier, `dynamic_resources` for LDS and CDS pointing to the XDS server, `static_resources` defining the XDS server cluster, and `shutdown_config` for graceful termination, providing a complete operational example. ```yaml node: id: "test-id" cluster: "pixiu" dynamic_resources: lds_config: cluster_name: ["xds-server"] api_type: "GRPC" refresh_delay: "5s" request_timeout: "10s" grpc_services: - timeout: "5s" cds_config: cluster_name: ["xds-server"] api_type: "GRPC" refresh_delay: "5s" request_timeout: "10s" grpc_services: - timeout: "5s" static_resources: clusters: - name: "xds-server" type: "Static" endpoints: - socket_address: address: "127.0.0.1" port: 18000 shutdown_config: timeout: "60s" step_timeout: "10s" reject_policy: "immediacy" ``` -------------------------------- ### Starting Spring Cloud Services Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/auth-filter.md Commands to start the `auth-service` (on port 8074) and `user-service` (on port 8071) for the Spring Cloud environment, acting as backend services. ```bash cd samples/springcloud/server # the port is 8074 run auth-service # the port is 8071 run user-service ``` -------------------------------- ### Starting Pixiu Gateway for Spring Cloud Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/auth-filter.md Command to start the Apache Dubbo-Go Pixiu gateway, configured to route requests to Spring Cloud services using a specific YAML configuration file. ```bash go run cmd/pixiu/*.go gateway start -c samples/dubbogo/simple/jwt/pixiu/springcloud-conf.yaml ``` -------------------------------- ### Calling SpringCloud Services via Pixiu - cURL/Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/springcloud/README.md These cURL commands demonstrate how to access the `user-service` and `auth-service` through the Pixiu gateway running on `localhost:8888`. They show how to interact with the services using their respective service IDs. ```bash # the serviceId is `user-provider` curl http://localhost:8888/user-service/echo/Pixiu # the serviceId is `auth-provider` curl http://localhost:8888/auth-service/echo/Pixiu ``` -------------------------------- ### Example JSON Response for Mix GET Request Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/http-uri.md This JSON object displays the successful response for the mix GET request, providing details of the user identified by the URI parameter. It confirms that the URI parameter was correctly extracted and used to fetch the user's information. ```JSON { "id": "0001", "name": "tc", "age": 18, "time": "2020-12-28T13:38:25.687309+08:00" } ``` -------------------------------- ### Preparing Dubbo-Go-Pixiu Direct Sample Environment Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This command prepares the configuration files for the Dubbo server and Pixiu gateway, and then starts the necessary Docker containers for the 'direct' sample. This sets up the backend services required for Pixiu to function. ```Shell ./start.sh prepare direct ``` -------------------------------- ### Cleaning Up Dubbo-Go Pixiu Resources - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Executes the `clean` action of the `start.sh` script for the 'body' project, which removes generated files and stops any running Docker containers, preparing the environment for a fresh start. ```Bash ./start.sh clean body ``` -------------------------------- ### Example JSON Response for Passthrough GET Request Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/http-uri.md This JSON object represents a successful response for the passthrough GET request, showing the retrieved user's id, name, age, and time. It confirms that the query parameter was correctly processed and used to fetch the corresponding user data. ```JSON { "id": "XVlBz", "name": "joe2", "age": 20, "time": "2021-01-01T00:00:00Z" } ``` -------------------------------- ### Starting Dubbo-Go Http Server Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/auth-filter.md Command to run the Go-based Http server, which acts as the backend service for the Dubbo-Go environment, configured with JWT authentication. ```bash go run samples/dubbogo/simple/jwt/server/server.go ``` -------------------------------- ### Starting Dubbo or HTTP Server for Direct Sample Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This command initiates the Dubbo or HTTP server for the 'direct' sample, which acts as the backend service that Dubbo-Go-Pixiu will proxy requests to. It's a prerequisite for running Pixiu. ```Shell ./start.sh startServer direct ``` -------------------------------- ### Testing Dubbo-go Pixiu GET Endpoints (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-multi.md These curl commands demonstrate how to test the configured RESTful GET endpoints for StudentService and TeacherService. They send HTTP GET requests to the Pixiu gateway, passing the student/teacher name as a URI path parameter. ```bash curl localhost:8888/api/v1/test-dubbo/student/tc-student -X GET and curl localhost:8888/api/v1/test-dubbo/teacher/tc-teacher -X GET ``` -------------------------------- ### Configuring Pixiu API Gateway for User Creation (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-body(http).md This YAML configuration defines a RESTful endpoint '/api/v1/test-dubbo/user' for POST requests. It specifies a required query string 'name', sets a timeout, and configures the integration request to a Dubbo service at '127.0.0.1:8889' with a specific path, group, and version. This setup enables the API gateway to proxy and validate requests before forwarding them to the backend. ```YAML name: pixiu description: pixiu sample resources: - path: '/api/v1/test-dubbo/user' type: restful description: user methods: - httpVerb: POST enable: true timeout: 1000ms inboundRequest: requestType: http queryStrings: - name: name required: true integrationRequest: requestType: http host: 127.0.0.1:8889 path: /UserProvider/CreateUser group: "test" version: 1.0.0 ``` -------------------------------- ### Testing Dubbo-Go Pixiu Request - Bash Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/user/start.md Demonstrates how to send a POST request to the running Pixiu gateway using `curl` with a JSON payload to test the Dubbo service, and also how to execute automated tests via the `start.sh` script. ```Bash curl -X POST 'localhost:8881/api/v1/test-dubbo/user' -d '{\"id\":\"0003\",\"code\":3,\"name\":\"dubbogo\",\"age\":99}' --header 'Content-Type: application/json' ``` ```Bash ./start.sh startTest body ``` -------------------------------- ### Running Dubbo-Go-Pixiu Binary with WASM Feature Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This command executes the previously built Dubbo-Go-Pixiu binary (with WASM support) to start the gateway. It requires the absolute path to the configuration file, similar to the `go run` command. ```Shell ./pixiu gateway start -c /[absolute-path]/dubbo-go-pixiu-samples/dubbogo/simple/direct/pixiu/conf.yaml ``` -------------------------------- ### Executing Dubbo-Go-Pixiu Sample Request (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-simple-run.md This command executes the `request.sh` script, which is designed to send requests to the running `dubbo-go-pixiu` sample server. It is typically used after the server has been successfully started to verify its functionality and connectivity. ```bash ./request.sh ``` -------------------------------- ### Starting Dubbo-go-Pixiu Gateway with Configuration Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/http/http-grpc.md This command initiates the Dubbo-go-Pixiu gateway, loading its configuration from the specified YAML file and setting up logging according to the provided log configuration file. This makes the gateway ready to process incoming requests. ```Shell ./dubbo-go-pixiu gateway start --config samples/http/grpc/pixiu/conf.yaml --log-config samples/http/grpc/pixiu/log.yml ``` -------------------------------- ### Running Prometheus PushGateway Docker Container - Shell Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/prometheus.md This command starts the Prometheus PushGateway as a detached Docker container, mapping port 9091 from the container to the host. This makes the PushGateway UI and metrics API accessible on the host's port 9091. ```shell docker run -d -p 9091:9091 prom/pushgateway ``` -------------------------------- ### Executing Passthrough GET Request with Query Parameter (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/http-uri.md This curl command demonstrates a simple GET request to the configured Pixiu endpoint, passing a 'name' query parameter. It shows how to retrieve user data via a passthrough GET operation, where the query string is directly forwarded to the downstream service. ```Bash curl --request GET 'localhost:8888/api/v1/test-http/user?name=joe2' ``` -------------------------------- ### Starting the gRPC Server Application Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/http/http-grpc.md This command executes the Go gRPC server application, making it available to receive gRPC requests. Ensure the server is running before attempting to proxy requests through Dubbo-go-Pixiu. ```Go go run server.go ``` -------------------------------- ### Testing GET Request with URI and Query Parameters (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-mix.md This `curl` command demonstrates how to send a GET request to the configured API endpoint. It includes a URI path parameter (`tc`) and a query string parameter (`age=99`), which are mapped to Dubbo service arguments as defined in the API configuration. ```bash curl localhost:port/api/v1/test-dubbo/user/tc?age=99 -X GET ``` -------------------------------- ### Running Dubbo-Go-Pixiu Docker Container (Basic) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This `docker run` command starts a new Docker container named `pixiu-gateway` from the `dubbogopixiu/dubbo-go-pixiu:latest` image. It maps port 8888 from the container to the host, making the gateway accessible. ```Shell docker run --name pixiu-gateway -p 8888:8888 dubbogopixiu/dubbo-go-pixiu:latest ``` -------------------------------- ### Testing Dubbo-Go Pixiu Endpoints with cURL Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/quick_start_for_windows.md These cURL commands are used to test the running Dubbo-Go Pixiu setup by sending HTTP POST and PUT requests to the configured endpoints. They demonstrate how to interact with the `/api/v1/test-dubbo/user` and `/api/v1/test-dubbo/user2` paths, sending JSON payloads and specifying the content type. ```bash curl -s -X POST "localhost:8881/api/v1/test-dubbo/user" -d "{\"id\":\"0003\",\"code\":3,\"name\":\"dubbogo\",\"age\":99}" --header "Content-Type: application/json" curl -s -X PUT "localhost:8881/api/v1/test-dubbo/user" -d "{\"id\":\"0003\",\"code\":3,\"name\":\"dubbogo\",\"age\":77}" --header "Content-Type: application/json" curl -s -X PUT "localhost:8881/api/v1/test-dubbo/user2" -d "{\"name\":\"dubbogo\",\"user\":{\"id\":\"0003\",\"code\":3,\"name\":\"dubbogo\",\"age\":88}}" --header "Content-Type: application/json" ``` -------------------------------- ### Testing Multiple Query Parameters with cURL (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-query.md This cURL command illustrates how to test the userByNameAndAge API endpoint by sending a GET request with multiple query parameters: 'name' and 'age'. It verifies the gateway's ability to extract and map both parameters to the corresponding Dubbo service method. ```bash curl localhost:port/api/v1/test-dubbo/userByNameAndAge?name=tc&age=99 -X GET ``` -------------------------------- ### Executing Mix GET Request with URI Parameter (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/http-uri.md This curl command demonstrates a GET request to the Pixiu endpoint using a URI parameter ('tc'). It shows how to retrieve user data when the identifier is part of the path, which is then mapped by Pixiu to the appropriate downstream service parameter. ```Bash curl --request GET 'localhost:8888/api/v1/test-http/user/tc' ``` -------------------------------- ### Successful User Creation Response (JSON) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-body(http).md This JSON object represents the expected response from the Pixiu gateway when a new user is successfully added. It includes the `id`, `code`, `name`, `age`, and `time` of the newly created user, indicating a successful operation. ```JSON { "id": "0002", "code": 3, "name": "tiecheng", "age": 18, "time": "0001-01-01T00:00:00Z" } ``` -------------------------------- ### Running Dubbo-Go-Pixiu Docker Container with Custom Config Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md This `docker run` command starts the Pixiu gateway container, mapping port 8888 and mounting local configuration files (`conf.yaml` and `log.yml`) into the container. This allows users to provide custom gateway and logging configurations. ```Shell docker run --name pixiu-gateway -p 8888:8888 \ -v /yourpath/conf.yaml:/etc/pixiu/conf.yaml \ -v /yourpath/log.yml:/etc/pixiu/log.yml \ dubbogopixiu/dubbo-go-pixiu:latest ``` -------------------------------- ### Configuring Dubbo Server and Services (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-multi.md This YAML configuration sets up the Dubbo server, including application details, ZooKeeper registries, and definitions for StudentProvider and TeacherProvider services. It specifies protocols, load balancing, and network parameters for Dubbo communication. ```yaml # dubbo server yaml configure file # application config application: organization: "dubbogoproxy.com" name: "BDTService" module: "dubbogo user-info server" version: "0.0.1" owner: "ZX" environment: "dev" registries: "demoZk1": protocol: "zookeeper" timeout: "3s" address: "127.0.0.1:2181" "demoZk2": protocol: "zookeeper" timeout: "3s" address: "127.0.0.1:2182" services: "StudentProvider": registry: "demoZk1, demoZk2" protocol: "dubbo" # Equivalent to the interface in the dubbo.xml file interface: "com.dubbogo.pixiu.StudentService" loadbalance: "random" warmup: "100" cluster: "failover" group: test version: 1.0.0 methods: - name: "GetStudentByName" retries: 1 loadbalance: "random" "TeacherProvider": registry: "demoZk1, demoZk2" protocol: "dubbo" # Equivalent to the interface in the dubbo.xml file interface: "com.dubbogo.pixiu.TeacherService" loadbalance: "random" warmup: "100" cluster: "failover" group: test version: 1.0.0 methods: - name: "GetTeacherByName" retries: 1 loadbalance: "random" protocols: "dubbo": name: "dubbo" port: 20000 protocol_conf: dubbo: session_number: 700 session_timeout: "20s" getty_session_param: compress_encoding: false tcp_no_delay: true tcp_keep_alive: true keep_alive_period: "120s" tcp_r_buf_size: 262144 tcp_w_buf_size: 65536 pkg_rq_size: 1024 pkg_wq_size: 512 tcp_read_timeout: "1s" tcp_write_timeout: "5s" wait_timeout: "1s" max_msg_len: 1024 session_name: "server" ``` -------------------------------- ### Pushing Multiple Metrics with Labels to PushGateway - Shell Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/prometheus.md This command shows how to push multiple metrics, including a counter and a gauge, along with labels, to the Prometheus PushGateway. It uses a 'here document' with `cat` to provide the metric data to `curl`, targeting a specific job and instance. ```shell cat <:9091/metrics/job/test_job/instance/test_instance # TYPE test_metrics counter test_metrics{label="app1",name="demo"} 100.00 # TYPE another_test_metrics gauge # HELP another_test_metrics Just an example. another_test_metrics 123.45 EOF ``` -------------------------------- ### Configuring Dubbo-go Pixiu API for Query Parameter Retrieval (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-query(http).md This YAML configuration defines a Dubbo-go Pixiu API endpoint (/api/v1/test-dubbo/user) that handles GET requests. It specifies that a 'name' query string parameter is required and maps it to an upstream Dubbo service (UserProvider/GetUserByName) running on 127.0.0.1:8889. ```yaml name: pixiu description: pixiu sample resources: - path: '/api/v1/test-dubbo/user' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http queryStrings: - name: name required: true integrationRequest: requestType: http host: 127.0.0.1:8889 path: /UserProvider/GetUserByName mappingParams: - name: queryStrings.name mapTo: queryStrings.name group: "test" version: 1.0.0 ``` -------------------------------- ### Configuring Dubbo-go Pixiu API Routes with Query Parameters (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-query.md This YAML configuration defines API routes for a Dubbo-go Pixiu gateway. It demonstrates how to map HTTP GET requests with query parameters (name, age, code) to specific Dubbo service methods (GetUserByName, GetUserByNameAndAge, GetUserByCode) of the UserService interface. It specifies parameter mapping types (string, int) and Dubbo service details like application name, interface, method, group, version, and cluster. ```yaml name: pixiu description: pixiu sample resources: - path: '/api/v1/test-dubbo/userByName' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: queryStrings.name mapTo: 0 mapType: "string" applicationName: "UserService" interface: "com.dubbogo.pixiu.UserService" method: "GetUserByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" - path: '/api/v1/test-dubbo/userByNameAndAge' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: queryStrings.name mapTo: 0 mapType: "string" - name: queryStrings.age mapTo: 1 mapType: "int" applicationName: "UserService" interface: "com.dubbogo.pixiu.UserService" method: "GetUserByNameAndAge" group: "test" version: 1.0.0 clusterName: "test_dubbo" - path: '/api/v1/test-dubbo/userByCode' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: queryStrings.code mapTo: 0 mapType: "int" applicationName: "UserService" interface: "com.dubbogo.pixiu.UserService" method: "GetUserByCode" group: "test" version: 1.0.0 clusterName: "test_dubbo" ``` -------------------------------- ### Displaying Dubbo-Go-Pixiu Sample Script Help Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/README.md These commands show how to use the `start.sh` script, which is used to manage the sample projects. The `help` action provides detailed information on available actions and projects. ```Shell ./start.sh [action] [project] ./start.sh help ``` -------------------------------- ### Pulling Prometheus PushGateway Docker Image - Shell Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/prometheus.md This command pulls the latest official Docker image for Prometheus PushGateway from Docker Hub. It's the first step to setting up PushGateway in a Docker environment. ```shell docker pull prom/pushgateway ``` -------------------------------- ### Sending POST Request to Pixiu Gateway (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-body(http).md This `curl` command demonstrates how to send a POST request to the configured Pixiu API gateway endpoint. It includes a JSON body with user data (`name`, `id`, `code`, `age`) and sets the `Content-Type` header to `application/json`. This simulates a client interacting with the gateway. ```Bash curl host:port/api/v1/test-dubbo/user -X POST -d '{"name": "tiecheng","id": "0002","code": 3,"age": 18}' --header "Content-Type: application/json" ``` -------------------------------- ### Configuring Dubbo-go-pixiu with Prometheus Metric Filter - YAML Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/prometheus.md This YAML configuration defines a listener for HTTP traffic on port 8888, sets up a route for '/user' to a 'user' cluster, and integrates a Prometheus metric filter. The filter is configured to collect metrics, push them to the specified PushGateway URL ('http://127.0.0.1:9091') every 10 seconds, and use 'pixiu' as the job name. ```yaml static_resources: listeners: - name: "net/http" protocol_type: "HTTP" address: socket_address: address: "0.0.0.0" port: 8888 filter_chains: filters: - name: dgp.filter.httpconnectionmanager config: route_config: routes: - match: prefix: /user route: cluster: user cluster_not_found_response_code: 505 http_filters: - name: dgp.filter.http.httpproxy config: maxIdleConns: 100 maxIdleConnsPerHost: 100 MaxConnsPerHost: 100 - name: dgp.filter.http.prometheusmetric config: metric_collect_rules: metric_path: "/metrics" push_gateway_url: "http://127.0.0.1:9091" counter_push: true push_interval_threshold: 10 push_job_name: "pixiu" config: idle_timeout: 5s read_timeout: 5s write_timeout: 5s clusters: - name: "user" lb_policy: "lb" endpoints: - id: 1 socket_address: address: 127.0.0.1 port: 1314 health_checks: - protocol: "tcp" timeout: 1s interval: 2s healthy_threshold: 4 unhealthy_threshold: 4 shutdown_config: timeout: "60s" step_timeout: "10s" reject_policy: "immediacy" ``` -------------------------------- ### Example Request Body for Multiple Parameters Dubbo Invocation (JSON) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-universality.md This JSON snippet provides an example of a request body for invoking a Dubbo service with multiple parameters. It shows how to define an array of parameter types (e.g., 'java.lang.String', 'object') and their corresponding values, which can include both primitive types and complex JSON objects. ```json { "types": [ "java.lang.String", "object" ], "values": [ "tc", { "id": "0001", "code": 1, "name": "tc", "age": 99 } ] } ``` -------------------------------- ### Testing Single String Query Parameter with cURL (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-query.md This cURL command demonstrates how to test the userByName API endpoint by sending a GET request with a single query parameter 'name'. It targets a local Dubbo-go Pixiu instance, expecting the gateway to extract the 'name' parameter and pass it to the configured Dubbo service. ```bash curl localhost:port/api/v1/test-dubbo/userByName?name=tc -X GET ``` -------------------------------- ### Testing gRPC Service Invocation via Dubbo-go-Pixiu with Curl Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/http/http-grpc.md These curl commands demonstrate how to send HTTP requests to the Dubbo-go-Pixiu gateway, which then proxies them to the gRPC backend. The first command is a GET request, and the second is a POST request with a JSON body, illustrating how to pass parameters to the gRPC service. ```Shell curl http://127.0.0.1:8881/api/v1/provider.UserProvider/GetUser ``` ```Shell curl http://127.0.0.1:8881/api/v1/provider.UserProvider/GetUser -X POST -d '{"userId":1}' ``` -------------------------------- ### Configuring HTTP API Routes in Dubbo-go Pixiu (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/http-uri.md This YAML configuration defines two API routes for Dubbo-go Pixiu: '/api/v1/test-http/user' and '/api/v1/test-http/user/:name'. It specifies GET and POST methods for each, including timeouts, inbound request types, and detailed integration request settings such as host, path, and parameter mappings from URI, query strings, and request body to the downstream service. ```YAML name: pixiu description: pixiu sample resources: - path: '/api/v1/test-http/user' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http queryStrings: - name: name required: true integrationRequest: requestType: http host: "127.0.0.1:1314" path: "/user" - httpVerb: POST enable: true timeout: 10s inboundRequest: requestType: http integrationRequest: requestType: http host: "127.0.0.1:1314" path: "/user/" resources: - path: '/:name' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http queryStrings: - name: name required: true integrationRequest: requestType: http mappingParams: - name: uri.name mapTo: uri.name host: "127.0.0.1:1314" path: "/user/:name" - httpVerb: POST enable: true timeout: 10s inboundRequest: requestType: http integrationRequest: requestType: http host: "127.0.0.1:1314" path: "/user/" mappingParams: - name: uri.name mapTo: requestBody.name - name: requestBody.age mapTo: requestBody.age - name: queryStrings.time mapTo: requestBody.time ``` -------------------------------- ### Configuring RESTful API Endpoints for Dubbo Services (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-multi.md This YAML configuration defines how Dubbo-go Pixiu exposes Dubbo services (StudentService, TeacherService) as RESTful HTTP endpoints. It maps URI path parameters (e.g., ':name') and request body content to Dubbo service method arguments, enabling GET and PUT operations. ```yaml name: pixiu description: pixiu sample resources: - path: '/api/v1/test-dubbo/student/:name' type: restful description: student methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: uri.name mapTo: 0 mapType: "string" applicationName: "StudentService" interface: "com.dubbogo.pixiu.StudentService" method: "GetStudentByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" - httpVerb: PUT enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: uri.name mapTo: 0 mapType: "string" - name: requestBody._all mapTo: 1 mapType: "object" applicationName: "StudentService" interface: "com.dubbogo.pixiu.StudentService" method: "UpdateStudentByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" - path: '/api/v1/test-dubbo/teacher/:name' type: restful description: teacher methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: uri.name mapTo: 0 mapType: "string" applicationName: "TeacherService" interface: "com.dubbogo.pixiu.TeacherService" method: "GetTeacherByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" - httpVerb: PUT enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: uri.name mapTo: 0 mapType: "string" - name: requestBody._all mapTo: 1 mapType: "object" applicationName: "TeacherService" interface: "com.dubbogo.pixiu.TeacherService" method: "UpdateTeacherByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" ``` -------------------------------- ### Pushing Simple Metric to PushGateway - Shell Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/others/prometheus.md This command demonstrates how to push a single, simple metric named 'test_metric' with a value of '123456' to the Prometheus PushGateway. It uses `curl` to send the data to the specified job endpoint. ```shell echo "test_metric 123456" | curl --data-binary @- http://:9091/metrics/job/test_job ``` -------------------------------- ### Defining APIs in Dubbo-go Pixiu Configuration (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/http/http-http.md This YAML configuration defines the API gateway setup for an HTTP to HTTP proxy. It includes a listener on port 8888, routes requests with the prefix '/user' to a 'user' cluster, and applies HTTP filters such as `httpproxy`, `cors`, and `response`. The 'user' cluster is configured to forward requests to `127.0.0.1:1314`. ```YAML --- static_resources: listeners: - name: "net/http" protocol_type: "HTTP" address: socket_address: address: "0.0.0.0" port: 8888 filter_chains: filters: - name: dgp.filter.httpconnectionmanager config: route_config: routes: - match: prefix: "/user" route: cluster: "user" cluster_not_found_response_code: 505 http_filters: - name: dgp.filter.http.httpproxy config: - name: dgp.filter.http.cors config: allow_origin: - api.dubbo.com allow_methods: "" allow_headers: "" expose_headers: "" max_age: "" allow_credentials: false - name: dgp.filter.http.response config: config: idle_timeout: 5s read_timeout: 5s write_timeout: 5s clusters: - name: "user" lb_policy: "lb" endpoints: - id: 1 socket_address: address: 127.0.0.1 port: 1314 timeout_config: connect_timeout: "5s" request_timeout: "10s" shutdown_config: timeout: "60s" step_timeout: "10s" reject_policy: "immediacy" ``` -------------------------------- ### Sending Mock API Request with cURL (Bash) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/mock.md This cURL command demonstrates how to send a GET request to the configured mock API endpoint. It targets 'localhost:8888/api/v1/test-dubbo/mock', which is the path defined in the Dubbo-go-Pixiu configuration. This simulates a client request to the mocked service. ```Bash curl localhost:8888/api/v1/test-dubbo/mock -X GET ``` -------------------------------- ### Configuring Mock API Endpoint in Dubbo-go-Pixiu (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/mock.md This YAML configuration defines a mock API endpoint for Dubbo-go-Pixiu. It sets up a GET method for the path '/api/v1/test-dubbo/mock' with mocking enabled and a timeout of 1000ms. This allows the gateway to return a predefined mock response without forwarding the request to a backend service. ```YAML name: pixiu description: pixiu sample resources: - path: '/api/v1/test-dubbo/mock' type: restful description: mock methods: - httpVerb: GET enable: true mock: true timeout: 1000ms inboundRequest: requestType: http ``` -------------------------------- ### Example JSON Response for Mix POST Request Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/http-uri.md This JSON object shows the successful response for the mix POST request, confirming the creation or update of a user with the provided name, age, and time, along with an ID. It validates that all mixed parameters (URI, query, body) were correctly processed. ```JSON { "id": "XVlBz", "name": "tc2", "age": 19, "time": "2021-01-01T00:00:00Z" } ``` -------------------------------- ### User Already Exists Response (JSON) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-body(http).md This JSON object represents the response from the Pixiu gateway when an attempt is made to add a user who already exists. It contains a `message` field indicating that the 'data is exist', preventing duplicate entries. ```JSON { "message": "data is exist" } ``` -------------------------------- ### Configuring Dubbo-go Pixiu API Gateway for Parameter Mapping (YAML) Source: https://github.com/apache/dubbo-go-pixiu/blob/develop/docs/sample/dubbo/dubbo-mix.md This YAML configuration defines API routes for the Dubbo-go Pixiu gateway. It shows how to map HTTP request parameters (from URI, query strings, and request body) to Dubbo service method arguments. It includes GET and PUT methods for user-related operations, specifying Dubbo application, interface, method, group, version, and cluster details. ```yaml name: pixiu description: pixiu sample resources: - path: '/api/v1/test-dubbo/user/:name' type: restful description: user methods: - httpVerb: GET enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: uri.name mapTo: 0 mapType: "string" - name: queryStrings.age mapTo: 1 mapType: "int" applicationName: "UserService" interface: "com.dubbogo.pixiu.UserService" method: "GetUserByNameAndAge" group: "test" version: 1.0.0 clusterName: "test_dubbo" - httpVerb: PUT enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: uri.name mapTo: 0 mapType: "string" - name: requestBody._all mapTo: 1 mapType: "object" applicationName: "UserService" interface: "com.dubbogo.pixiu.UserService" method: "UpdateUserByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" - path: '/api/v1/test-dubbo/user' type: restful description: user methods: - httpVerb: PUT enable: true timeout: 1000ms inboundRequest: requestType: http integrationRequest: requestType: dubbo mappingParams: - name: queryStrings.name mapTo: 0 mapType: "string" - name: requestBody._all mapTo: 1 mapType: "object" applicationName: "UserService" interface: "com.dubbogo.pixiu.UserService" method: "UpdateUserByName" group: "test" version: 1.0.0 clusterName: "test_dubbo" ```