Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(client): support go client for hugegraph #514

Merged
merged 38 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dddcc66
init go client
izliang Aug 27, 2023
6624859
go client ci
izliang Aug 27, 2023
2c68f82
Update client-go-ci.yml
izliang Aug 27, 2023
5789511
Update client-go-ci.yml
izliang Aug 27, 2023
3103dbe
fix client-go
izliang Oct 16, 2023
a537d72
set License Header
izliang Oct 16, 2023
09cc5c4
fix package name
izliang Oct 16, 2023
6d0a547
add ignore license header
izliang Oct 16, 2023
99891c6
fix RAT check & markdown format
imbajin Oct 17, 2023
a034043
set license header
izliang Oct 17, 2023
06ed677
fix api
izliang Oct 23, 2023
d431311
fix api
izliang Oct 23, 2023
2bf495b
chore: replace all tab to 4 space
imbajin Oct 23, 2023
94e5d98
Update client-go-ci.yml
izliang Oct 23, 2023
2ab0e45
Update client-go-ci.yml
izliang Oct 24, 2023
580c755
fix makefile
izliang Oct 25, 2023
b0324dc
Merge branch 'master' into pr/514
imbajin Oct 30, 2023
df4f0e7
fix package name
izliang Oct 30, 2023
7888ca9
add Gremlin post API
izliang Oct 31, 2023
0b454f5
add property apis
izliang Nov 1, 2023
cc1d465
add apis
izliang Nov 1, 2023
5513534
add vertexlabel apis
izliang Nov 1, 2023
d58bc58
fix file header
izliang Nov 2, 2023
bb5a703
set username & password
izliang Nov 2, 2023
f3e71a2
vertex API init
izliang Nov 10, 2023
0dfaedb
new API format
izliang Nov 16, 2023
a407393
API format
izliang Nov 17, 2023
fd2e747
fix API
izliang Nov 17, 2023
9495bc5
ADD API
izliang Nov 21, 2023
733333e
Fix Header
izliang Nov 22, 2023
f417238
set new CommitId
izliang Dec 4, 2023
47bee4c
Update client-go-ci.yml
izliang Dec 4, 2023
0c6a996
Update client-go-ci.yml
izliang Dec 4, 2023
74b76b6
Merge branch 'master' into pr/514
imbajin Dec 5, 2023
3c39403
Merge branch 'master' into feature-go-client
imbajin Dec 5, 2023
04469a0
Fix API
izliang Dec 10, 2023
e2050cc
Merge branch 'master' into pr/514
imbajin Dec 11, 2023
22b9c3d
tiny fix
imbajin Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/client-ci.yml
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:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/client-go-ci.yml
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/setup-go@v2.1.3
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
2 changes: 1 addition & 1 deletion .github/workflows/hubble-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "hugegraph-hubble-ci"
name: "hubble-ci"

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/loader-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "hugegraph-loader-ci"
name: "loader-ci"

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spark-connector-ci.yml
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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
pull-requests: write

steps:
- uses: actions/stale@v3
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Due to the lack of activity, the current issue is marked as stale and will be closed after 20 days, any update will remove the stale label'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tools-ci.yml
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:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ tree.txt

# system ignore
Thumbs.db

# client-go
go.env
3 changes: 3 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ header: # `header` section is configurations for source codes license header.
- 'assembly/**'
- '.github/**/*'
- '**/target/*'
- 'hugegraph-client-go/go.mod'
- 'hugegraph-client-go/go.sum'
- 'hugegraph-client-go/Makefile'
- 'hugegraph-client/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker'
# - 'hugegraph-hubble/hubble-fe/**'
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
Expand Down
72 changes: 72 additions & 0 deletions hugegraph-client-go/Makefile
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:
izliang marked this conversation as resolved.
Show resolved Hide resolved
$(GO) env -w GO111MODULE=on


#make prepare, download dependencies
prepare: gomod

gomod: set-env
izliang marked this conversation as resolved.
Show resolved Hide resolved
izliang marked this conversation as resolved.
Show resolved Hide resolved
$(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
izliang marked this conversation as resolved.
Show resolved Hide resolved
96 changes: 96 additions & 0 deletions hugegraph-client-go/README.en.md
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'`
}
```
94 changes: 94 additions & 0 deletions hugegraph-client-go/README.md
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'`
}
```
Loading
Loading