Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
am-kinetica committed Apr 3, 2024
2 parents cae40f3 + 86b7b8a commit 8255aa2
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 148 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
# Kinetica Go API Changelog


## Version 7.2

### Version 7.2.0.1 - 2024-03-27

- Upgraded `golang.org/x/net` library from v0.9.0 to v0.22.0
- Added runnable example to `examples.go`


### Version 7.2.0.0 - 2024-02-11

- Initial 7.2 release



## Version 7.1

### Version 7.1.9.1 - 2024-03-27

- Upgraded `golang.org/x/net` library from v0.9.0 to v0.22.0
- Added runnable example to `examples.go`


### Version 7.1.9.0 - 2023-08-12

- Initial release, with the following endpoint calls:
Expand Down
275 changes: 140 additions & 135 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,135 +1,140 @@
<h3 align="center" style="margin:0px">
<img width="200" src="https://www.kinetica.com/wp-content/uploads/2018/08/kinetica_logo.svg" alt="Kinetica Logo"/>
</h3>
<h5 align="center" style="margin:0px">
<a href="https://www.kinetica.com/">Website</a>
|
<a href="https://docs.kinetica.com/7.1/">Docs</a>
|
<a href="https://join.slack.com/t/kinetica-community/shared_invite/zt-1bt9x3mvr-uMKrXlSDXfy3oU~sKi84qg">Community Slack</a>
</h5>

# Kinetica GOLANG API

- [Overview](#overview)
- [Support](#support)
- [Contact Us](#contact-us)

## Overview

This project contains the source code of the Golang Kinetica API.

The documentation can be found at <https://docs.kinetica.com/7.1/>.

### Usage

For using this API in a `GO` project add the lines

```GO
require (
github.com/kineticadb/gpudb-api-go v0.0.1
)
```

to the `go.mod` file of your project.

For changes to the client-side API, please refer to
[CHANGELOG.md](CHANGELOG.md).

### Starter example

```GO

package main

import (
"context"
"fmt"
"os"
"sync"
"time"

"github.com/kineticadb/gpudb-api-go/example"
"github.com/kineticadb/gpudb-api-go/kinetica"
"go.uber.org/multierr"
"go.uber.org/zap"
)

func main() {
endpoint := os.Args[1]
username := os.Args[2]
password := os.Args[3]

ctx := context.TODO()
options := kinetica.KineticaOptions{Username: username, Password: password}
// fmt.Println("Options", options)
dbInst := kinetica.NewWithOptions(ctx, endpoint, &options)
}

```

### Logging

The logging is done using Uber zap package and `lumberjack` for rotating files based on size. Time based rotation is not supported yet. The configuration for `lumberjack` can be found here - <https://pkg.go.dev/gopkg.in/natefinch/lumberjack.v2>

#### Default Log Config file

This is included and will be used in case a user defined config file is not found. The name of the file is `log_config.yaml`.

```yaml
level: 'info'
development: true
disableCaller: false
disableStacktrace: false
encoding: 'console'
encoderConfig:
messageKey: 'msg'
levelKey: 'level'
timeKey: 'ts'
nameKey: 'logger'
callerKey: 'caller'
functionKey: 'function'
stacktraceKey: 'stacktrace'
skipLineEnding: false
lineEnding: "\n"
levelEncoder: 'capital'
timeEncoder: 'iso8601'
durationEncoder: 'string'
callerEncoder: 'full'
nameEncoder: 'full'
consoleSeparator: ' | '
outputPaths:
# Implements logging to the console
- 'stdout'
# Implements rolling logs using lumberjack logger; config parameters are supplied as
# query params. Here maxSize is 10MB after which the logger rolls over; maximum
# number of backups (maxBackups) kept is 5 and maxAge is 10 days.
# The name of the log file in this case is "logs/gpudb-api.log" where the
# "logs" directory is under the current directory on the local machine.
- 'lumberjack://localhost/logs/gpudb-api.log?maxSize=10&maxBackups=5&maxAge=10'
errorOutputPaths:
- 'stderr'
- './logs/error_logs'
initialFields:
app: 'gpudb-api'
```
## Support
For bugs, please submit an
[issue on Github](https://github.com/kineticadb/kinetica-api-go/issues).
For support, you can post on
[stackoverflow](https://stackoverflow.com/questions/tagged/kinetica) under the
``kinetica`` tag or
[Slack](https://join.slack.com/t/kinetica-community/shared_invite/zt-1bt9x3mvr-uMKrXlSDXfy3oU~sKi84qg).
## Contact Us
- Ask a question on Slack:
[Slack](https://join.slack.com/t/kinetica-community/shared_invite/zt-1bt9x3mvr-uMKrXlSDXfy3oU~sKi84qg)
- Follow on GitHub:
[Follow @kineticadb](https://github.com/kineticadb)
- Email us: <[email protected]>
- Visit: <https://www.kinetica.com/contact/>
<h3 align="center" style="margin:0px">
<img width="200" src="https://www.kinetica.com/wp-content/uploads/2018/08/kinetica_logo.svg" alt="Kinetica Logo"/>
</h3>
<h5 align="center" style="margin:0px">
<a href="https://www.kinetica.com/">Website</a>
|
<a href="https://docs.kinetica.com/7.2/">Docs</a>
|
<a href="https://join.slack.com/t/kinetica-community/shared_invite/zt-1bt9x3mvr-uMKrXlSDXfy3oU~sKi84qg">Community Slack</a>
</h5>


# Kinetica GOLANG API

- [Overview](#overview)
- [Support](#support)
- [Contact Us](#contact-us)


## Overview

This project contains the source code of the Golang Kinetica API.

The documentation can be found at <https://docs.kinetica.com/7.2/>.

### Usage

For using this API in a `GO` project add the lines

```GO
require (
github.com/kineticadb/gpudb-api-go v0.0.4
)
```

to the `go.mod` file of your project.

For changes to the client-side API, please refer to
[CHANGELOG.md](CHANGELOG.md).

### Starter example

```GO

package main

import (
"context"
"fmt"
"os"
"sync"
"time"

"github.com/kineticadb/gpudb-api-go/example"
"github.com/kineticadb/gpudb-api-go/kinetica"
"go.uber.org/multierr"
"go.uber.org/zap"
)

func main() {
endpoint := os.Args[1]
username := os.Args[2]
password := os.Args[3]

ctx := context.TODO()
options := kinetica.KineticaOptions{Username: username, Password: password}
dbInst := kinetica.NewWithOptions(ctx, endpoint, &options)
}

```

### Logging

The logging is done using Uber zap package and `lumberjack` for rotating files
based on size. Time based rotation is not supported yet. The configuration for
`lumberjack` can be found here -
<https://pkg.go.dev/gopkg.in/natefinch/lumberjack.v2>

#### Default Log Config file

This is included and will be used in case a user defined config file is not
found. The name of the file is `log_config.yaml`.

```yaml
level: 'info'
development: true
disableCaller: false
disableStacktrace: false
encoding: 'console'
encoderConfig:
messageKey: 'msg'
levelKey: 'level'
timeKey: 'ts'
nameKey: 'logger'
callerKey: 'caller'
functionKey: 'function'
stacktraceKey: 'stacktrace'
skipLineEnding: false
lineEnding: "\n"
levelEncoder: 'capital'
timeEncoder: 'iso8601'
durationEncoder: 'string'
callerEncoder: 'full'
nameEncoder: 'full'
consoleSeparator: ' | '
outputPaths:
# Implements logging to the console
- 'stdout'
# Implements rolling logs using lumberjack logger; config parameters are supplied as
# query params. Here maxSize is 10MB after which the logger rolls over; maximum
# number of backups (maxBackups) kept is 5 and maxAge is 10 days.
# The name of the log file in this case is "logs/gpudb-api.log" where the
# "logs" directory is under the current directory on the local machine.
- 'lumberjack://localhost/logs/gpudb-api.log?maxSize=10&maxBackups=5&maxAge=10'
errorOutputPaths:
- 'stderr'
- './logs/error_logs'
initialFields:
app: 'gpudb-api'
```
## Support
For bugs, please submit an
[issue on Github](https://github.com/kineticadb/kinetica-api-go/issues).
For support, you can post on
[stackoverflow](https://stackoverflow.com/questions/tagged/kinetica) under the
``kinetica`` tag or
[Slack](https://join.slack.com/t/kinetica-community/shared_invite/zt-1bt9x3mvr-uMKrXlSDXfy3oU~sKi84qg).
## Contact Us
- Ask a question on Slack:
[Slack](https://join.slack.com/t/kinetica-community/shared_invite/zt-1bt9x3mvr-uMKrXlSDXfy3oU~sKi84qg)
- Follow on GitHub:
[Follow @kineticadb](https://github.com/kineticadb)
- Email us: <[email protected]>
- Visit: <https://www.kinetica.com/contact/>
28 changes: 25 additions & 3 deletions examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ var (
)

func main() {
endpoint := "https://172.17.0.2:8082/gpudb-0" //os.Args[1]
username := "admin" //os.Args[2]
password := "Kinetica1." //os.Args[3]
endpoint := os.Args[1]
username := os.Args[2]
password := os.Args[3]

// Logger, err := zap.NewProduction()
// if err != nil {
Expand All @@ -38,6 +38,7 @@ func main() {

fmt.Println(anyValue...)

runMain(dbInst)
// runShowExplainVerboseAnalyseSqlStatement(dbInst)
// runShowExplainVerboseSqlStatement(dbInst)
// runShowStoredProcedureDDL(dbInst)
Expand Down Expand Up @@ -84,6 +85,27 @@ func main() {

}

func runMain(dbInst *kinetica.Kinetica) {
start := time.Now()
result, err := dbInst.ExecuteSqlRaw(context.TODO(), "CREATE OR REPLACE TABLE go (id INT, name VARCHAR(64))", 0, 0, "", nil)
if err != nil {
panic(err)
}
fmt.Println("\nCREATE: ", *result)
result, err = dbInst.ExecuteSqlRaw(context.TODO(), "INSERT INTO go VALUES (1, 'Joe'), (2, 'Jane')", 0, 0, "", nil)
if err != nil {
panic(err)
}
fmt.Println("\nINSERT: ", *result)
records, grm_err := dbInst.ExecuteSqlRaw(context.TODO(), "SELECT * FROM go ORDER BY id", 0, 0, "", nil)
if grm_err != nil {
panic(grm_err)
}
duration := time.Since(start)
fmt.Printf("\nSELECT: %+v\n", *records)
fmt.Println("runMain", duration.Milliseconds(), " ms")
}

func runShowExplainVerboseAnalyseSqlStatement(dbInst *kinetica.Kinetica) {
start := time.Now()
// string field
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ require (
github.com/samber/lo v1.38.1
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.24.0
golang.org/x/net v0.9.0 // indirect
golang.org/x/net v0.22.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v2 v2.4.0

)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
Loading

0 comments on commit 8255aa2

Please sign in to comment.