aliyun_igraph_go_sdk

package module
v0.0.0-...-8dab9d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 15 Imported by: 10

README

使用方法

配置

// 必选配置,指定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: 用来标记来源的标识

var config = aliyun_igraph_go_sdk.ClientConfig{
			MaxConnsPerHost: 128,
			RequestTimeout:  100 * time.Millisecond,
		}
RequestTimeout: 请求超时设置 默认是1s
MaxConnsPerHost: 单机连接数上限 默认512

查询使用样例

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)

Documentation

Index

Constants

View Source
const (
	REQUEST_METHOD = "GET"
)

Variables

View Source
var Logger = initDefaultIgraphLogger()

Functions

func GenerateInnerLogger

func GenerateInnerLogger(logFileName, isJsonType, logMaxSize, logFileBackupCount, allowLogLevel string) log.Logger

func LocalIP

func LocalIP() (net.IP, error)

func PrintResult

func PrintResult(i interface{})

func ToJson

func ToJson(i interface{}) string

Types

type BadResponseError

type BadResponseError struct {
	RespBody   string
	RespHeader map[string][]string
	HTTPCode   int
}

BadResponseError define be http bad response error

func NewBadResponseError

func NewBadResponseError(body string, header map[string][]string, httpCode int) *BadResponseError

func (BadResponseError) Error

func (e BadResponseError) Error() string

func (BadResponseError) String

func (e BadResponseError) String() string

type Client

type Client struct {
	Endpoint string
	UserName string
	PassWord string
	Src      string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, userName string, passWord string, src string) *Client

func (*Client) InitConfig

func (c *Client) InitConfig(clientConfig ClientConfig)

func (*Client) Read

func (c *Client) Read(readRequest *ReadRequest) (*Response, error)

func (*Client) WithRequestTimeout

func (c *Client) WithRequestTimeout(timeout time.Duration) *Client

WithRequestTimeout with custom timeout for a request

func (*Client) Write

func (c *Client) Write(writeRequest *WriteRequest) (*Response, error)

type ClientConfig

type ClientConfig struct {
	MaxConnsPerHost int
	RequestTimeout  time.Duration
}

type ClientError

type ClientError struct {
	Message string `json:"errorMessage"`
}

ClientError defines be client error

func NewClientError

func NewClientError(err error) *ClientError

NewClientError new client error

func (ClientError) Error

func (e ClientError) Error() string

func (ClientError) String

func (e ClientError) String() string

type InvalidParamsError

type InvalidParamsError struct {
	Message string
}

func (InvalidParamsError) Error

func (e InvalidParamsError) Error() string

func (InvalidParamsError) String

func (e InvalidParamsError) String() string

type MatchItem

type MatchItem struct {
	FieldNames  []string        `json:"field_names"`
	FieldValues [][]interface{} `json:"field_values"`
}

type ReadRequest

type ReadRequest struct {
	QueryString string            `json:"query_string"`
	QueryParams map[string]string `json:"query_params"`
}

func (*ReadRequest) AddQueryParam

func (r *ReadRequest) AddQueryParam(key string, value string) *ReadRequest

func (*ReadRequest) BuildUri

func (r *ReadRequest) BuildUri() string

func (*ReadRequest) SetQueryParams

func (r *ReadRequest) SetQueryParams(params map[string]string) *ReadRequest

func (*ReadRequest) Validate

func (r *ReadRequest) Validate() error

type ReadResult

type ReadResult struct {
	ErrorInfo []string  `json:"error_info"`
	Result    []*Result `json:"result"`
}

type Response

type Response struct {
	Result []*Result `json:"result"`
}

func NewResponse

func NewResponse(results []*Result) *Response

type Result

type Result struct {
	Data      []map[string]interface{} `json:"data"`
	TraceInfo map[string]string        `json:"trace_info"`
	ErrorInfo []string                 `json:"error_info"`
}

type WriteRequest

type WriteRequest struct {
	WriteType    WriteType         `json:"write_type"`
	InstanceName string            `json:"instance_name"`
	GraphName    string            `json:"graph_name"`
	LabelName    string            `json:"label_name"`
	Contents     map[string]string `json:"contents"`
	PrimaryKey   string            `json:"primary_key"`
	SecondaryKey string            `json:"secondary_key"`
	QueryParams  map[string]string `json:"query_params"`
}

func NewWriteRequest

func NewWriteRequest(writeType WriteType, instanceName string, graphName string, labelName string, primaryKey string, secondaryKey string, contents map[string]string) *WriteRequest

func (*WriteRequest) AddContent

func (r *WriteRequest) AddContent(key string, value string) *WriteRequest

func (*WriteRequest) AddQueryParam

func (r *WriteRequest) AddQueryParam(key string, value string) *WriteRequest

func (*WriteRequest) BuildUri

func (r *WriteRequest) BuildUri() url.URL

func (*WriteRequest) SetQueryParams

func (r *WriteRequest) SetQueryParams(params map[string]string) *WriteRequest

func (*WriteRequest) Validate

func (r *WriteRequest) Validate() error

type WriteResult

type WriteResult struct {
	Errno int `json:"errno"`
}

type WriteType

type WriteType string
const (
	WriteTypeAdd    WriteType = "ADD"
	WriteTypeDelete WriteType = "DELETE"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL