Browse Source

fix README.md and README_zh.md to be unanimous

wenzuochao 6 years ago
parent
commit
e771872ca5
2 changed files with 137 additions and 3 deletions
  1. 128 2
      README.md
  2. 9 1
      README_zh.md

+ 128 - 2
README.md

@@ -1,6 +1,7 @@
 # Alibaba Cloud Go Software Development Kit
 
-[![Build Status](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go.svg?branch=master)](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go)
+[![Travis Build Status](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go.svg?branch=master)](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go)
+[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/hmhx3lawe4v2ii5c?svg=true)](https://ci.appveyor.com/project/wenzuochao/alibaba-cloud-sdk-go)
 [![Go Report Card](https://goreportcard.com/badge/github.com/aliyun/alibaba-cloud-sdk-go)](https://goreportcard.com/report/github.com/aliyun/alibaba-cloud-sdk-go)
 [![codecov](https://codecov.io/gh/aliyun/alibaba-cloud-sdk-go/branch/master/graph/badge.svg)](https://codecov.io/gh/aliyun/alibaba-cloud-sdk-go)
 [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go?ref=badge_shield)
@@ -36,7 +37,13 @@ If you have any problem while using Go SDK, please [submit an issue](https://git
 
 ## Installation
 
-Run the following commands to install Alibaba Cloud Go SDK:
+Use `go get` to install SDK:
+
+```sh
+$ go get -u github.com/aliyun/alibaba-cloud-sdk-go/sdk
+```
+
+If you have used glide to manage dependence, you can also use glide to install Alibaba Cloud Go SDK:
 
 ```powershell
 glide get github.com/aliyun/alibaba-cloud-sdk-go
@@ -83,6 +90,125 @@ func main() {
 }
 ```
 
+When you create an instance of client, you need to fill out three parameters: `Region ID`、`Access Key ID` and `Access Key Secret`. You can get `Access Key ID` and `Access Key Secret` from console, and get `Region ID` from [region list](https://help.aliyun.com/document_detail/40654.html?spm=5176.doc52740.2.8.FogWrd)
+
+## Keepalive
+Alibaba Cloud Go SDK uses primordial `net/http` of Go language to send and accept requests,so it's  configuration is the same as `net/http`'s,you can use config to deliver configuration to the bottomed httpClient.
+
+```go
+httpTransport := http.Transport{
+    // set http client options
+}
+config := sdk.NewConfig()
+            .WithHttpTransport(&httpTransport)
+            .WithTimeout(timeout)
+ecsClient, err := ecs.NewClientWithOptions(config)
+```
+
+## Concurrent Request
+
+* Due to the concurrency nature of the Go language, we recommend that you control the concurrent requests for the SDK at the application level.
+* In order to facilitate your use, we also provide a direct use of concurrent invocation mode, the relevant concurrency control by the SDK internal implementation.
+
+### Open SDK Client's concurrent function.
+
+```go
+// Maximum Running Vusers
+poolSize := 2
+// The maximum number of requests that can be cached
+maxTaskQueueSize := 5
+
+// Enable asynchronous functionality at creation time
+config := sdk.NewConfig()
+            .WithEnableAsync(true)
+            .WithGoRoutinePoolSize(poolSize)            // Optional,default:5
+            .WithMaxTaskQueueSize(maxTaskQueueSize)     // Optional,default:1000
+ecsClient, err := ecs.NewClientWithOptions(config)
+
+// It can also be opened after client is initialized
+client.EnableAsync(poolSize, maxTaskQueueSize)
+```
+
+##### Make an asynchronous call
+Alibaba Cloud Go SDK supports asynchronous calls in two ways:
+
+1. Using channel as return values
+    ```go
+    responseChannel, errChannel := client.FooWithChan(request)
+
+    // this will block
+    response := <-responseChannel
+    err = <-errChannel
+    ```
+
+2. Use callback to control the callback
+
+    ```go
+    blocker := client.FooWithCallback(request, func(response *FooResponse, err error) {
+        // handle the response and err
+    })
+
+    // blocker which is type of (chan int),is used to control synchronization,when returning 1 means success,and returning 0 means failure.
+    // When <-blocker returns failure,err also will be handled by afferent callback.
+    result := <-blocker
+    ```
+
+## Generalize the call interface(CommonAPI)
+
+### What is CommonAPI
+
+CommonAPI which is launched by Alibaba Cloud Go SDK,is an universal grid way to call API. CommonAPI has the following characteristics: :
+1. Lightweight: only the Core package is required to initiate the call, without the need to download and install the SDK of each product line.
+2. Easy: call the newly released API without updating the SDK.
+3. Iterating fast 
+
+### Start to use
+
+CommonAPI needs to be used in conjunction with the corresponding API documentation to query information about the API.
+
+You can query the API documentation for all products at[Document Center](https://help.aliyun.com/?spm=5176.8142029.388261.173.23896dfaav2hEF).
+
+Launching a CommonAPI request requires you to query the following parameters:
+* Domain name: the generic domain name for the product, which can be viewed in the "call mode" page.
+* API version: the version number of the API, in the form of 'yyyy-mm-dd', which can be found in the "public parameters" page.
+* Interface name (apiName) : the name of the API
+
+We take ECS [DescribeInstanceStatus API](https://help.aliyun.com/document_detail/25505.html?spm=5176.doc25506.6.820.VbHnW6) as an example.
+
+```go
+package main
+
+import (
+	"fmt"
+	"os"
+
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk"
+	"github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
+)
+
+func main() {
+
+	client, err := sdk.NewClientWithAccessKey("cn-hangzhou", os.Getenv("ACCESS_KEY_ID"), os.Getenv("ACCESS_KEY_SECRET"))
+	if err != nil {
+		panic(err)
+	}
+
+	request := requests.NewCommonRequest()
+	request.Domain = "ecs.aliyuncs.com"
+	request.Version = "2014-05-26"
+	request.ApiName = "DescribeInstanceStatus"
+
+	request.QueryParams["PageNumber"] = "1"
+	request.QueryParams["PageSize"] = "30"
+
+	response, err := client.ProcessCommonRequest(request)
+	if err != nil {
+		panic(err)
+	}
+
+	fmt.Print(response.GetHttpContentString())
+}
+```
 
 ## License
 [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go?ref=badge_large)

+ 9 - 1
README_zh.md

@@ -1,8 +1,12 @@
 # 阿里云开发者 Go 工具套件
 
-[![Build Status](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go.svg?branch=master)](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go)
+[![Travis Build Status](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go.svg?branch=master)](https://travis-ci.org/aliyun/alibaba-cloud-sdk-go)
+[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/hmhx3lawe4v2ii5c?svg=true)](https://ci.appveyor.com/project/wenzuochao/alibaba-cloud-sdk-go)
 [![Go Report Card](https://goreportcard.com/badge/github.com/aliyun/alibaba-cloud-sdk-go)](https://goreportcard.com/report/github.com/aliyun/alibaba-cloud-sdk-go)
 [![codecov](https://codecov.io/gh/aliyun/alibaba-cloud-sdk-go/branch/master/graph/badge.svg)](https://codecov.io/gh/aliyun/alibaba-cloud-sdk-go)
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go?ref=badge_shield)
+
+See [英文文档](./README.md)
 
 欢迎使用阿里云开发者工具套件(SDK)。阿里云 Go SDK 让您不用复杂编程即可访问云服务器、云监控等多个阿里云服务。这里向您介绍如何获取阿里云 Go SDK 并开始调用。
 
@@ -197,3 +201,7 @@ func main() {
 	fmt.Print(response.GetHttpContentString())
 }
 ```
+
+## 许可证
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Faliyun%2Falibaba-cloud-sdk-go?ref=badge_large)
+