nebula_go

package module
v3.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 24 Imported by: 19

README

nebula-go

Go Reference functional tests codecov

IMPORTANT: Code of Nebula go client has been transferred from nebula-clients to this repository(nebula-go), and new releases in the future will be published in this repository. Please update your go.mod and imports correspondingly.

Official Nebula Go client which communicates with the server using fbthrift. Currently the latest stable release is v3.4.0

The code in master branch will be updated to accommodate the nightly changes made in NebulaGraph. To Use the console with a stable release of NebulaGraph, please check the branches and use the corresponding version.

Client version Nebula Service Version
v1.0.0 1.x.x
v2.0.0-ga 2.0.0-ga, 2.0.1
v2.5.1 2.5.0
v2.6.0 2.6.0
v3.0.0 3.0.0
v3.1.x 3.1.x
v3.2.x 3.1.x-3.2.x
v3.3.x 3.1.x-3.3.x
v3.4.x 3.1.x-3.4.x
v3.5.x 3.1.x-3.5.x
master 3.x-nightly

Please be careful not to modify the files in the nebula directory, these codes were all generated by fbthrift.

NOTE Installing Nebula Go v2.5.0 could cause checksum mismatch, use v2.5.1 instead.

Install & Update

$ go get -u -v github.com/vesoft-inc/nebula-go/v3@master

You can specify the version of Nebula-go by substituting <tag> in $ go get -u -v github.com/vesoft-inc/nebula-go@<tag>. For example:

for v3: $ go get -u -v github.com/vesoft-inc/nebula-go/v3@v3.4.0

for v2: $ go get -u -v github.com/vesoft-inc/nebula-go/v2@v2.6.0

Note: You will get a message like this if you don't specify a tag:

$ go get -u -v github.com/vesoft-inc/nebula-go/v2@master
go: github.com/vesoft-inc/nebula-go/v2 master => v2.0.0-20210506025434-97d4168c5c4d

Here the 20210506025434-97d4168c5c4d is a version tag auto-generated by GitHub using commit date and SHA. This should match the latest commit in the master branch.

Usage example

Mininal example

Suppose you already initialized your space and defined the schema as:

  1. Vertex person with properties name: string, age: int
  2. Edge like with properties likeness: double

You can query the Nebula by the minimal example:

package main

import (
  nebula "github.com/vesoft-inc/nebula-go/v3"
)

type Person struct {
  Name     string  `nebula:"name"`
  Age      int     `nebula:"age"`
  Likeness float64 `nebula:"likeness"`
}

func main() {
  hostAddress := nebula.HostAddress{Host: "127.0.0.1", Port: 3699}

  config, err := nebula.NewSessionPoolConf(
    "user",
    "password",
    []nebula.HostAddress{hostAddress},
    "space_name",
  )

  sessionPool, err := nebula.NewSessionPool(*config, nebula.DefaultLogger{})

  query := `GO FROM 'Bob' OVER like YIELD
    $^.person.name AS name,
    $^.person.age AS age,
    like.likeness AS likeness`

  resultSet, err := sessionPool.Execute(query)
  if err != nil {
    panic(err)
  }

  var personList []Person
  resultSet.Scan(&personList)
}
More examples

Simple Code Example

Code Example with Goroutines

Session Pool Example

There are some limitations while using the session pool:

  1. There MUST be an existing space in the DB before initializing the session pool.
  2. Each session pool is corresponding to a single USER and a single Space. This is to ensure that the user's access control is consistent. i.g. The same user may have different access privileges in different spaces. If you need to run queries in different spaces, you may have multiple session pools.
  3. Every time when sessionPool.Execute() is called, the session will execute the query in the space set in the session pool config.
  4. Commands that alter passwords or drop users should NOT be executed via session pool.

Code of Conduct

This project and everyone participating in it is governed by the Vesoft Code of Conduct. By participating, you are expected to uphold this code.

Licensing

Nebula GO is under Apache 2.0 license, so you can freely download, modify, and deploy the source code to meet your needs. You can also freely deploy Nebula GO as a back-end service to support your SaaS deployment.

Documentation

Overview

* * Copyright (c) 2024 vesoft inc. All rights reserved. * * This source code is licensed under Apache 2.0 License. *

Index

Constants

View Source
const (
	ErrorTagNotFound  = "TagNotFound: Tag not existed!"
	ErrorEdgeNotFound = "EdgeNotFound: Edge not existed!"
)

Variables

This section is empty.

Functions

func GetDefaultSSLConfig

func GetDefaultSSLConfig(rootCAPath, certPath, privateKeyPath string) (*tls.Config, error)

GetDefaultSSLConfig reads the files in the given path and returns a tls.Config object

func IndexOf added in v3.7.0

func IndexOf(collection []string, element string) int

func IsError

func IsError(resp *graph.ExecutionResponse) bool

func MakeOperatorInfo added in v3.5.0

func MakeOperatorInfo(planNodeDesc *graph.PlanNodeDescription) string

generate operator info for Row format.

func MakeProfilingData added in v3.5.0

func MakeProfilingData(planNodeDesc *graph.PlanNodeDescription, isTckFmt bool) string

generate profiling data for both Row and TCK formats.

Types

type ConnectionPool

type ConnectionPool struct {
	// contains filtered or unexported fields
}

func NewConnectionPool

func NewConnectionPool(addresses []HostAddress, conf PoolConfig, log Logger) (*ConnectionPool, error)

NewConnectionPool constructs a new connection pool using the given addresses and configs

func NewSslConnectionPool

func NewSslConnectionPool(addresses []HostAddress, conf PoolConfig, sslConfig *tls.Config, log Logger) (*ConnectionPool, error)

NewConnectionPool constructs a new SSL connection pool using the given addresses and configs

func (*ConnectionPool) Close

func (pool *ConnectionPool) Close()

Close closes all connection

func (*ConnectionPool) GetSession

func (pool *ConnectionPool) GetSession(username, password string) (*Session, error)

GetSession authenticates the username and password. It returns a session if the authentication succeed.

func (*ConnectionPool) Ping

func (pool *ConnectionPool) Ping(host HostAddress, timeout time.Duration) error

Ping checks availability of host

type DateTimeWrapper

type DateTimeWrapper struct {
	// contains filtered or unexported fields
}

func (DateTimeWrapper) GetLocalDateTimeWithTimezoneName

func (dt DateTimeWrapper) GetLocalDateTimeWithTimezoneName(timezoneName string) (*nebula.DateTime, error)

GetLocalDateTimeWithTimezoneName returns a nebula.DateTime object representing local time using user specified timezone name.

If the name is "" or "UTC", LoadLocation returns UTC. If the name is "Local", LoadLocation returns Local.

Otherwise, the name is taken to be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York".

func (DateTimeWrapper) IsEqualTo

func (dt1 DateTimeWrapper) IsEqualTo(dt2 DateTimeWrapper) bool

type DateWrapper

type DateWrapper struct {
	// contains filtered or unexported fields
}

func (DateWrapper) IsEqualTo

func (d1 DateWrapper) IsEqualTo(d2 DateWrapper) bool

type DefaultLogger

type DefaultLogger struct{}

func (DefaultLogger) Error

func (l DefaultLogger) Error(msg string)

func (DefaultLogger) Fatal

func (l DefaultLogger) Fatal(msg string)

func (DefaultLogger) Info

func (l DefaultLogger) Info(msg string)

func (DefaultLogger) Warn

func (l DefaultLogger) Warn(msg string)

type ErrorCode

type ErrorCode int64
const (
	ErrorCode_SUCCEEDED               ErrorCode = ErrorCode(nebula.ErrorCode_SUCCEEDED)
	ErrorCode_E_DISCONNECTED          ErrorCode = ErrorCode(nebula.ErrorCode_E_DISCONNECTED)
	ErrorCode_E_FAIL_TO_CONNECT       ErrorCode = ErrorCode(nebula.ErrorCode_E_FAIL_TO_CONNECT)
	ErrorCode_E_RPC_FAILURE           ErrorCode = ErrorCode(nebula.ErrorCode_E_RPC_FAILURE)
	ErrorCode_E_BAD_USERNAME_PASSWORD ErrorCode = ErrorCode(nebula.ErrorCode_E_BAD_USERNAME_PASSWORD)
	ErrorCode_E_SESSION_INVALID       ErrorCode = ErrorCode(nebula.ErrorCode_E_SESSION_INVALID)
	ErrorCode_E_SESSION_TIMEOUT       ErrorCode = ErrorCode(nebula.ErrorCode_E_SESSION_TIMEOUT)
	ErrorCode_E_SYNTAX_ERROR          ErrorCode = ErrorCode(nebula.ErrorCode_E_SYNTAX_ERROR)
	ErrorCode_E_EXECUTION_ERROR       ErrorCode = ErrorCode(nebula.ErrorCode_E_EXECUTION_ERROR)
	ErrorCode_E_STATEMENT_EMPTY       ErrorCode = ErrorCode(nebula.ErrorCode_E_STATEMENT_EMPTY)
	ErrorCode_E_USER_NOT_FOUND        ErrorCode = ErrorCode(nebula.ErrorCode_E_USER_NOT_FOUND)
	ErrorCode_E_BAD_PERMISSION        ErrorCode = ErrorCode(nebula.ErrorCode_E_BAD_PERMISSION)
	ErrorCode_E_SEMANTIC_ERROR        ErrorCode = ErrorCode(nebula.ErrorCode_E_SEMANTIC_ERROR)
	ErrorCode_E_PARTIAL_SUCCEEDED     ErrorCode = ErrorCode(nebula.ErrorCode_E_PARTIAL_SUCCEEDED)
)

type HostAddress

type HostAddress struct {
	Host string
	Port int
}

type Label added in v3.8.0

type Label struct {
	Field   string `nebula:"Field"`
	Type    string `nebula:"Type"`
	Null    string `nebula:"Null"`
	Default string `nebula:"Default"`
	Comment string `nebula:"Comment"`
}

func (Label) BuildDropEdgeFieldQL added in v3.8.0

func (field Label) BuildDropEdgeFieldQL(labelName string) string

func (Label) BuildDropTagFieldQL added in v3.8.0

func (field Label) BuildDropTagFieldQL(labelName string) string

type LabelFieldSchema added in v3.8.0

type LabelFieldSchema struct {
	Field    string
	Type     string
	Nullable bool
}

func (LabelFieldSchema) BuildAddEdgeFieldQL added in v3.8.0

func (field LabelFieldSchema) BuildAddEdgeFieldQL(labelName string) string

func (LabelFieldSchema) BuildAddTagFieldQL added in v3.8.0

func (field LabelFieldSchema) BuildAddTagFieldQL(labelName string) string

type LabelName added in v3.8.0

type LabelName struct {
	Name string `nebula:"Name"`
}

type LabelSchema added in v3.8.0

type LabelSchema struct {
	Name        string
	Fields      []LabelFieldSchema
	TTLDuration uint
	TTLCol      string
}

func (LabelSchema) BuildCreateEdgeQL added in v3.8.0

func (edge LabelSchema) BuildCreateEdgeQL() string

func (LabelSchema) BuildCreateTagQL added in v3.8.0

func (tag LabelSchema) BuildCreateTagQL() string

func (LabelSchema) BuildDropEdgeQL added in v3.8.0

func (edge LabelSchema) BuildDropEdgeQL() string

func (LabelSchema) BuildDropTagQL added in v3.8.0

func (tag LabelSchema) BuildDropTagQL() string

type Logger

type Logger interface {
	Info(msg string)
	Warn(msg string)
	Error(msg string)
	Fatal(msg string)
}

type Node

type Node struct {
	// contains filtered or unexported fields
}

func (Node) GetID

func (node Node) GetID() ValueWrapper

GetID returns a list of vid of node

func (Node) GetTags

func (node Node) GetTags() []string

GetTags returns a list of tag names of node

func (Node) HasTag

func (node Node) HasTag(label string) bool

HasTag checks if node contains given label

func (Node) IsEqualTo

func (n1 Node) IsEqualTo(n2 *Node) bool

Returns true if two nodes have same vid

func (Node) Keys

func (node Node) Keys(tagName string) ([]string, error)

Keys returns all prop names of the given tag name

func (Node) Properties

func (node Node) Properties(tagName string) (map[string]*ValueWrapper, error)

Properties returns all properties of a tag

func (Node) String

func (node Node) String() string

String returns a string representing node Node format: ("VertexID" :tag1{k0: v0,k1: v1}:tag2{k2: v2})

func (Node) Values

func (node Node) Values(tagName string) ([]*ValueWrapper, error)

Values returns all prop values of the given tag name

type PathWrapper

type PathWrapper struct {
	// contains filtered or unexported fields
}

func (*PathWrapper) ContainsNode

func (path *PathWrapper) ContainsNode(node Node) bool

func (*PathWrapper) ContainsRelationship

func (path *PathWrapper) ContainsRelationship(relationship *Relationship) bool

func (*PathWrapper) GetEndNode

func (path *PathWrapper) GetEndNode() (*Node, error)

func (*PathWrapper) GetNodes

func (path *PathWrapper) GetNodes() []*Node

func (*PathWrapper) GetPathLength

func (path *PathWrapper) GetPathLength() int

func (*PathWrapper) GetRelationships

func (path *PathWrapper) GetRelationships() []*Relationship

func (*PathWrapper) GetSegments

func (path *PathWrapper) GetSegments() []segment

func (*PathWrapper) GetStartNode

func (path *PathWrapper) GetStartNode() (*Node, error)

func (*PathWrapper) IsEqualTo

func (p1 *PathWrapper) IsEqualTo(p2 *PathWrapper) bool

func (*PathWrapper) String

func (pathWrap *PathWrapper) String() string

Path format: <("VertexID" :tag1{k0: v0,k1: v1}) -[:TypeName@ranking {edgeProps}]-> ("VertexID2" :tag1{k0: v0,k1: v1} :tag2{k2: v2}) -[:TypeName@ranking {edgeProps}]-> ("VertexID3" :tag1{k0: v0,k1: v1})>

type PoolConfig

type PoolConfig struct {
	// Socket timeout and Socket connection timeout, unit: seconds
	TimeOut time.Duration
	// The idleTime of the connection, unit: seconds
	// If connection's idle time is longer than idleTime, it will be delete
	// 0 value means the connection will not expire
	IdleTime time.Duration
	// The max connections in pool for all addresses
	MaxConnPoolSize int
	// The min connections in pool for all addresses
	MinConnPoolSize int
	// UseHTTP2 indicates whether to use HTTP2
	UseHTTP2 bool
	// HttpHeader is the http headers for the connection when using HTTP2
	HttpHeader http.Header
	// client handshakeKey, make sure the client handshakeKey is in the white list of NebulaGraph server 'client_white_list'
	HandshakeKey string
}

PoolConfig is the configs of connection pool

func GetDefaultConf

func GetDefaultConf() PoolConfig

GetDefaultConf returns the default config

type Record

type Record struct {
	// contains filtered or unexported fields
}

func (Record) GetValueByColName

func (record Record) GetValueByColName(colName string) (*ValueWrapper, error)

Returns value in the record at given column name

func (Record) GetValueByIndex

func (record Record) GetValueByIndex(index int) (*ValueWrapper, error)

Returns value in the record at given column index

func (Record) String

func (record Record) String() string

type Relationship

type Relationship struct {
	// contains filtered or unexported fields
}

func (Relationship) GetDstVertexID

func (relationship Relationship) GetDstVertexID() ValueWrapper

func (Relationship) GetEdgeName

func (relationship Relationship) GetEdgeName() string

func (Relationship) GetRanking

func (relationship Relationship) GetRanking() int64

func (Relationship) GetSrcVertexID

func (relationship Relationship) GetSrcVertexID() ValueWrapper

func (Relationship) IsEqualTo

func (r1 Relationship) IsEqualTo(r2 *Relationship) bool

func (Relationship) Keys

func (relationship Relationship) Keys() []string

Keys returns a list of keys

func (Relationship) Properties

func (relationship Relationship) Properties() map[string]*ValueWrapper

Properties returns a map where the key is property name and the value is property name

func (Relationship) String

func (relationship Relationship) String() string

String returns a string representing relationship Relationship format: [:edge src->dst @ranking {props}]

func (Relationship) Values

func (relationship Relationship) Values() []*ValueWrapper

Values returns a list of values wrapped as ValueWrappers

type ResultSet

type ResultSet struct {
	// contains filtered or unexported fields
}

func GenResultSet added in v3.6.0

func GenResultSet(resp *graph.ExecutionResponse) (*ResultSet, error)

func (ResultSet) AsStringTable

func (res ResultSet) AsStringTable() [][]string

Returns a 2D array of strings representing the query result If resultSet.resp.data is nil, returns an empty 2D array

func (ResultSet) GetColNames

func (res ResultSet) GetColNames() []string

func (ResultSet) GetColSize

func (res ResultSet) GetColSize() int

Returns the number of total columns

func (ResultSet) GetComment

func (res ResultSet) GetComment() string

func (ResultSet) GetErrorCode

func (res ResultSet) GetErrorCode() ErrorCode

Returns an integer representing an error type 0 ErrorCode_SUCCEEDED -1 ErrorCode_E_DISCONNECTED -2 ErrorCode_E_FAIL_TO_CONNECT -3 ErrorCode_E_RPC_FAILURE -4 ErrorCode_E_BAD_USERNAME_PASSWORD -5 ErrorCode_E_SESSION_INVALID -6 ErrorCode_E_SESSION_TIMEOUT -7 ErrorCode_E_SYNTAX_ERROR -8 ErrorCode_E_EXECUTION_ERROR -9 ErrorCode_E_STATEMENT_EMPTY -10 ErrorCode_E_USER_NOT_FOUND -11 ErrorCode_E_BAD_PERMISSION -12 ErrorCode_E_SEMANTIC_ERROR

func (ResultSet) GetErrorMsg

func (res ResultSet) GetErrorMsg() string

func (ResultSet) GetLatency

func (res ResultSet) GetLatency() int64

func (ResultSet) GetLatencyInMs added in v3.8.0

func (res ResultSet) GetLatencyInMs() int64

func (ResultSet) GetPlanDesc

func (res ResultSet) GetPlanDesc() *graph.PlanDescription

func (ResultSet) GetRowSize

func (res ResultSet) GetRowSize() int

Returns the number of total rows

func (ResultSet) GetRowValuesByIndex

func (res ResultSet) GetRowValuesByIndex(index int) (*Record, error)

Returns all values in the row at given index

func (ResultSet) GetRows

func (res ResultSet) GetRows() []*nebula.Row

Returns all rows

func (ResultSet) GetSpaceName

func (res ResultSet) GetSpaceName() string

func (ResultSet) GetValuesByColName

func (res ResultSet) GetValuesByColName(colName string) ([]*ValueWrapper, error)

Returns all values in the given column

func (ResultSet) IsEmpty

func (res ResultSet) IsEmpty() bool

func (ResultSet) IsPartialSucceed

func (res ResultSet) IsPartialSucceed() bool

func (ResultSet) IsSetComment

func (res ResultSet) IsSetComment() bool

func (ResultSet) IsSetData

func (res ResultSet) IsSetData() bool

func (ResultSet) IsSetPlanDesc

func (res ResultSet) IsSetPlanDesc() bool

func (ResultSet) IsSucceed

func (res ResultSet) IsSucceed() bool

func (ResultSet) MakeDotGraph

func (res ResultSet) MakeDotGraph() string

explain/profile format="dot"

func (ResultSet) MakeDotGraphByStruct

func (res ResultSet) MakeDotGraphByStruct() string

explain/profile format="dot:struct"

func (ResultSet) MakePlanByRow

func (res ResultSet) MakePlanByRow() [][]interface{}

explain/profile format="row"

func (ResultSet) MakePlanByTck added in v3.5.0

func (res ResultSet) MakePlanByTck() [][]interface{}

explain/profile format="tck"

func (ResultSet) Scan added in v3.7.0

func (res ResultSet) Scan(v interface{}) error

Scan scans the rows into the given value.

type SchemaManager added in v3.8.0

type SchemaManager struct {
	// contains filtered or unexported fields
}

func NewSchemaManager added in v3.8.0

func NewSchemaManager(pool *SessionPool) *SchemaManager

func (*SchemaManager) ApplyEdge added in v3.8.0

func (mgr *SchemaManager) ApplyEdge(edge LabelSchema) (*ResultSet, error)

ApplyEdge applies the given edge to the graph. 1. If the edge does not exist, it will be created. 2. If the edge exists, it will be checked if the fields are the same. 2.1 If not, the new fields will be added. 2.2 If the field type is different, it will return an error. 2.3 If a field exists in the graph but not in the given edge, it will be removed. 3. If the edge exists and the fields are the same, it will be checked if the TTL is set as expected.

Notice: We won't change the field type because it has unexpected behavior for the data.

func (*SchemaManager) ApplyTag added in v3.8.0

func (mgr *SchemaManager) ApplyTag(tag LabelSchema) (*ResultSet, error)

ApplyTag applies the given tag to the graph. 1. If the tag does not exist, it will be created. 2. If the tag exists, it will be checked if the fields are the same. 2.1 If not, the new fields will be added. 2.2 If the field type is different, it will return an error. 2.3 If a field exists in the graph but not in the given tag, it will be removed. 3. If the tag exists and the fields are the same, it will be checked if the TTL is set as expected.

Notice: We won't change the field type because it has unexpected behavior for the data.

func (*SchemaManager) WithVerbose added in v3.8.0

func (mgr *SchemaManager) WithVerbose(verbose bool) *SchemaManager

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) CreateSpace added in v3.8.0

func (session *Session) CreateSpace(conf SpaceConf) (*ResultSet, error)

func (*Session) Execute

func (session *Session) Execute(stmt string) (*ResultSet, error)

Execute returns the result of the given query as a ResultSet

func (*Session) ExecuteAndCheck added in v3.8.0

func (session *Session) ExecuteAndCheck(stmt string) (*ResultSet, error)

func (*Session) ExecuteJson

func (session *Session) ExecuteJson(stmt string) ([]byte, error)

ExecuteJson returns the result of the given query as a json string Date and Datetime will be returned in UTC

JSON struct:

{
    "results":[
        {
            "columns":[
            ],
            "data":[
                {
                    "row":[
                        "row-data"
                    ],
                    "meta":[
                        "metadata"
                    ]
                }
            ],
            "latencyInUs":0,
            "spaceName":"",
            "planDesc ":{
                "planNodeDescs":[
                    {
                        "name":"",
                        "id":0,
                        "outputVar":"",
                        "description":{
                            "key":""
                        },
                        "profiles":[
                            {
                                "rows":1,
                                "execDurationInUs":0,
                                "totalDurationInUs":0,
                                "otherStats":{}
                            }
                        ],
                        "branchInfo":{
                            "isDoBranch":false,
                            "conditionNodeId":-1
                        },
                        "dependencies":[]
                    }
                ],
                "nodeIndexMap":{},
                "format":"",
                "optimize_time_in_us":0
            },
            "comment ":""
        }
    ],
    "errors":[
        {
      		"code": 0,
      		"message": ""
        }
    ]
}

func (*Session) ExecuteJsonWithParameter

func (session *Session) ExecuteJsonWithParameter(stmt string, params map[string]interface{}) ([]byte, error)

ExecuteJson returns the result of the given query as a json string Date and Datetime will be returned in UTC The result is a JSON string in the same format as ExecuteJson()

func (*Session) ExecuteWithParameter

func (session *Session) ExecuteWithParameter(stmt string, params map[string]interface{}) (*ResultSet, error)

ExecuteWithParameter returns the result of the given query as a ResultSet

func (*Session) GetSessionID

func (session *Session) GetSessionID() int64

func (*Session) Ping added in v3.3.0

func (session *Session) Ping() error

Ping checks if the session is valid

func (*Session) Release

func (session *Session) Release()

Release logs out and releases connection hold by session. The connection will be added into the activeConnectionQueue of the connection pool so that it could be reused.

func (*Session) ShowSpaces added in v3.8.0

func (session *Session) ShowSpaces() ([]SpaceName, error)

type SessionPool added in v3.3.0

type SessionPool struct {
	// contains filtered or unexported fields
}

SessionPool is a pool that manages sessions internally.

Usage: Construct sessionPool = newSessionPool(conf)

Initialize sessionPool.init()

Execute query result = sessionPool.execute("query")

Release: sessionPool.close()

Notice that all queries will be executed in the default space specified in the pool config.

func NewSessionPool added in v3.3.0

func NewSessionPool(conf SessionPoolConf, log Logger) (*SessionPool, error)

NewSessionPool creates a new session pool with the given configs. There must be an existing SPACE in the DB.

func (*SessionPool) AddEdgeTTL added in v3.8.0

func (pool *SessionPool) AddEdgeTTL(tagName string, colName string, duration uint) (*ResultSet, error)

func (*SessionPool) AddTagTTL added in v3.8.0

func (pool *SessionPool) AddTagTTL(tagName string, colName string, duration uint) (*ResultSet, error)

func (*SessionPool) Close added in v3.3.0

func (pool *SessionPool) Close()

Close logs out all sessions and closes bonded connection.

func (*SessionPool) CreateEdge added in v3.8.0

func (pool *SessionPool) CreateEdge(edge LabelSchema) (*ResultSet, error)

func (*SessionPool) CreateTag added in v3.8.0

func (pool *SessionPool) CreateTag(tag LabelSchema) (*ResultSet, error)

func (*SessionPool) DescEdge added in v3.8.0

func (pool *SessionPool) DescEdge(edgeName string) ([]Label, error)

func (*SessionPool) DescTag added in v3.8.0

func (pool *SessionPool) DescTag(tagName string) ([]Label, error)

func (*SessionPool) Execute added in v3.3.0

func (pool *SessionPool) Execute(stmt string) (*ResultSet, error)

Execute returns the result of the given query as a ResultSet Notice there are some limitations: 1. The query should not be a plain space switch statement, e.g. "USE test_space", but queries like "use space xxx; match (v) return v" are accepted. 2. If the query contains statements like "USE <space name>", the space will be set to the one in the pool config after the execution of the query. 3. The query should not change the user password nor drop a user.

func (*SessionPool) ExecuteAndCheck added in v3.8.0

func (pool *SessionPool) ExecuteAndCheck(q string) (*ResultSet, error)

func (*SessionPool) ExecuteJson added in v3.3.0

func (pool *SessionPool) ExecuteJson(stmt string) ([]byte, error)

ExecuteJson returns the result of the given query as a json string Date and Datetime will be returned in UTC

JSON struct:

{
    "results":[
        {
            "columns":[
            ],
            "data":[
                {
                    "row":[
                        "row-data"
                    ],
                    "meta":[
                        "metadata"
                    ]
                }
            ],
            "latencyInUs":0,
            "spaceName":"",
            "planDesc ":{
                "planNodeDescs":[
                    {
                        "name":"",
                        "id":0,
                        "outputVar":"",
                        "description":{
                            "key":""
                        },
                        "profiles":[
                            {
                                "rows":1,
                                "execDurationInUs":0,
                                "totalDurationInUs":0,
                                "otherStats":{}
                            }
                        ],
                        "branchInfo":{
                            "isDoBranch":false,
                            "conditionNodeId":-1
                        },
                        "dependencies":[]
                    }
                ],
                "nodeIndexMap":{},
                "format":"",
                "optimize_time_in_us":0
            },
            "comment ":""
        }
    ],
    "errors":[
        {
      		"code": 0,
      		"message": ""
        }
    ]
}

func (*SessionPool) ExecuteJsonWithParameter added in v3.3.0

func (pool *SessionPool) ExecuteJsonWithParameter(stmt string, params map[string]interface{}) ([]byte, error)

ExecuteJson returns the result of the given query as a json string Date and Datetime will be returned in UTC The result is a JSON string in the same format as ExecuteJson() TODO(Aiee) check the space name

func (*SessionPool) ExecuteWithParameter added in v3.3.0

func (pool *SessionPool) ExecuteWithParameter(stmt string, params map[string]interface{}) (*ResultSet, error)

ExecuteWithParameter returns the result of the given query as a ResultSet

func (*SessionPool) GetEdgeTTL added in v3.8.0

func (pool *SessionPool) GetEdgeTTL(edgeName string) (string, uint, error)

func (*SessionPool) GetTagTTL added in v3.8.0

func (pool *SessionPool) GetTagTTL(tagName string) (string, uint, error)

func (*SessionPool) GetTotalSessionCount added in v3.3.0

func (pool *SessionPool) GetTotalSessionCount() int

GetTotalSessionCount returns the total number of sessions in the pool

func (*SessionPool) ShowEdges added in v3.8.0

func (pool *SessionPool) ShowEdges() ([]LabelName, error)

func (*SessionPool) ShowSpaces added in v3.8.0

func (pool *SessionPool) ShowSpaces() ([]SpaceName, error)

func (*SessionPool) ShowTags added in v3.8.0

func (pool *SessionPool) ShowTags() ([]LabelName, error)

type SessionPoolConf added in v3.3.0

type SessionPoolConf struct {
	// contains filtered or unexported fields
}

SessionPoolConf is the configs of a session pool Note that the space name is bound to the session pool for its lifetime

func NewSessionPoolConf added in v3.3.0

func NewSessionPoolConf(
	username, password string,
	serviceAddrs []HostAddress,
	spaceName string, opts ...SessionPoolConfOption) (*SessionPoolConf, error)

NewSessionPoolConfOpt creates a new NewSessionPoolConf with the provided options

type SessionPoolConfOption added in v3.3.0

type SessionPoolConfOption func(*SessionPoolConf)

func WithHTTP2 added in v3.6.0

func WithHTTP2(useHTTP2 bool) SessionPoolConfOption

func WithHandshakeKey added in v3.7.0

func WithHandshakeKey(handshakeKey string) SessionPoolConfOption

func WithHttpHeader added in v3.6.1

func WithHttpHeader(header http.Header) SessionPoolConfOption

func WithIdleTime added in v3.3.0

func WithIdleTime(idleTime time.Duration) SessionPoolConfOption

func WithMaxSize added in v3.3.0

func WithMaxSize(maxSize int) SessionPoolConfOption

func WithMinSize added in v3.3.0

func WithMinSize(minSize int) SessionPoolConfOption

func WithSSLConfig added in v3.3.0

func WithSSLConfig(sslConfig *tls.Config) SessionPoolConfOption

func WithTimeOut added in v3.3.0

func WithTimeOut(timeOut time.Duration) SessionPoolConfOption

type SpaceConf added in v3.8.0

type SpaceConf struct {
	Name           string
	Partition      uint
	Replica        uint
	VidType        string
	IgnoreIfExists bool
	Comment        string
}

type SpaceName added in v3.8.0

type SpaceName struct {
	Name string `nebula:"Name"`
}

type TimeWrapper

type TimeWrapper struct {
	// contains filtered or unexported fields
}

func (TimeWrapper) IsEqualTo

func (t1 TimeWrapper) IsEqualTo(t2 TimeWrapper) bool

type ValueWrapper

type ValueWrapper struct {
	// contains filtered or unexported fields
}

func (ValueWrapper) AsBool

func (valWrap ValueWrapper) AsBool() (bool, error)

AsBool converts the ValueWrapper to a boolean value

func (ValueWrapper) AsDate

func (valWrap ValueWrapper) AsDate() (*nebula.Date, error)

AsDate converts the ValueWrapper to a nebula.Date

func (ValueWrapper) AsDateTime

func (valWrap ValueWrapper) AsDateTime() (*DateTimeWrapper, error)

AsDateTime converts the ValueWrapper to a DateTimeWrapper

func (ValueWrapper) AsDedupList

func (valWrap ValueWrapper) AsDedupList() ([]ValueWrapper, error)

AsDedupList converts the ValueWrapper to a slice of ValueWrapper that has unique elements

func (ValueWrapper) AsDuration

func (valWrap ValueWrapper) AsDuration() (*nebula.Duration, error)

AsDuration converts the ValueWrapper to a DurationWrapper

func (ValueWrapper) AsFloat

func (valWrap ValueWrapper) AsFloat() (float64, error)

AsFloat converts the ValueWrapper to a float64

func (ValueWrapper) AsGeography

func (valWrap ValueWrapper) AsGeography() (*nebula.Geography, error)

AsPath converts the ValueWrapper to a nebula.Geography

func (ValueWrapper) AsInt

func (valWrap ValueWrapper) AsInt() (int64, error)

AsInt converts the ValueWrapper to an int64

func (ValueWrapper) AsList

func (valWrap ValueWrapper) AsList() ([]ValueWrapper, error)

AsList converts the ValueWrapper to a slice of ValueWrapper

func (ValueWrapper) AsMap

func (valWrap ValueWrapper) AsMap() (map[string]ValueWrapper, error)

AsMap converts the ValueWrapper to a map of string and ValueWrapper

func (ValueWrapper) AsNode

func (valWrap ValueWrapper) AsNode() (*Node, error)

AsNode converts the ValueWrapper to a Node

func (ValueWrapper) AsNull

func (valWrap ValueWrapper) AsNull() (nebula.NullType, error)

AsNull converts the ValueWrapper to nebula.NullType

func (ValueWrapper) AsPath

func (valWrap ValueWrapper) AsPath() (*PathWrapper, error)

AsPath converts the ValueWrapper to a PathWrapper

func (ValueWrapper) AsRelationship

func (valWrap ValueWrapper) AsRelationship() (*Relationship, error)

AsRelationship converts the ValueWrapper to a Relationship

func (ValueWrapper) AsString

func (valWrap ValueWrapper) AsString() (string, error)

AsString converts the ValueWrapper to a String

func (ValueWrapper) AsTime

func (valWrap ValueWrapper) AsTime() (*TimeWrapper, error)

AsTime converts the ValueWrapper to a TimeWrapper

func (ValueWrapper) GetType

func (valWrap ValueWrapper) GetType() string

GetType returns the value type of value in the valWrap as a string

func (ValueWrapper) IsBool

func (valWrap ValueWrapper) IsBool() bool

func (ValueWrapper) IsDate

func (valWrap ValueWrapper) IsDate() bool

func (ValueWrapper) IsDateTime

func (valWrap ValueWrapper) IsDateTime() bool

func (ValueWrapper) IsDuration

func (valWrap ValueWrapper) IsDuration() bool

func (ValueWrapper) IsEdge

func (valWrap ValueWrapper) IsEdge() bool

func (ValueWrapper) IsEmpty

func (valWrap ValueWrapper) IsEmpty() bool

func (ValueWrapper) IsFloat

func (valWrap ValueWrapper) IsFloat() bool

func (ValueWrapper) IsGeography

func (valWrap ValueWrapper) IsGeography() bool

func (ValueWrapper) IsInt

func (valWrap ValueWrapper) IsInt() bool

func (ValueWrapper) IsList

func (valWrap ValueWrapper) IsList() bool

func (ValueWrapper) IsMap

func (valWrap ValueWrapper) IsMap() bool

func (ValueWrapper) IsNull

func (valWrap ValueWrapper) IsNull() bool

func (ValueWrapper) IsPath

func (valWrap ValueWrapper) IsPath() bool

func (ValueWrapper) IsSet

func (valWrap ValueWrapper) IsSet() bool

func (ValueWrapper) IsString

func (valWrap ValueWrapper) IsString() bool

func (ValueWrapper) IsTime

func (valWrap ValueWrapper) IsTime() bool

func (ValueWrapper) IsVertex

func (valWrap ValueWrapper) IsVertex() bool

func (ValueWrapper) String

func (valWrap ValueWrapper) String() string

String() returns the value in the ValueWrapper as a string.

Maps in the output will be sorted by key value in alphabetical order.

For vertex, the output is in form (vid: tagName{propKey: propVal, propKey2, propVal2}),
For edge, the output is in form (SrcVid)-[name]->(DstVid)@Ranking{prop1: val1, prop2: val2}
where arrow direction depends on edgeType.
For path, the output is in form (v1)-[name@edgeRanking]->(v2)-[name@edgeRanking]->(v3)

For time, and dateTime, String returns the value calculated using the timezone offset from graph service by default.

Jump to

Keyboard shortcuts

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