Skip to content

Commit 0f44094

Browse files
authored
Support for Global Active Tables (#28)
* Added AddReplicaRequest, DropReplicaRequest, ReplicaStatsRequest * Added Replica information to TableResult * Added signing of body hash for specific requests. Also cleaned up a bunch of warnings, including ioutil being deprecated as of go 1.16.
1 parent f78fb2c commit 0f44094

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1161
-451
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
77

88
### Added
99
- Latest Oracle Cloud Infrastructure regions and region codes: TYO, ABH, DAC, DOH, IZQ
10+
- Cloud only: added support for Global Active Tables. This includes new requests and structs:
11+
- AddReplicaRequest
12+
- DropReplicaRequest
13+
- ReplicaStatsRequest/Result
14+
- ReplicaStats
15+
- Replica
16+
as well as additional replica-related information in TableResult
1017

1118
### Changed
1219
- Changed copyrights to 2024

README.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ and to [the Oracle NoSQL Cloud Simulator](https://www.oracle.com/downloads/cloud
1111
This project is open source and maintained by Oracle Corp.
1212

1313
## Prerequisites
14-
- Go 1.12 or later
15-
- Download a [Go](https://golang.org/dl/) 1.12+ binary release suitable for your system.
14+
- Go 1.16 or later
15+
- Download a [Go](https://golang.org/dl/) 1.16+ binary release suitable for your system.
1616
- Install on your system following the [installation instructions](https://golang.org/doc/install).
1717
- Go for Oracle Linux 7 can be installed via `yum`: [Go Packages for Oracle Linux](http://yum.oracle.com/oracle-linux-golang.html).
1818
- Add the directory that contains the `go` executable into your system PATH, for example:
@@ -37,15 +37,6 @@ recommended to use the Go modules to manage dependencies for your application.
3737
Run `go env GOPROXY` to check if the `GOPROXY` is set correctly for your environment,
3838
if not, run the commands:
3939

40-
* If using `go1.12`
41-
42-
```sh
43-
export GO111MODULE="on"
44-
export GOPROXY="https://proxy.golang.org"
45-
```
46-
47-
* If using `go1.13+`:
48-
4940
```go
5041
go env -w GO111MODULE=on
5142
go env -w GOPROXY="https://proxy.golang.org,direct"

doc/connect.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Database Go SDK. There are several supported environments:
77

88
## Prerequisites
99

10-
Th Go SDK requires:
11-
* Go 1.12 or later
10+
The Go SDK requires:
11+
* Go 1.16 or later
1212
* For the Oracle NoSQL Cloud Service
1313
- An Oracle Cloud Infrastructure account
1414
- A user created in that account, in a group with a policy that grants the desired permissions.
@@ -27,15 +27,6 @@ recommended to use the Go modules to manage dependencies for your application.
2727

2828
Run `go env GOPROXY` to check if the `GOPROXY` is set correctly for your environment, if not, run the commands:
2929

30-
* If using `go1.12`
31-
32-
```sh
33-
export GO111MODULE="on"
34-
export GOPROXY="https://proxy.golang.org"
35-
```
36-
37-
* If using `go1.13+`:
38-
3930
```go
4031
go env -w GO111MODULE=on
4132
go env -w GOPROXY="https://proxy.golang.org,direct"

internal/test/cloudsim_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "22.4.10",
2+
"version": "24.1.11-SNAPSHOT",
33
"tablePrefix": "Go",
44
"reCreateTables": true,
55
"verbose": true,

internal/test/config.go

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"errors"
1414
"flag"
1515
"fmt"
16-
"io/ioutil"
16+
"os"
1717
"strings"
1818
"time"
1919

@@ -61,7 +61,7 @@ func newConfig(configFile string) (*Config, error) {
6161
return nil, errors.New("config file not specified")
6262
}
6363

64-
data, err := ioutil.ReadFile(configFile)
64+
data, err := os.ReadFile(configFile)
6565
if err != nil {
6666
return nil, fmt.Errorf("failed to read config file %s: %v", configFile, err)
6767
}
@@ -106,8 +106,7 @@ func (cfg *Config) IsOnPremSecureStore() bool {
106106
// createConfig creates a test configuration object from the JSON file specified
107107
// on command line of the form:
108108
//
109-
// testConfig=<path to JSON file>
110-
//
109+
// testConfig=<path to JSON file>
111110
func createConfig() (cfg *Config, err error) {
112111
if !flag.Parsed() {
113112
flag.Parse()
@@ -173,20 +172,6 @@ func createClient(cfg *Config) (*nosqldb.Client, error) {
173172
return client, nil
174173
}
175174

176-
// getClient returns a NoSQL client used for testing.
177-
//
178-
// If there is a test client already created, the client is returned, otherwise
179-
// it creates a new client with the specified configuration.
180-
func getClient(cfg *Config) (*nosqldb.Client, error) {
181-
if client != nil {
182-
return client, nil
183-
}
184-
185-
var err error
186-
client, err = createClient(cfg)
187-
return client, err
188-
}
189-
190175
// Interceptor represents an interceptor that used to inject customized
191176
// procedures to setup NoSQL client, setup and teardown test resources.
192177
//
@@ -256,10 +241,6 @@ const (
256241
// MinReadKB represents the minimum read KB for a query operation
257242
MinReadKB = 1
258243

259-
// The default interval between two tests.
260-
// This is used to avoid throttling errors during testing.
261-
defaultTestInterval = 500 * time.Millisecond
262-
263244
// MaxDataSizeLimit represents the limit on data size for a row.
264245
// It is 512 KB.
265246
MaxDataSizeLimit = 512 * 1024

internal/test/onprem_config.json

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
{
2-
"version": "20.2.15",
3-
"tablePrefix": "Go",
4-
"reCreateTables": true,
5-
"dropTablesOnTearDown": true,
6-
"clientConfig": {
7-
"mode": "onprem",
8-
"endpoint": "https://localhost:8091",
9-
"username": "driver_user",
10-
"password": "RHJpdmVyVXNlcl9fMTIzNDU2",
11-
"httpConfig": {
12-
"certPath": "/path/to/server_certificate.pem",
13-
"serverName": "localhost"
14-
}
15-
}
16-
}
2+
"version": "24.1.11-SNAPSHOT",
3+
"tablePrefix": "Go",
4+
"reCreateTables": true,
5+
"dropTablesOnTearDown": true,
6+
"verbose": true,
7+
"serialVersion": 0,
8+
"clientConfig": {
9+
"endpoint": "http://localhost:8090",
10+
"mode": "onprem"
11+
}
12+
}

internal/test/test_util.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func valueEqual(v1, v2 interface{}) bool {
224224
}
225225

226226
if v2 == nil {
227-
return v1 == nil || v1 == types.JSONNullValueInstance ||
227+
return v1 == types.JSONNullValueInstance ||
228228
v1 == types.NullValueInstance || v1 == types.EmptyValueInstance
229229
}
230230

@@ -350,7 +350,7 @@ func VersionsEqual(v1, v2 types.Version) bool {
350350
return false
351351
}
352352
// Compare 0-6
353-
if bytes.Equal(arr1[:7], arr2[:7]) == false {
353+
if !bytes.Equal(arr1[:7], arr2[:7]) {
354354
return false
355355
}
356356
// Compare 8-end
@@ -454,11 +454,7 @@ func ratValueEqual(rat1, rat2 *big.Rat, fpArithSpec *nosqldb.FPArithSpec) bool {
454454

455455
// as last resort, compare the string representation.
456456
decimalPrec := int(fpArithSpec.Precision)
457-
if bf1.Text('G', decimalPrec) == bf2.Text('G', decimalPrec) {
458-
return true
459-
}
460-
461-
return false
457+
return bf1.Text('G', decimalPrec) == bf2.Text('G', decimalPrec)
462458
}
463459

464460
func timeValueEqual(t1 time.Time, v2 interface{}) bool {

nosqldb/aggr_iter.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,16 +482,15 @@ func (iter *funcMinMaxIter) displayContent(sb *strings.Builder, f *planFormatter
482482
// This function returns an error if either of the two values is non-atomic or
483483
// the values are not comparable. Otherwise, the returned res is:
484484
//
485-
// 0 if v1 == v2
486-
// 1 if v1 > v2
487-
// -1 if v1 < v2
485+
// 0 if v1 == v2
486+
// 1 if v1 > v2
487+
// -1 if v1 < v2
488488
//
489489
// Whether the two values are comparable depends on the "forSort" parameter.
490490
// If true, then values that would otherwise be considered non-comparable are
491491
// assumed to have the following order:
492492
//
493-
// NUMERICS < TIMESTAMP < STRING < BOOLEAN < EMPTY < JSON_NULL < NULL
494-
//
493+
// NUMERICS < TIMESTAMP < STRING < BOOLEAN < EMPTY < JSON_NULL < NULL
495494
func compareAtomicValues(rcb *runtimeControlBlock, forSort bool, v1, v2 types.FieldValue) (res int, err error) {
496495
if rcb != nil {
497496
rcb.trace(4, "compareAtomicValues() : comparing values %v and %v", v1, v2)
@@ -784,7 +783,7 @@ func compareBools(x, y bool) int {
784783
switch {
785784
case x == y:
786785
return 0
787-
case x == false:
786+
case !x:
788787
return -1
789788
default:
790789
return 1

nosqldb/auth/cloudsim/cloudsim.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"net/http"
1414

1515
"github.com/oracle/nosql-go-sdk/nosqldb/auth"
16+
"github.com/oracle/nosql-go-sdk/nosqldb/logger"
1617
)
1718

1819
// AccessTokenProvider implements the nosqldb.AuthorizationProvider interface.
@@ -46,3 +47,8 @@ func (p *AccessTokenProvider) Close() error {
4647
func (p *AccessTokenProvider) SignHTTPRequest(req *http.Request) error {
4748
return nil
4849
}
50+
51+
// GetLogger returns a logger to use.
52+
func (p *AccessTokenProvider) GetLogger() *logger.Logger {
53+
return nil
54+
}

nosqldb/auth/iam/configuration.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"crypto/rsa"
77
"errors"
88
"fmt"
9-
"io/ioutil"
109
"os"
1110
"regexp"
1211
"strings"
@@ -198,7 +197,7 @@ func parseConfigFile(data []byte, profile string) (info *configFileInfo, err err
198197

199198
//Look for profile
200199
for i, line := range splitContent {
201-
if match := profileRegex.FindStringSubmatch(line); match != nil && len(match) > 1 && match[1] == profile {
200+
if match := profileRegex.FindStringSubmatch(line); len(match) > 1 && match[1] == profile {
202201
start := i + 1
203202
return parseConfigAtLine(start, splitContent)
204203
}
@@ -257,7 +256,7 @@ func openConfigFile(configFilePath string) (data []byte, err error) {
257256
return
258257
}
259258

260-
data, err = ioutil.ReadFile(expandedPath)
259+
data, err = os.ReadFile(expandedPath)
261260
if err != nil {
262261
err = fmt.Errorf("can not read config file: %s due to: %s", configFilePath, err.Error())
263262
}
@@ -272,7 +271,7 @@ func readTokenFromFile(tokenFilePath string) (string, error) {
272271
return "", err
273272
}
274273

275-
data, err := ioutil.ReadFile(expandedPath)
274+
data, err := os.ReadFile(expandedPath)
276275
if err != nil {
277276
err = fmt.Errorf("can not read token file: %s due to: %s", tokenFilePath, err.Error())
278277
return "", err
@@ -404,7 +403,7 @@ func (p fileConfigurationProvider) PrivateRSAKey() (key *rsa.PrivateKey, err err
404403
return
405404
}
406405

407-
pemFileContent, err := ioutil.ReadFile(expandedPath)
406+
pemFileContent, err := os.ReadFile(expandedPath)
408407
if err != nil {
409408
err = fmt.Errorf("can not read PrivateKey %s from configuration file due to: %s", filePath, err.Error())
410409
return
@@ -439,7 +438,7 @@ func (p fileConfigurationProvider) Region() (value string, err error) {
439438
return canStringBeRegion(value)
440439
}
441440

442-
var blankRegex = regexp.MustCompile("\\s")
441+
var blankRegex = regexp.MustCompile(`\s`)
443442

444443
func canStringBeRegion(stringRegion string) (region string, err error) {
445444
if blankRegex.MatchString(stringRegion) || stringRegion == "" {

0 commit comments

Comments
 (0)