GO SDK 簡單使用樣例。
下載地址
iGraph GO SDK 讓開發人員可以非常方便地使用 GO 程序操作圖引擎服務
配置方式
/* 必選配置,指定endpoint、用戶名、密碼 */
var client = aliyun_igraph_go_sdk.NewClient("your_endpoint", "your_user_name", "your_password", "your_src")
/*
your_endpoint: igraph-cn-xxxx.igraph.aliyuncs.com
your_user_name: 購買實例時設置的用戶名
your_pass_word: 購買實例時設置的密碼
your_src: 用來標記來源的標識
RequestTimeout: 請求超時設置 默認是1s
MaxConnsPerHost: 單機連接數上限 默認512
*/
var config = aliyun_igraph_go_sdk.ClientConfig{
MaxConnsPerHost: 128,
RequestTimeout: 100 * time.Millisecond,
}
查詢使用樣例
var client = aliyun_igraph_go_sdk.NewClient("http://igraph-cn-xxxx.igraph.aliyuncs", "username", "password", "src")
client.InitConfig(config)
m := make(map[string]string)
readRequest := &aliyun_igraph_go_sdk.ReadRequest{QueryString: "GremlinQuery", QueryParams: m}
resp, err := client.Read(*readRequest)
更新使用樣例
graphName := "graphName"
instanceName := "igraph-cn-xxxx"
labelName := "labelName"
pkey := "pkfieldName"
request := NewWriteRequest(WriteTypeAdd, instanceName, tableName, labelName, pkey, "", map[string]string{})
request.AddContent("field1", "1")
request.AddContent("field2", "1")
request.AddContent("field3", "1")
request.AddContent(pkey, "1")
resp, err := client.Write(*request)
文檔內容是否對您有幫助?