Skip to content

Commit

Permalink
Merge branch 'apache:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyuT authored Dec 11, 2023
2 parents 9953fee + 8133144 commit f746d37
Show file tree
Hide file tree
Showing 45 changed files with 4,238 additions and 25 deletions.
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/[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
2 changes: 0 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ name: "CodeQL"

on:
workflow_dispatch:
push:
branches: [ master, release-* ]
pull_request:
# The branches below must be a subset of the branches above
# branches: [ master ] # enable in all PR
Expand Down
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:
$(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
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

0 comments on commit f746d37

Please sign in to comment.