forked from apache/incubator-hugegraph-toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'apache:master' into master
- Loading branch information
Showing
45 changed files
with
4,238 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "hugegraph-client-ci" | ||
name: "java-client-ci" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: "go-client-ci" | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- /^release-.*$/ | ||
paths: | ||
- hugegraph-client-go/** | ||
- hugegraph-dist/** | ||
- .github/workflows/** | ||
- pom.xml | ||
pull_request: | ||
paths: | ||
- hugegraph-client-go/** | ||
- hugegraph-dist/** | ||
- .github/workflows/** | ||
- pom.xml | ||
|
||
jobs: | ||
client-go-ci: | ||
runs-on: ubuntu-latest | ||
env: | ||
TRAVIS_DIR: hugegraph-client/assembly/travis | ||
COMMIT_ID: be6ee386b9939dc6bd6fcbdf2274b8acc3a0a314 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
JAVA_VERSION: ['11'] | ||
steps: | ||
- name: Install JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ matrix.JAVA_VERSION }} | ||
distribution: 'zulu' | ||
|
||
- name: Cache Maven packages | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Prepare env and service | ||
run: | | ||
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID | ||
- name: Init Go env | ||
uses: actions/[email protected] | ||
with: { go-version: '1.x' } | ||
|
||
- name: Go test | ||
run: | | ||
go version | ||
sudo swapoff -a | ||
sudo sysctl -w vm.swappiness=1 | ||
sudo sysctl -w fs.file-max=262144 | ||
sudo sysctl -w vm.max_map_count=262144 | ||
cd hugegraph-client-go && make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "hugegraph-hubble-ci" | ||
name: "hubble-ci" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "hugegraph-loader-ci" | ||
name: "loader-ci" | ||
|
||
on: | ||
workflow_dispatch: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "hugegraph-spark-connector-ci" | ||
name: "spark-connector-ci" | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "hugegraph-tools-ci" | ||
name: "tools-ci" | ||
on: | ||
workflow_dispatch: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,3 +95,6 @@ tree.txt | |
|
||
# system ignore | ||
Thumbs.db | ||
|
||
# client-go | ||
go.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# init project path | ||
HOMEDIR := $(shell pwd) | ||
OUTDIR := $(HOMEDIR)/output | ||
|
||
# Get the go environment required for compilation | ||
export GOENV = $(HOMEDIR)/go.env | ||
|
||
GO := GO111MODULE=on go | ||
GOPATH := $(shell $(GO) env GOPATH) | ||
GOMOD := $(GO) mod | ||
GOBUILD := $(GO) build | ||
GOTEST := $(GO) test -race -timeout 30s -gcflags="-N -l" | ||
GOPKGS := $$($(GO) list ./...| grep -vE "vendor") | ||
|
||
# test cover files | ||
COVPROF := $(HOMEDIR)/covprof.out # coverage profile | ||
COVFUNC := $(HOMEDIR)/covfunc.txt # coverage profile information for each function | ||
COVHTML := $(HOMEDIR)/covhtml.html # HTML representation of coverage profile | ||
|
||
# make, make all | ||
all: prepare compile package | ||
|
||
set-env: | ||
$(GO) env -w GO111MODULE=on | ||
|
||
|
||
#make prepare, download dependencies | ||
prepare: gomod | ||
|
||
gomod: set-env | ||
$(GOMOD) download | ||
|
||
#make compile | ||
compile: build | ||
|
||
build: | ||
$(GOBUILD) -o $(HOMEDIR)/hugegraph-client-go | ||
# make test, test your code | ||
test: prepare test-case | ||
test-case: | ||
$(GOTEST) -v -cover $(GOPKGS) | ||
|
||
# make package | ||
package: package-bin | ||
package-bin: | ||
rm -rf $(OUTDIR) | ||
mkdir -p $(OUTDIR) | ||
mv hugegraph-client-go $(OUTDIR)/ | ||
# make clean | ||
clean: | ||
$(GO) clean | ||
rm -rf $(OUTDIR) | ||
rm -rf $(GOPATH)/pkg/darwin_amd64 | ||
# avoid filename conflict and speed up build | ||
.PHONY: all prepare compile test package clean build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# go-hugegraph | ||
|
||
#### Introduction | ||
|
||
HugeGraph client SDK tool based on Go language | ||
|
||
#### Software Architecture | ||
|
||
Software Architecture Description | ||
|
||
#### Installation Tutorial | ||
|
||
```Shell | ||
|
||
Go get github. com/go huggraph | ||
|
||
``` | ||
|
||
#### Implement API | ||
|
||
| API | illustrate | | ||
|---------|-------------------------| | ||
| schema | Obtain the model schema | | ||
| version | Get version information | | ||
|
||
#### Instructions for use | ||
|
||
##### 1. Initialize the client | ||
|
||
```Go | ||
package main | ||
|
||
import "github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go" | ||
import "github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go/hgtransport" | ||
|
||
func main() { | ||
|
||
clinet, err := hugegraph.NewCommonClient(hugegraph.Config{ | ||
Host: "127.0.0.1", | ||
Port: 8080, | ||
Graph: "hugegraph", | ||
Username: "", | ||
Password: "", | ||
Logger: &hgtransport.ColorLogger{ | ||
Output: os.Stdout, | ||
EnableRequestBody: true, | ||
EnableResponseBody: true, | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("Error creating the client: %s\n", err) | ||
} | ||
} | ||
``` | ||
|
||
##### 2. Obtain the hugegraph version | ||
|
||
-1. Use the SDK to obtain version information | ||
|
||
```Go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
) | ||
|
||
func getVersion() { | ||
|
||
client := initClient() | ||
res, err := client.Version() | ||
if err != nil { | ||
log.Fatalf("Error getting the response: %s\n", err) | ||
} | ||
defer res.Body.Close() | ||
|
||
fmt.Println(res.Versions) | ||
fmt.Println(res.Versions.Version) | ||
} | ||
``` | ||
|
||
-2. Result Set Response Body | ||
|
||
```Go | ||
package main | ||
|
||
type VersionResponse struct { | ||
Versions struct { | ||
Version string `json:"version"` // hugegraph version | ||
Core string `json:"core"` // hugegraph core version | ||
Gremlin string `json:"gremlin"` // hugegraph gremlin version | ||
API string `json:"api"` // hugegraph api version | ||
} ` json: 'versions'` | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# go-hugegraph | ||
|
||
#### 介绍 | ||
|
||
基于 Go 语言的 HugeGraph Client SDK 工具 | ||
|
||
#### 软件架构 | ||
|
||
软件架构说明 | ||
|
||
#### 安装教程 | ||
|
||
```shell | ||
go get github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go | ||
``` | ||
|
||
#### 实现 API | ||
|
||
| API | 说明 | | ||
|---------|-------------| | ||
| schema | 获取模型 schema | | ||
| version | 获取版本信息 | | ||
|
||
#### 使用说明 | ||
|
||
##### 1.初始化客户端 | ||
|
||
```go | ||
package main | ||
|
||
import "github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go" | ||
import "github.com/apache/incubator-hugegraph-toolchain/hugegraph-client-go/hgtransport" | ||
|
||
func main() { | ||
|
||
clinet, err := hugegraph.NewCommonClient(hugegraph.Config{ | ||
Host: "127.0.0.1", | ||
Port: 8080, | ||
Graph: "hugegraph", | ||
Username: "", | ||
Password: "", | ||
Logger: &hgtransport.ColorLogger{ | ||
Output: os.Stdout, | ||
EnableRequestBody: true, | ||
EnableResponseBody: true, | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("Error creating the client: %s\n", err) | ||
} | ||
} | ||
``` | ||
|
||
##### 2.获取 hugegraph 版本 | ||
|
||
- 1.使用 SDK 获取版本信息 | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
) | ||
|
||
func getVersion() { | ||
|
||
client := initClient() | ||
res, err := client.Version() | ||
if err != nil { | ||
log.Fatalf("Error getting the response: %s\n", err) | ||
} | ||
defer res.Body.Close() | ||
|
||
fmt.Println(res.Versions) | ||
fmt.Println(res.Versions.Version) | ||
} | ||
``` | ||
|
||
- 2.返回值的结构 | ||
|
||
```go | ||
package main | ||
|
||
type VersionResponse struct { | ||
Versions struct { | ||
Version string `json:"version"` // hugegraph version | ||
Core string `json:"core"` // hugegraph core version | ||
Gremlin string `json:"gremlin"` // hugegraph gremlin version | ||
API string `json:"api"` // hugegraph api version | ||
} ` json: 'versions'` | ||
} | ||
``` |
Oops, something went wrong.