Skip to content

Commit

Permalink
update structure of client support for v2 transactions, and access in…
Browse files Browse the repository at this point in the history
…terface for transaction results (#37)

* update structure of client support for v2 transactions, and access interface for transaction results.

* update go version in github action.

* hide concrete column implementations, all access through column interface, plus misc cleanups and minor improvements to examples.

* fix constant values in relation signatures and update tests.
  • Loading branch information
bradlo authored Oct 20, 2022
1 parent ebe80bb commit d7f9c9f
Show file tree
Hide file tree
Showing 54 changed files with 5,816 additions and 841 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18

- name: Build
run: go build -v ./rai
Expand Down
25 changes: 17 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
# Changelog

## v0.4.0-alpha

* Complete overhaul of transaction response handling and results access API.

## v0.3.1-alpha

* Fix v2 show result if empty result.

## v0.3.0-alpha

* Deprecated metadata json format.
* Removed `TransactionAsyncMetadataResponse` model.
* Added support to metadata protobuf format.
* `GetTransactionMetadata` returns protobuf metadata.
* Added `v2` show result functionality.

## v0.2.1

* Renamed:
- `Execute` to `ExecuteV1`.
- `ExecuteAsyncWait` to `Execute`.
* `Execute` to `ExecuteV1`.
* `ExecuteAsyncWait` to `Execute`.

## v0.2.0

* Added `CancelTransaction` feature.

## v0.1.1

* Added v2 predefined results formats:
- `GetTransactions` returns `TransactionsAsyncMultipleResponses`.
- `GetTransaction` returns `TransactionAsyncSingleResponse`.
- `GetTransactionResults` returns `[]ArrowRelation`.
- `GetTransactionMetadata` returns `[]TransactionAsyncMetadataResponse`.
- `GetTransactionProblems` returns `[](ClientProblem|IntegrityConstraintViolation)`.
- `ExecuteAsync` returns `TransactionAsyncResult`.
* `GetTransactions` returns `TransactionsAsyncMultipleResponses`.
* `GetTransaction` returns `TransactionAsyncSingleResponse`.
* `GetTransactionResults` returns `[]ArrowRelation`.
* `GetTransactionMetadata` returns `[]TransactionAsyncMetadataResponse`.
* `GetTransactionProblems` returns `[](ClientProblem|IntegrityConstraintViolation)`.
* `ExecuteAsync` returns `TransactionAsyncResult`.

* `Problem` model is changed to `ClientProblem` and `IntegrityConstraintViolation`
problem type is introduced.
Expand All @@ -37,4 +45,5 @@ problem type is introduced.
is a simplification and *breaking change* to the signatures of both functions.

## v0.1.0-alpha

* Initial release
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ The RelationalAI Software Development Kit for Go enables developers to access th

### Requirements

* Go 1.17+

The SDK has been tested on golang version 1.17+, but likely works with earlier versions.
* Go 1.18+

### Building the SDK

Expand All @@ -29,9 +27,8 @@ The SDK has been tested on golang version 1.17+, but likely works with earlier v

**Run the tests**

cd ./rai
go test

./run-tests

Note, the test are run against the account configured in your SDK config file.

### Create a configuration file
Expand All @@ -58,11 +55,9 @@ You can copy `config.spec` from the root of this repo and modify as needed.

## Generate golang sources from protobuf specification

```shell
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
export PATH=$PATH:$HOME/go/bin
protoc -I protos --go_out=. --go_opt=Mschema.proto=./rai/pb --go_opt=Mmessage.proto=./rai/pb protos/*.proto
```
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
export PATH=$PATH:$HOME/go/bin
protoc -I protos --go_out=. --go_opt=Mschema.proto=./rai/pb --go_opt=Mmessage.proto=./rai/pb protos/*.proto

## Examples

Expand All @@ -71,8 +66,8 @@ are located in `./examples` folder.

Each example can be run using the `go` command.

cd ./examples
go run get_database/main.go -d sdk-test
cd ./examples
go run get_database/main.go -d sdk-test

There is also a bash script in `./examples` that can be used to run
individual examples.
Expand All @@ -93,4 +88,4 @@ to submit an issue or a PR here.

The RelationalAI Software Development Kit for Go is licensed under the
Apache License 2.0. See:
https://github.com/RelationalAI/rai-sdk-go/blob/master/LICENSE
https://github.com/RelationalAI/rai-sdk-go/blob/master/LICENSE
2 changes: 1 addition & 1 deletion examples/cancel_transaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/clone_database/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/create_database/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/create_engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/create_oauth_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/create_user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/delete_model/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/delete_oauth_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/delete_user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/disable_user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/enable_user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions examples/execute/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getCode(opts *Options) (string, error) {
}
bytes, err := ioutil.ReadFile(opts.File)
if err != nil {
return "", nil
return "", err
}
return string(bytes), nil
}
Expand All @@ -56,7 +56,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rsp.Show()
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions examples/execute_async/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getCode(opts *Options) (string, error) {
}
bytes, err := ioutil.ReadFile(opts.File)
if err != nil {
return "", nil
return "", err
}
return string(bytes), nil
}
Expand All @@ -56,7 +56,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rsp.Show()
return nil
}

Expand Down
72 changes: 0 additions & 72 deletions examples/execute_v1/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion examples/find_oauth_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/find_user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/get_database/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/get_engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/get_model/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/get_oauth_client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/get_transaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion examples/get_transaction_metadata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func run(opts *Options) error {
if err != nil {
return err
}
rai.Print(rsp, 4)
rai.ShowJSON(rsp, 4)
return nil
}

Expand Down
Loading

0 comments on commit d7f9c9f

Please sign in to comment.