### Quickstart Documentation Test Output Source: https://github.com/mosn/layotto/blob/main/docs/docs/development/test-quickstart.md This is an example output from running a quickstart documentation test, showing successful state operations and resource cleanup. ```bash admindeMacBook-Pro-2:layotto qunli$ mdx docs/en/start/state/start.md latest: Pulling from library/redis Digest: sha256:69a3ab2516b560690e37197b71bc61ba245aafe4525ebdece1d8a0bc5669e3e2 Status: Image is up to date for redis:latest docker.io/library/redis:latest REPOSITORY TAG IMAGE ID CREATED SIZE redis latest bba24acba395 3 days ago 113MB pseudomuto/protoc-gen-doc latest 35472df9ecbb 6 weeks ago 39.5MB apache/skywalking-oap-server 8.0.1-es7 887769fd3bf6 21 months ago 191MB apache/skywalking-ui 8.0.1 42b3b496616e 21 months ago 127MB 5835d4652c057ce7ea109564c3e36351335ec53c3dedb02650f2056d3cc3edd5 appending output to nohup.out runtime client initializing for: 127.0.0.1:34904 SaveState succeeded.key:key1 , value: hello world GetState succeeded.[key:key1 etag:1]: hello world SaveBulkState succeeded.[key:key1 etag:2]: hello world SaveBulkState succeeded.[key:key2 etag:2]: hello world GetBulkState succeeded.key:key1 ,value:hello world ,etag:2 ,metadata:map[] GetBulkState succeeded.key:key4 ,value: ,etag: ,metadata:map[] GetBulkState succeeded.key:key3 ,value: ,etag: ,metadata:map[] GetBulkState succeeded.key:key5 ,value: ,etag: ,metadata:map[] GetBulkState succeeded.key:key2 ,value:hello world ,etag:1 ,metadata:map[] DeleteState succeeded.key:key1 DeleteState succeeded.key:key2 redis-test ``` -------------------------------- ### Install and Run Redis Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/faas/start.md Installs Redis using Homebrew and starts the Redis server. Ensure Redis is accessible externally by modifying `redis.conf` if needed. ```bash > brew install redis > redis-server /usr/local/etc/redis.conf ``` -------------------------------- ### Build and Run Layotto with Go SDK Example Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/sdk_reference/go/start.md Follow these steps to build the Layotto binary, add it to your PATH, start Layotto with a configuration file, and then run the Go SDK client program. ```shell # 1. Execute the following commands sequentially in the root directory of the project # build a layotto binary program, and add it to the environment variables for easy subsequent operations cd cmd/layotto go build -o layotto export PATH=$PATH:$(pwd)/layotto # 2.Run layotto according to the configuration file layotto start -c ../../configs/config_hello.json # 3.Start another terminal and launch the go sdk client program cd demo/hello/common go build -o client ./client -s helloworld ## output: runtime client initializing for: 127.0.0.1:34904 greeting ``` -------------------------------- ### Install Go SDK Source: https://context7.com/mosn/layotto/llms.txt Install the Layotto Go SDK using the go get command. ```bash go get github.com/layotto/go-sdk ``` -------------------------------- ### Start MySQL Demo with Docker Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/sequencer/mysql.md Use this command to start a MySQL instance in a Docker container for demonstration purposes. Ensure Docker is installed and running. ```shell docker run --name mysql-test -d -p 3306:3306 mysql ``` -------------------------------- ### Run Quickstart Check with `make quickstart` Source: https://github.com/mosn/layotto/blob/main/docs/docs/development/commands.md Executes a quickstart check test. ```bash make quickstart ``` -------------------------------- ### Example of Failed Quickstart Test Output Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/development/test-quickstart.md This output shows an example of an error encountered during Quickstart documentation testing, specifically a 'panic' due to an 'etag mismatch' when deleting a state. ```bash SaveState succeeded.key:key1 , value: hello world GetState succeeded.[key:key1 etag:1]: hello world SaveBulkState succeeded.[key:key1 etag:2]: hello world SaveBulkState succeeded.[key:key2 etag:2]: hello world GetBulkState succeeded.key:key2 ,value:hello world ,etag:1 ,metadata:map[] GetBulkState succeeded.key:key1 ,value:hello world ,etag:2 ,metadata:map[] GetBulkState succeeded.key:key3 ,value: ,etag: ,metadata:map[] GetBulkState succeeded.key:key4 ,value: ,etag: ,metadata:map[] GetBulkState succeeded.key:key5 ,value: ,etag: ,metadata:map[] panic: error deleting state: rpc error: code = Aborted desc = failed deleting state with key key1: possible etag mismatch. error from state store: ERR Error running script (call to f_9b5da7354cb61e2ca9faff50f6c43b81c73c0b94): @user_script:1: user_script:1: failed to delete key1 goroutine 1 [running]: main.testDelete(0x16bc760, 0xc0000ac000, 0x16c56a0, 0xc0000b90e0, 0x15f30e1, 0x5, 0x15f2539, 0x4) /Users/qunli/projects/layotto/demo/state/redis/client.go:73 +0x13d main.main() /Users/qunli/projects/layotto/demo/state/redis/client.go:57 +0x2f4 exit status 2 ``` -------------------------------- ### Run Quickstart Documentation Source: https://github.com/mosn/layotto/blob/main/docs/docs/development/test-quickstart.md Use this command to run a specific quickstart documentation file. Ensure you have the necessary Docker images, like Redis, pulled. ```shell mdx docs/en/start/state/start.md ``` -------------------------------- ### Run CI Quickstart Tests Source: https://github.com/mosn/layotto/blob/main/docs/docs/development/test-quickstart.md Execute this command at the project root to run the CI tests for quickstart documentation. ```shell make style.quickstart ``` -------------------------------- ### Clone and Build Java Sequencer Example Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/sequencer/start.md Clone the Java SDK repository, navigate to the examples directory, and build the example JAR file using Maven. ```bash git clone https://github.com/layotto/java-sdk cd java-sdk mvn -f examples-sequencer/pom.xml clean package ``` -------------------------------- ### Start Local Development Server Source: https://github.com/mosn/layotto/blob/main/docs/README.md Starts a local development server for live preview. Changes are reflected without server restarts. ```bash yarn start ``` -------------------------------- ### Build Java Examples Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/phone/start.md Build the example JAR file for the Java SDK. This command will only run if the JAR does not already exist. ```bash # build example jar mvn -f examples-phone/pom.xml clean package ``` -------------------------------- ### Client Demo Output Example Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/configuration/start-apollo.md This output indicates that the client successfully performed save, get, delete, and subscribe operations on the configuration data through Layotto. ```bash save key success get configuration after save, &{Key:key1 Content:value1 Group:application Label:prod Tags:map[feature:print release:1.0.0] Metadata:map[]} get configuration after save, &{Key:haha Content:heihei Group:application Label:prod Tags:map[feature:haha release:1.0.0] Metadata:map[]} delete keys success write start receive subscribe resp store_name:"config_demo" app_id:"apollo" items: tags: > ``` -------------------------------- ### Add Quickstart to CI Script Source: https://github.com/mosn/layotto/blob/main/docs/docs/development/test-quickstart.md Modify the `etc/script/test-quickstart.sh` script to include your new quickstart documentation for automated testing. ```shell etc/script/test-quickstart.sh ``` -------------------------------- ### Build and Run Java SDK Example Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/oss/start.md Build the Java SDK example JAR file using Maven and then run it. This demonstrates interaction with Layotto's ObjectStorageService. ```shell # build example jar mvn -f examples-oss/pom.xml clean package ``` ```shell java -jar examples-oss/target/examples-oss-jar-with-dependencies.jar ``` -------------------------------- ### Build and Start Layotto Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/file/minio.md Compile the Layotto binary and start the Layotto server with the specified configuration file. Ensure you have replaced `${project_path}` with your actual project path. ```shell #备注 请将${project_path}替换成你的项目路径 cd ${project_path}/cmd/layotto go build -o layotto ./layotto start --config ../../configs/config_file.json ``` -------------------------------- ### Start Minikube with VirtualBox and Containerd Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/faas/start.md Starts a Minikube cluster using the VirtualBox driver and containerd as the container runtime. ```bash > minikube start --driver=virtualbox --container-runtime=containerd ``` -------------------------------- ### Generate All Code and Documentation Source: https://github.com/mosn/layotto/blob/main/docs/docs/api_reference/how_to_generate_api_doc.md Execute this command in the project root to generate all associated files, including Go code, SDK, sidecar code, API reference, quickstart guides, and update CI scripts. Requires Docker to be enabled. ```shell make proto ``` -------------------------------- ### Start Minikube Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/istio/start.md Starts the minikube cluster. This is a prerequisite for deploying services. ```bash minikube start ``` -------------------------------- ### Build and Start Layotto (Shell) Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/design/pluggable/usage.md Build the Layotto executable and start it with a configuration file that specifies the pluggable component. ```shell cd cmd/layotto go build -o layotto. ./layotto start -c ../../configs/config_hello_component.json ``` -------------------------------- ### Build and Start Layotto Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/configuration/start.md Build the Layotto executable and then start Layotto using a configuration file that specifies Etcd as the configuration center. Ensure you are in the correct project directory. ```bash cd ${project_path}/cmd/layotto go build -o layotto ./layotto start -c ../../configs/runtime_config.json ``` -------------------------------- ### Start Layotto Runtime Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/faas/start.md Starts the Layotto runtime within the Minikube VM, using the specified configuration file. ```bash > minikube ssh > layotto start -c /home/docker/config.json ``` -------------------------------- ### Aliyun OSS Component Configuration Example Source: https://github.com/mosn/layotto/blob/main/docs/docs/design/file/file-design.md Example configuration for the Aliyun OSS component, specifying its type, endpoint, credentials, and buckets. This demonstrates how to configure backend storage. ```json { "file": { "file_demo": { "type": "aliyun.oss", "metadata":[ { "endpoint": "endpoint_address", "accessKeyID": "accessKey", "accessKeySecret": "secret", "bucket": ["bucket1", "bucket2"] } ] } } } ``` -------------------------------- ### Build and Start Layotto Server with UDS Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/uds/start.md Build the Layotto binary and start the server using the UDS configuration file. Ensure the project path is correctly set. ```shell cd ${project_path}/cmd/layotto go build -o layotto ``` ```shell ./layotto start -c ../../configs/config_uds.json ``` -------------------------------- ### Build and Start Layotto Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/file/qiniu_oss.md Commands to build the Layotto executable and start it with the Qiniu OSS configuration file. ```shell cd cmd/layotto_multiple_api/ go build -o layotto ./layotto start -c ../../configs/config_file_qiniu_oss.json ``` -------------------------------- ### Build and Run Layotto Locally Source: https://context7.com/mosn/layotto/llms.txt Clone the repository, start a Redis instance, build Layotto, and then start Layotto with a Redis configuration file. ```bash git clone https://github.com/mosn/layotto.git cd layotto docker run -itd --name redis-test -p 6380:6379 redis cd cmd/layotto go build -o layotto ./layotto start -c ../../configs/config_redis.json ``` -------------------------------- ### Redis Pub/Sub Component Configuration Example Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/pubsub/common.md Illustrates a specific configuration for a Redis-based Pub/Sub component. This example shows how to set the Redis host and password within the metadata. ```json "pub_subs": { "pubsub_dmoe": { "type": "redis", "metadata": { "redisHost": "localhost:6380", "redisPassword": "" } } }, ``` -------------------------------- ### Start Etcd and Layotto with Docker Compose Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/configuration/start.md Use this command to start Etcd and Layotto using Docker Compose. Navigate to the specified directory first. ```bash cd docker/layotto-etcd docker-compose up -d ``` -------------------------------- ### Build Java SDK Example for Lock Demo Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/lock/start.md Clones the Java SDK, builds the example JAR, and prepares to run the distributed lock demonstration. This involves Maven for building. ```shell git clone https://github.com/layotto/java-sdk cd java-sdk # build example jar mvn -f examples-lock/pom.xml clean package ``` -------------------------------- ### Example Proto File with Service Definition Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/api_reference/how_to_generate_api_doc.md This is an example of a proto file defining an EmailService with two RPC methods. It serves as a basis for generating API documentation and code. ```protobuf // EmailService is used to send emails. service EmailService { // Send an email with template rpc SendEmailWithTemplate(SendEmailWithTemplateRequest) returns (SendEmailWithTemplateResponse) {} // Send an email with raw content instead of using templates. rpc SendEmail(SendEmailRequest) returns (SendEmailResponse) {} } // different message types...... ``` -------------------------------- ### Run CI Quickstart Tests with Specific Version Source: https://github.com/mosn/layotto/blob/main/docs/docs/development/test-quickstart.md Use this command to run quickstart documentation tests for a specific Go version (e.g., 1.17). This is useful for testing compatibility with different Go environments. ```shell make style.quickstart QUICKSTART_VERSION=1.17 ``` -------------------------------- ### Build and Run Configuration Demo Source: https://github.com/mosn/layotto/blob/main/demo/configuration/common/README.md Build the client executable and then run it, specifying the configuration component name using the -s flag. ```bash go build -o client ./client -s "config_demo" ``` -------------------------------- ### Clone and Build Java SDK Example Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/cryption/start.md Clone the Java SDK repository and build the example JAR file for the CryptionService. This involves navigating to the SDK directory and using Maven for the build process. ```shell git clone https://github.com/layotto/java-sdk ``` ```shell cd java-sdk ``` ```shell # build example jar mvn -f examples-cryption/pom.xml clean package ``` -------------------------------- ### Start Layotto Service Source: https://github.com/mosn/layotto/blob/main/docs/blog/code/webassembly/index.md This Go function checks if a Layotto instance is already running on localhost:2045. If not, it starts a new Layotto process with a specified configuration file. This is part of the setup for Layotto's FaaS mode. ```go func startLayotto() { conn, err := net.Dial("tcp", "localhost:2045") if err == nil { conn.Close() return } cmd := exec.Command("layotto", "start", "-c", "/home/docker/config.json") cmd.Start() } ``` -------------------------------- ### Start Redis and Layotto with Docker Compose Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/pubsub/start.md Deploy Redis and Layotto using Docker Compose for a quick setup. This is recommended for non-Windows users. ```bash cd docker/layotto-redis # Start redis and layotto with docker-compose docker-compose up -d ``` -------------------------------- ### Connection Pool Get Method Source: https://github.com/mosn/layotto/blob/main/docs/blog/code/layotto-rpc/index.md Retrieves a connection from the pool or creates a new one if none are available. It also starts a readloop goroutine for handling data from Mosn. ```go // Get is get wrapConn by context.Context func (p *connPool) Get(ctx context.Context) (*wrapConn, error) { if err := p.waitTurn(ctx); err != nil { return nil, err } p.mu.Lock() // 1. 从连接池获取连接 if ele := p.free.Front(); ele != nil { p.free.Remove(ele) p.mu.Unlock() wc := ele.Value.(*wrapConn) if !wc.isClose() { return wc, nil } } else { p.mu.Unlock() } // 2. 创建新的连接 c, err := p.dialFunc() if err != nil { p.freeTurn() return nil, err } wc := &wrapConn{Conn: c} if p.stateFunc != nil { wc.state = p.stateFunc() } // 3. 启动 readloop 独立协程读取 Mosn 返回的数据 if p.onDataFunc != nil { utils.GoWithRecover(func() { p.readloop(wc) }, nil) } return wc, nil } ``` -------------------------------- ### Build and Run Hello Component Demo Source: https://github.com/mosn/layotto/blob/main/demo/hello/common/README.md Build the client executable and run the demo with a specified component name. This is useful for testing different component configurations. ```bash go build -o client ./client -s "helloworld" ``` -------------------------------- ### Generate All Artifacts with Make Proto Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/api_reference/how_to_generate_api_doc.md Execute this command in the Layotto directory to generate all artifacts, including Go code, API reference docs, quickstart guides, and updated CI scripts. ```shell make proto ``` -------------------------------- ### Run Quickstart Documentation Test Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/development/test-quickstart.md Execute all shell scripts within a specified markdown file using the 'mdx' tool. Ensure local conflicting software is closed before running. ```shell mdx docs/en/start/state/state.md ``` -------------------------------- ### Layotto MinIO Configuration Example Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/file/minio.md This JSON snippet shows the configuration for Layotto to connect to MinIO. Modify the endpoint, accessKeyID, and accessKeySecret to match your MinIO deployment. SSL should be set according to your MinIO setup. ```json { "file": { "minio": { "metadata":[ { "endpoint": "play.min.io", "accessKeyID": "Q3AM3UQ867SPQQA43P2F", "accessKeySecret": "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", "SSL":true, "region":"us-east-1" } ] } } } ``` -------------------------------- ### Hidden Command for Directory Navigation Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/development/test-quickstart.md Embed commands within an HTML comment to hide them from the documentation but still execute them during testing. This example shows how to navigate back to the parent directory and optionally wait for a service to start. ```shell ```shell # open a new terminal tab # change directory to ${your project path}/demo/state/redis/ cd demo/state/redis/ go run . ``` ``` -------------------------------- ### Kubernetes: Actuator API Probe Configuration Source: https://context7.com/mosn/layotto/llms.txt Example Kubernetes probe configuration for Layotto's Actuator API. Sets up liveness and readiness probes using HTTP GET requests to the specified Actuator endpoints. ```yaml livenessProbe: httpGet: path: /actuator/health/liveness port: 34999 initialDelaySeconds: 3 periodSeconds: 10 readinessProbe: httpGet: path: /actuator/health/readiness port: 34999 initialDelaySeconds: 3 periodSeconds: 5 ``` -------------------------------- ### Quick Start: Running a WASM Module with Layotto Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/wasm/start.md This section guides you through the process of running a WASM module with Layotto, including setting up a Redis instance, building Layotto, and sending a request to trigger the WASM logic. ```APIDOC ## Step 1: Start Redis and Write Test Data This step involves setting up a Redis instance, for example, using Docker. ```shell docker run -d --name redis-test -p 6379:6379 redis ``` Execute the following command to set a key-value pair in Redis: ```shell docker exec -i redis-test redis-cli set book1 100 ``` Verify the value: ```shell docker exec -i redis-test redis-cli get book1 ``` Expected output: ``` "100" ``` ## Step 2: Start Layotto Build Layotto with WASM support. You can choose between `wasmtime` or `wasmer` as the runtime. Build with Wasmtime: ```shell @if.not.exist layotto_wasmtime go build -tags wasmcomm,wasmtime -o ./layotto_wasmtime ./cmd/layotto ``` Build with Wasmer: ```shell go build -tags wasmcomm,wasmer -o ./layotto_wasmtime ./cmd/layotto ``` Run Layotto: ```shell @background ./layotto_wasmtime start -c ./demo/faas/config.json ``` **Note:** Ensure the Redis address in `./demo/faas/config.json` is correctly set to your actual Redis instance (default is `localhost:6379`). ## Step 3: Send a Request Send a request to Layotto to interact with the loaded WASM module. ```shell curl -H 'id:id_1' 'localhost:2045?name=book1' ``` Expected output: ``` There are 100 inventories for book1. ``` This request triggers the WASM module, which in turn interacts with Redis. ## Step 4: Clean Up Remove the Redis container. ```shell docker rm -f redis-test ``` ``` -------------------------------- ### Tencent Cloud OSS File Operations Demo Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/file/tencentcloud_oss.md Provides example commands for performing common file operations (put, get, list, delete) on Tencent Cloud OSS using a demo application. Ensure you have built the demo application first. ```shell cd demo/file/tencentcloud go build -o oss ./oss put dir/a.txt aaa #创建文件 ./oss get dir/a.txt #获取文件 ./oss list dir/ #列出目录下文件 ./oss del dir/a.txt #删除文件 ``` -------------------------------- ### Run Go Secret Demo Client Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/secret/start.md Navigate to the Go demo directory, build the client, and run it to retrieve secrets. This example assumes the client binary does not exist. ```shell cd ${project_path}/demo/secret/common/ ``` ```shell go build -o client ``` ```shell ./client -s "secret_demo" ``` -------------------------------- ### HelloWorld Component Implementation Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/development/component_ref/component_ref.md Example implementation of a component that injects and uses configuration and secret stores during initialization. ```go func (hw *HelloWorld) SetConfigStore(cs configstores.Store) (err error) { //save for use hw.config=cs return nil } func (hw *HelloWorld) SetSecretStore(ss secretstores.SecretStore) (err error) { //save for use hw.secretStore = ss return nil } //fetch secret/config when component init func (hw *HelloWorld) Init(config *hello.HelloConfig) error { hw.secretStore.GetSecret(secretstores.GetSecretRequest{ Name: "dbPassword", }) hw.config.Get(context.Background(),&configstores.GetRequest{ Keys: []string{"dbAddress"}, }) return nil } ``` -------------------------------- ### Install Dependencies Source: https://github.com/mosn/layotto/blob/main/docs/README.md Run this command to install project dependencies using Yarn. ```bash yarn ``` -------------------------------- ### Start Grpc Server in grpcServerFilterFactory Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-blog/code/layotto-rpc/index.md Initializes and starts the gRPC server within the grpcServerFilterFactory. It configures interceptors and uses the handler to create and start the server wrapper, ensuring graceful shutdown timeout is set. ```go func (f *grpcServerFilterFactory) Init(param interface{}) error { ... opts := []grpc.ServerOption{ grpc.UnaryInterceptor(f.UnaryInterceptorFilter), grpc.StreamInterceptor(f.StreamInterceptorFilter), } // 经过上述初始化,完成 Grpc registerServerWrapper 的初始化 sw, err := f.handler.New(addr, f.config.GrpcConfig, opts...) if err != nil { return err } // 启动 Grpc sever sw.Start(f.config.GracefulStopTimeout) f.server = sw log.DefaultLogger.Debugf("grpc server filter initialized success") return nil } ... ``` -------------------------------- ### Build and Run Java UDS Client Demo Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/uds/start.md Clone the Java SDK, build the example JAR, and run it to test UDS communication with Layotto. Successful execution will print 'greeting, helloworld'. ```shell git clone https://github.com/layotto/java-sdk cd java-sdk # build example jar mvn -f examples-uds/pom.xml clean package java -jar examples-uds/target/examples-uds-jar-with-dependencies.jar ``` -------------------------------- ### Start Go Subscriber Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/pubsub/start.md Start the Go subscriber program. It listens for messages on a specified topic. ```shell ./subscriber -s pub_subs_demo ``` -------------------------------- ### Build and Run Go Client Demo Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/phone/start.md Navigate to the Go demo directory, build the client, and run it to interact with Layotto's PhoneCallService API. ```bash cd ${project_path}/demo/phone/common/ go build -o client ./client -s "demo" ``` -------------------------------- ### Start Layotto Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/rpc/helloworld.md Start the Layotto runtime with a specified configuration file. This command runs in the background. ```shell ./layotto start -c ../../demo/rpc/http/example.json ``` -------------------------------- ### Navigate to Client Demo Directory Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/configuration/start-apollo.md Change the directory to the location of the client-side demonstration code. ```bash cd ${project_path}/demo/configuration/common ``` -------------------------------- ### Build and Run Java Client Demo Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/lock/start.md Clone the Java SDK, build the example JAR, and run it to test Layotto's distributed lock API. ```bash git clone https://github.com/layotto/java-sdk ``` ```bash cd java-sdk mvn -f examples-lock/pom.xml clean package ``` ```bash java -jar examples-lock/target/examples-lock-jar-with-dependencies.jar ``` -------------------------------- ### Start Etcd Server Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/lock/etcd.md Command to start an Etcd server. Ensure Etcd is downloaded and executable. ```shell ./etcd ``` -------------------------------- ### Start Layotto Server Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/rpc/dubbo_json_rpc.md Start the Layotto server with the specified configuration file for Dubbo JSON RPC. ```shell ./layotto -c demo/rpc/dubbo_json_rpc/example.json ``` -------------------------------- ### Prepare and Run Java Secret Demo Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/secret/start.md Download the Java SDK, change directory, build the example JAR, and then run it to demonstrate secret retrieval. The build step assumes the JAR file does not exist. ```shell git clone https://github.com/layotto/java-sdk ``` ```shell cd java-sdk ``` ```shell # build example jar mvn -f examples-secret/pom.xml clean package ``` ```shell java -jar examples-secret/target/examples-secret-jar-with-dependencies.jar ``` -------------------------------- ### Start Layotto with Etcd Configuration Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/lock/etcd.md Starts the Layotto service using a specified runtime configuration file. ```shell ./layotto start -c ../../configs/runtime_config.json ``` -------------------------------- ### Run Plug Components (Shell) Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/design/pluggable/usage.md Navigate to the component's directory and run the Go program to start the pluggable component. ```shell cd demo/pluggable/hello go run. ``` -------------------------------- ### Build and Run Demo Client Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/trace/jaeger.md Build and run the demo client to test Layotto's SayHello interface. Navigate to the 'demo/flowcontrol' directory before building. ```shell cd ${project_path}/demo/flowcontrol/ ```go // This is a placeholder for the go build command, actual command is below ``` ./client ``` ```go go build -o client ``` -------------------------------- ### Start Layotto with Tencent Cloud OSS Config Source: https://github.com/mosn/layotto/blob/main/docs/docs/component_specs/file/tencentcloud_oss.md Demonstrates how to start the Layotto service with a configuration file specifying Tencent Cloud OSS details. Ensure you have built the Layotto binary first. ```shell cd cmd/layotto_multiple_api/ go build -o layotto ./layotto start -c ../../configs/config_file_tencentcloud_oss.json ``` -------------------------------- ### Example JSON RPC Response Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-blog/code/layotto-rpc/index.md This is an example of the JSON-RPC response format that Layotto might return after processing a request. ```json {"jsonrpc": "2.0", "id":9527, "result":{"id":"113", "name":"Moorse", "age":30,"time":703394193,"sex":"MAN"}} ``` -------------------------------- ### Run Demo Client Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/trace/prometheus.md Execute the demo client to interact with Layotto's SayHello interface and test metrics. ```shell ./client ``` -------------------------------- ### Start Dubbo Server Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/rpc/dubbo_json_rpc.md Start the compiled Dubbo server. A 3-second sleep is included to ensure Zookeeper is ready. ```shell ./server ``` -------------------------------- ### Build and Run Java Subscriber Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/pubsub/start.md Clone the Java SDK, build the example JAR, and run the subscriber. This sets up a listener for pub/sub events. ```bash git clone https://github.com/layotto/java-sdk cd java-sdk # build example jar mvn -f examples-pubsub-subscriber/pom.xml clean package # run the example java -jar examples-pubsub-subscriber/target/examples-pubsub-subscriber-jar-with-dependencies.jar ``` -------------------------------- ### Run Go UDS Client Demo Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/uds/start.md Build and run the Go client demo to test communication with Layotto via UDS. This example demonstrates calling Layotto's 'hellos' component. ```shell cd ${project_path}/demo/uds/ go build client.go # 通过UDS访问layotto的hellos组件 ./client ``` -------------------------------- ### File Component Initialization Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-blog/code/start_process/start_process.md Handles the registration and creation of file components, including their initialization with provided configurations. ```go func (m *MosnRuntime) initFiles(files ...file.FileFactory) ERRORY ERROR LO //register configured components on m.fileRegistry.Register(files...) for name, config := range m. untimesConfig.Files Fact //create/create a new component instance c, err := m.fileRegistry.Create(name) if err !=nil L/ m. rrInt(err, "creation files component %s failed", name) return err } if err := c. nit(context.TODO(), &config); err != nil LO ``` -------------------------------- ### Start Redis Container Source: https://github.com/mosn/layotto/blob/main/docs/docs/start/wasm/start.md Use this command to start a Redis container for testing WASM functionality. Ensure Redis is accessible. ```shell docker run -d --name redis-test -p 6379:6379 redis ``` -------------------------------- ### Run Demo Client Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/trace/zipkin.md Execute the demo client to generate trace data. Navigate to the demo flow control directory and run the client.go file. ```shell cd ${project_path}/demo/flowcontrol/ go run client.go ``` -------------------------------- ### Clone and Build Java SDK Demo Source: https://github.com/mosn/layotto/blob/main/docs/i18n/en-US/docusaurus-plugin-content-docs/current/start/phone/start.md Clone the Java SDK repository, navigate to the SDK directory, and build the example JAR file using Maven. ```bash git clone https://github.com/layotto/java-sdk ``` ```bash cd java-sdk ``` ```bash # build example jar mvn -f examples-phone/pom.xml clean package ```