UltipaDocs
Try Playground
  • Introduction
  • RESTful API
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
    • Installation
    • Connection
      • Request Configuration
      • Querying Methods
      • UQL Execution
      • Graphset Management
      • Schema and Property Management
      • Data Insertion and Deletion
      • Query Acceleration
      • Algorithm Management
      • Downloads and Exports
      • Process and Task Management
      • Access Management
      • Others
    • Result Processing
    • Types Mapping
  1. Docs
  2. /
  3. Ultipa Drivers
  4. /
  5. Go

Connection

After installing the Ultipa Go SDK and setting up a running Ultipa instance, you should be able to connect your application to the Ultipa graph database.

Code Configuration Connection

Connect to a Cluster

Go
func TestMisc(t *testing.T) {
  config := configuration.NewUltipaConfig(&configuration.UltipaConfig{
    Hosts: []string{"192.168.1.85:60061", "192.168.1.86:60061", "192.168.1.87:60061"},
    Username: "***",
    Password: "***",
  })

  conn, _ := sdk.NewUltipa(config)

  testResult, _ := conn.Test()
  println(testResult)
}

Connect to Ultipa Cloud

Go
func GetClient1(hosts []string, graphName string) (*api.UltipaAPI, error) {
   var err error
   config, _ := configuration.NewUltipaConfig(&configuration.UltipaConfig{
      Hosts:        []string{"xaznryn5s.us-east-1.cloud.ultipa.com:60010"},
      Username:     "***",
      Password:     "***",
      DefaultGraph: "Sample_Graphset",
      Debug:        true,
   })
   client, err = sdk.NewUltipa(config)
   if err != nil {
      log.Fatalln(err)
   }
   return client, err
}

Configuration Items

Below are all the configuration items available for UltipaConfig:

Item
Type
Default
Description
Hosts[]stringDatabase host addresses or URI (excluding https:// or http://). For clusters, multiple addresses are separated by commas. Required.
UsernamestringUsername of the host authentication. Required.
PasswordstringPassword of the host authentication. Required.
PasswordEncryptstringMD5Password encryption method of the driver. Supports MD5, LDAP and NOTHING. NOTHING is used when the content is blank.
DefaultGraphstringName of the graph in the database to use by default.
Crt[]byteCertificate file for encrypted messages.
MaxRecvSizeint10MBMaximum size in megabytes when receiving data.
ConsistencyboolFALSEWhether to use the leader node to ensure consistency read.
CurrentGraphstringdefaultName of the current graphset.
CurrentClusterIdstringCluster ID of the nameserver.
Timeoutint321000Request timeout threshold in seconds.
DebugboolFALSEWhether to use the debug mode.
HeartBeatint0Heartbeat interval in milliseconds for all instances, set 0 to disable heartbeat.

YAML Configuration File

A YAML configuration file stores the necessary server information for connecting to the Ultipa graph database.

Variable in YAMLItem in UltipaConfig
hostsHosts
usernameUsername
passwordPassword
default_graphDefaultGraph
crtCrt
max_recv_sizeMaxRecvSize
consistencyConsistency
current_graphCurrentGraph
current_cluster_idCurrentClusterId
timeoutTimeout
debugDebug
heart_beatHeartBeat

A driver is created with the configurations specified using the YAML file. The YAML file should be placed under the path of current Go file.

Example of a YAML configuration file 'testConfig.yml':

YAML
hosts: 
  - "192.168.1.85:60061"
  - "192.168.1.86:60061"
  - "192.168.1.87:60061"
username: ***
password: ***
default_graph: amz
timeout:: 300
Go
func TestMisc(t *testing.T) {
  config, _ := configuration.LoadConfigFromYAML("./testConfig.yml")

  conn, _ := sdk.NewUltipa(config)
  testResult, _ := conn.Test()
  println(testResult)
}