Skip to content

Commit

Permalink
#183 Prepare for versioned release (#184)
Browse files Browse the repository at this point in the history
* #183 Prepare for versioned release

* #183 Disable Darwin testing

* #183 Disable Windows testing temporarily

* #183 Update dependencies

* #183 Add methods required by interface

* #183 Update changelog

* #183 Working testcases

* #183 Working testcases
  • Loading branch information
docktermj authored May 8, 2024
1 parent f9fa51c commit d1bfe84
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: go test darwin

# TODO: Once "arm64" is available, rename file to "go-test-darwin.yaml"

on: [push]

env:
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.7.1] - 2024-05-08

### Added in 0.7.1

- `SzDiagnostic.GetFeature`
- `SzEngine.FindInterestingEntitiesByEntityId`
- `SzEngine.FindInterestingEntitiesByRecordId`

### Deleted in 0.7.1

- `SzEngine.GetRepositoryLastModifiedTime`

## [0.7.0] - 2024-04-26

### Changed in 0.7.0
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ require (
github.com/senzing-garage/go-helpers v0.5.1
github.com/senzing-garage/go-logging v1.4.1
github.com/senzing-garage/go-observing v0.3.1
github.com/senzing-garage/sz-sdk-go v0.12.1
github.com/senzing-garage/sz-sdk-go v0.12.3
github.com/stretchr/testify v1.9.0
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/senzing-garage/go-messaging v1.4.1 // indirect
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ github.com/senzing-garage/go-messaging v1.4.1 h1:ZdFcemh1iACP+HJWGS5/QLaUSD7PUYV
github.com/senzing-garage/go-messaging v1.4.1/go.mod h1:7tEicOa0baYz0lh0w1BJEiQ6ry1FIQl/67JAWwFpcRY=
github.com/senzing-garage/go-observing v0.3.1 h1:EGqe+Uix8VNQ9HCwm5xZkAF0hGoHaC1URAaT/5FW37A=
github.com/senzing-garage/go-observing v0.3.1/go.mod h1:x60vlRIR0ZdJrHDuK82nzmQG4sN0G6oqdLE9vQl9pVc=
github.com/senzing-garage/sz-sdk-go v0.12.1 h1:W+4rotdlN6O/eGWNITrCz+LZ30YQ9Pog1Id0XtWPo9c=
github.com/senzing-garage/sz-sdk-go v0.12.1/go.mod h1:K+tiyY6W5FnUrzBZXIg5x7cWbZKpO/6rzpkCoKhcK6o=
github.com/senzing-garage/sz-sdk-go v0.12.3 h1:KDOByEcJ5oTMogR9BKx7UWfEiy2/lswSQqykRmdyJt8=
github.com/senzing-garage/sz-sdk-go v0.12.3/go.mod h1:K+tiyY6W5FnUrzBZXIg5x7cWbZKpO/6rzpkCoKhcK6o=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae h1:c55+MER4zkBS14uJhSZMGGmya0yJx5iHV4x/fpOSNRk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
Expand Down
35 changes: 35 additions & 0 deletions szdiagnostic/szdiagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,41 @@ func (client *Szdiagnostic) GetDatastoreInfo(ctx context.Context) (string, error
return resultResponse, err
}

/*
The Reinitialize method re-initializes the Senzing G2Diagnostic object.
Input
- ctx: A context to control lifecycle.
- configId: The configuration ID used for the initialization.
*/
func (client *Szdiagnostic) GetFeature(ctx context.Context, featureId int64) (string, error) {
// _DLEXPORT int G2Diagnostic_getFeature(const long long libFeatID);
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var err error = nil
var resultResponse string
entryTime := time.Now()
if client.isTrace {
client.traceEntry(99, featureId)
defer func() { client.traceExit(99, featureId, err, time.Since(entryTime)) }()
}
result := C.G2Diagnostic_getFeature_helper(C.longlong(featureId))
if result.returnCode != 0 {
err = client.newError(ctx, 9999, featureId, result, time.Since(entryTime))
}
resultResponse = C.GoString(result.response)
C.G2GoHelper_free(unsafe.Pointer(result.response))
if client.observers != nil {
go func() {
details := map[string]string{
"featureId": strconv.FormatInt(featureId, 10),
}
notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 9999, err, details)
}()
}
return resultResponse, err
}

/*
The PurgeRepository method removes every record in the Senzing repository.
Before calling purgeRepository() all other instances of the Senzing API
Expand Down
25 changes: 25 additions & 0 deletions szdiagnostic/szdiagnostic_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ func ExampleSzdiagnostic_CheckDatastorePerformance() {
// Output: {"numRecordsInserted":...
}

func ExampleSzdiagnostic_GetDatastoreInfo() {
// For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szdiagnostic/szdiagnostic_examples_test.go
ctx := context.TODO()
szDiagnostic := getSzDiagnostic(ctx)
result, err := szDiagnostic.GetDatastoreInfo(ctx)
if err != nil {
fmt.Println(err)
}
fmt.Println(truncate(result, 61))
// Output: {"dataStores":[{"id":"CORE", "type":"sqlite3","location":"...
}

func ExampleSzdiagnostic_GetFeature() {
// For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szdiagnostic/szdiagnostic_examples_test.go
ctx := context.TODO()
szDiagnostic := getSzDiagnostic(ctx)
featureId := int64(1)
result, err := szDiagnostic.GetFeature(ctx, featureId)
if err != nil {
fmt.Println(err)
}
fmt.Println(result)
// Output: {"LIB_FEAT_ID":1,"FTYPE_CODE":"NAME","ELEMENTS":[{"FELEM_CODE":"TOKENIZED_NM","FELEM_VALUE":"ROBERT|SMITH"},{"FELEM_CODE":"CATEGORY","FELEM_VALUE":"PERSON"},{"FELEM_CODE":"CULTURE","FELEM_VALUE":"ANGLO"},{"FELEM_CODE":"GIVEN_NAME","FELEM_VALUE":"Robert"},{"FELEM_CODE":"SUR_NAME","FELEM_VALUE":"Smith"},{"FELEM_CODE":"FULL_NAME","FELEM_VALUE":"Robert Smith"}]}
}

func ExampleSzdiagnostic_PurgeRepository() {
// For more information, visit https://github.com/Senzing/sz-sdk-go-core/blob/main/szdiagnostic/szdiagnostic_examples_test.go
ctx := context.TODO()
Expand Down
13 changes: 11 additions & 2 deletions szdiagnostic/szdiagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ func TestSzdiagnostic_GetDatastoreInfo(test *testing.T) {
printActual(test, actual)
}

func TestSzdiagnostic_PurgeRepository(test *testing.T) {
func TestSzdiagnostic_GetFeature(test *testing.T) {
ctx := context.TODO()
szDiagnostic := getTestObject(ctx, test)
err := szDiagnostic.PurgeRepository(ctx)
featureId := int64(1)
actual, err := szDiagnostic.GetFeature(ctx, int64(featureId))
testError(test, err)
printActual(test, actual)
}

// func TestSzdiagnostic_PurgeRepository(test *testing.T) {
// ctx := context.TODO()
// szDiagnostic := getTestObject(ctx, test)
// err := szDiagnostic.PurgeRepository(ctx)
// testError(test, err)
// }

// ----------------------------------------------------------------------------
// Logging and observing
// ----------------------------------------------------------------------------
Expand Down
125 changes: 90 additions & 35 deletions szengine/szengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,96 @@ func (client *Szengine) FetchNext(ctx context.Context, exportHandle uintptr) (st
return resultResponse, err
}

/*
TODO: Document FindInterestingEntitiesByEntityId
The FindInterestingEntitiesByEntityId method...
Input
- ctx: A context to control lifecycle.
- entityId: The unique identifier of an entity.
- flags: Flags used to control information returned.
Output
- A JSON document.
See the example output.
*/
func (client *Szengine) FindInterestingEntitiesByEntityId(ctx context.Context, entityId int64, flags int64) (string, error) {
// _DLEXPORT int G2_findInterestingEntitiesByEntityID(const long long entityID, const long long flags, char **responseBuf, size_t *bufSize, void *(*resizeFunc)(void *ptr, size_t newSize));
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var err error = nil
var resultResponse string
entryTime := time.Now()
if client.isTrace {
client.traceEntry(33, entityId, flags)
defer func() { client.traceExit(34, entityId, flags, resultResponse, err, time.Since(entryTime)) }()
}
result := C.G2_findInterestingEntitiesByEntityID_helper(C.longlong(entityId), C.longlong(flags))
if result.returnCode != 0 {
err = client.newError(ctx, 4015, entityId, flags, result.returnCode, time.Since(entryTime))
}
resultResponse = C.GoString(result.response)
C.G2GoHelper_free(unsafe.Pointer(result.response))
if client.observers != nil {
go func() {
details := map[string]string{
"entityID": strconv.FormatInt(entityId, 10),
}
notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8016, err, details)
}()
}
return resultResponse, err
}

/*
TODO: Document FindInterestingEntitiesByRecordId
The FindInterestingEntitiesByRecordId method...
Input
- ctx: A context to control lifecycle.
- dataSourceCode: Identifies the provenance of the data.
- recordId: The unique identifier within the records of the same data source.
- flags: Flags used to control information returned.
Output
- A JSON document.
See the example output.
*/
func (client *Szengine) FindInterestingEntitiesByRecordId(ctx context.Context, dataSourceCode string, recordId string, flags int64) (string, error) {
// _DLEXPORT int G2_findInterestingEntitiesByRecordID(const char* dataSourceCode, const char* recordID, const long long flags, char **responseBuf, size_t *bufSize, void *(*resizeFunc)(void *ptr, size_t newSize));
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var err error = nil
var resultResponse string
entryTime := time.Now()
if client.isTrace {
client.traceEntry(35, dataSourceCode, recordId, flags)
defer func() {
client.traceExit(36, dataSourceCode, recordId, flags, resultResponse, err, time.Since(entryTime))
}()
}
dataSourceCodeForC := C.CString(dataSourceCode)
defer C.free(unsafe.Pointer(dataSourceCodeForC))
recordIDForC := C.CString(recordId)
defer C.free(unsafe.Pointer(recordIDForC))
result := C.G2_findInterestingEntitiesByRecordID_helper(dataSourceCodeForC, recordIDForC, C.longlong(flags))
if result.returnCode != 0 {
err = client.newError(ctx, 4016, dataSourceCode, recordId, flags, result.returnCode, time.Since(entryTime))
}
resultResponse = C.GoString(result.response)
C.G2GoHelper_free(unsafe.Pointer(result.response))
if client.observers != nil {
go func() {
details := map[string]string{
"dataSourceCode": dataSourceCode,
"recordID": recordId,
}
notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8017, err, details)
}()
}
return resultResponse, err
}

/*
The FindNetworkByEntityId method finds all entities surrounding a requested set of entities.
This includes the requested entities, paths between them, and relations to other nearby entities.
Expand Down Expand Up @@ -791,41 +881,6 @@ func (client *Szengine) GetRedoRecord(ctx context.Context) (string, error) {
return resultResponse, err
}

/*
The GetRepositoryLastModifiedTime method retrieves the last modified time of the Senzing repository,
measured in the number of seconds between the last modified time and January 1, 1970 12:00am GMT (epoch time).
Input
- ctx: A context to control lifecycle.
Output
- A Unix Timestamp.
*/
func (client *Szengine) GetRepositoryLastModifiedTime(ctx context.Context) (int64, error) {
// _DLEXPORT int G2_getRepositoryLastModifiedTime(long long* lastModifiedTime);
runtime.LockOSThread()
defer runtime.UnlockOSThread()
var err error = nil
var resultTime int64
entryTime := time.Now()
if client.isTrace {
client.traceEntry(89)
defer func() { client.traceExit(90, resultTime, err, time.Since(entryTime)) }()
}
result := C.G2_getRepositoryLastModifiedTime_helper()
if result.returnCode != 0 {
err = client.newError(ctx, 4042, result.returnCode, result, time.Since(entryTime))
}
resultTime = int64(result.time)
if client.observers != nil {
go func() {
details := map[string]string{}
notifier.Notify(ctx, client.observers, client.observerOrigin, ComponentId, 8042, err, details)
}()
}
return resultTime, err
}

/*
The GetStats method retrieves workload statistics for the current process.
These statistics will automatically reset after retrieval.
Expand Down
41 changes: 29 additions & 12 deletions szengine/szengine_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,35 @@ func ExampleSzengine_FetchNext() {
// Output: true
}

func ExampleSzengine_FindInterestingEntitiesByEntityId() {
// For more information, visit https://github.com/senzing-garage/g2-sdk-go-base/blob/main/g2engine/g2engine_examples_test.go
ctx := context.TODO()
szEngine := getSzEngine(ctx)
entityId := getEntityIdForRecord("CUSTOMERS", "1001")
flags := int64(0)
result, err := szEngine.FindInterestingEntitiesByEntityId(ctx, entityId, flags)
if err != nil {
fmt.Println(err)
}
fmt.Println(result)
// Output: {"INTERESTING_ENTITIES":{"ENTITIES":[]}}
}

func ExampleSzengine_FindInterestingEntitiesByRecordId() {
// For more information, visit https://github.com/senzing-garage/g2-sdk-go-base/blob/main/g2engine/g2engine_examples_test.go
ctx := context.TODO()
szEngine := getSzEngine(ctx)
dataSourceCode := "CUSTOMERS"
recordId := "1001"
flags := int64(0)
result, err := szEngine.FindInterestingEntitiesByRecordId(ctx, dataSourceCode, recordId, flags)
if err != nil {
fmt.Println(err)
}
fmt.Println(result)
// Output: {"INTERESTING_ENTITIES":{"ENTITIES":[]}}
}

func ExampleSzengine_FindNetworkByEntityId() {
// For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szengine/szengine_examples_test.go
ctx := context.TODO()
Expand Down Expand Up @@ -432,18 +461,6 @@ func ExampleSzengine_GetRedoRecord() {
// Output: {"REASON":"deferred delete","DATA_SOURCE":"CUSTOMERS","RECORD_ID":"1001","DSRC_ACTION":"X"}
}

func ExampleSzengine_GetRepositoryLastModifiedTime() {
// For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szengine/szengine_examples_test.go
ctx := context.TODO()
szEngine := getSzEngine(ctx)
result, err := szEngine.GetRepositoryLastModifiedTime(ctx)
if err != nil {
fmt.Println(err)
}
fmt.Println(result > 0) // Dummy output.
// Output: true
}

func ExampleSzengine_GetStats() {
// For more information, visit https://github.com/senzing-garage/sz-sdk-go-core/blob/main/szengine/szengine_examples_test.go
ctx := context.TODO()
Expand Down
Loading

0 comments on commit d1bfe84

Please sign in to comment.