Commit aa5d0de4 authored by Vijay Kumar Chauhan's avatar Vijay Kumar Chauhan
Browse files

Merge branch 'ImmudbVersionUpgrade-prafuln' into 'coreimmudb'

immudb version upgrade

See merge request !268
parents ed14a167 24524c2d
3 merge requests!270Core ImmuDB package and TOTP plugin - Implementation,!269Core ImmuDB package and TOTP plugin - Implementation,!268immudb version upgrade
Showing with 108 additions and 673 deletions
...@@ -47,7 +47,8 @@ type ImmuDAO struct { ...@@ -47,7 +47,8 @@ type ImmuDAO struct {
MetaData MetaData MetaData MetaData
} }
type MetaData struct { type MetaData struct {
GetOpts GetOptions GetOpts GetOptions
ScanOpts schema.ScanRequest
} }
type GetOptions struct { type GetOptions struct {
AtTx uint64 `json:"atTx"` AtTx uint64 `json:"atTx"`
...@@ -215,6 +216,7 @@ func TestDbConnection(host ImmuHost) error { ...@@ -215,6 +216,7 @@ func TestDbConnection(host ImmuHost) error {
if err != nil { if err != nil {
return err return err
} }
defer client.CloseSession(context.TODO())
if ok := client.IsConnected(); !ok { if ok := client.IsConnected(); !ok {
return errormdl.Wrap("ImmuDB is not connected") return errormdl.Wrap("ImmuDB is not connected")
} }
...@@ -343,6 +345,30 @@ func (i *ImmuDAO) GetKeyHistory(key []byte, offset uint64, limit int32, desc boo ...@@ -343,6 +345,30 @@ func (i *ImmuDAO) GetKeyHistory(key []byte, offset uint64, limit int32, desc boo
return client.History(context.TODO(), req) return client.History(context.TODO(), req)
} }
// GetActiveKeys - List all avaliable keys from active database, this function does not retrive deleted keys
/*
This call can have below options:-
SeekKey - List all keys which were inserted/saved after the specified key, include specified key in result if InclusiveSeek = True
EndKey - List all keys which were inserted/saved before the specified key, include specified key in result if InclusiveEnd = True
Prefix - List all keys which are perfixed with given character(s)
Desc - Sorting in descending order
Limit - Maximum numbers of entries to return
SinceTx - Used to avoid waiting for the indexer to be up-to-date with the most recent transaction
NoWait (True/False) - If set to true, then the server will not wait for the indexer to be up-to-date with the most recent transaction
InclusiveSeek (True/False)
InclusiveEnd (True/False)
Offset - Number of entries to skip
*/
func (i *ImmuDAO) GetActiveKeys() (*schema.Entries, error) {
client, err := GetImmuDbConnection(i.HostName) // ImmuDB connection
if err != nil {
return nil, err
}
// Scan iterates over the set of keys in a topological order
return client.Scan(context.TODO(), &i.MetaData.ScanOpts)
}
/* END OF READ OPERATIONS */ /* END OF READ OPERATIONS */
/* WRITE OPERATIONS */ /* WRITE OPERATIONS */
......
...@@ -687,3 +687,35 @@ func TestImmuDAO_ListDatabases(t *testing.T) { ...@@ -687,3 +687,35 @@ func TestImmuDAO_ListDatabases(t *testing.T) {
}) })
} }
} }
func TestImmuDAO_GetActiveKeys(t *testing.T) {
type fields struct {
HostName string
MetaData MetaData
}
tests := []struct {
name string
fields fields
want *schema.Entries
wantErr bool
}{
{name: "Test 1", fields: fields{HostName: "ImmuDbHost1"}, wantErr: false},
{name: "Test 2", fields: fields{HostName: "ImmuDbHost22"}, wantErr: false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
i := &ImmuDAO{
HostName: tt.fields.HostName,
MetaData: tt.fields.MetaData,
}
got, err := i.GetActiveKeys()
if (err != nil) != tt.wantErr {
t.Errorf("ImmuDAO.GetActiveKeys() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) && err == nil {
t.Errorf("ImmuDAO.GetActiveKeys() = %v, want %v", got, tt.want)
}
})
}
}
...@@ -9,7 +9,7 @@ require ( ...@@ -9,7 +9,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d
github.com/aymerick/raymond v2.0.2+incompatible github.com/aymerick/raymond v2.0.2+incompatible
github.com/boltdb/bolt v1.3.1 github.com/boltdb/bolt v1.3.1
github.com/codenotary/immudb v1.4.1 github.com/codenotary/immudb v1.5.0
github.com/denisenkom/go-mssqldb v0.12.2 github.com/denisenkom/go-mssqldb v0.12.2
github.com/dgraph-io/dgo/v2 v2.2.0 github.com/dgraph-io/dgo/v2 v2.2.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
...@@ -33,7 +33,7 @@ require ( ...@@ -33,7 +33,7 @@ require (
github.com/qiangxue/fasthttp-routing v0.0.0-20160225050629-6ccdc2a18d87 github.com/qiangxue/fasthttp-routing v0.0.0-20160225050629-6ccdc2a18d87
github.com/segmentio/ksuid v1.0.4 github.com/segmentio/ksuid v1.0.4
github.com/shurcooL/go-goon v1.0.0 github.com/shurcooL/go-goon v1.0.0
github.com/stretchr/testify v1.8.1 github.com/stretchr/testify v1.8.2
github.com/tidwall/buntdb v1.2.9 github.com/tidwall/buntdb v1.2.9
github.com/tidwall/gjson v1.14.1 github.com/tidwall/gjson v1.14.1
github.com/tidwall/sjson v1.2.4 github.com/tidwall/sjson v1.2.4
...@@ -41,8 +41,8 @@ require ( ...@@ -41,8 +41,8 @@ require (
github.com/zhouzhuojie/conditions v0.2.3 github.com/zhouzhuojie/conditions v0.2.3
go.mongodb.org/mongo-driver v1.9.1 go.mongodb.org/mongo-driver v1.9.1
go.uber.org/zap v1.21.0 go.uber.org/zap v1.21.0
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/crypto v0.10.0
google.golang.org/grpc v1.54.0 google.golang.org/grpc v1.56.1
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0
...@@ -93,10 +93,10 @@ require ( ...@@ -93,10 +93,10 @@ require (
github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/rs/xid v1.4.0 // indirect github.com/rs/xid v1.5.0 // indirect
github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636 // indirect github.com/shurcooL/go v0.0.0-20200502201357-93f07166e636 // indirect
github.com/spf13/afero v1.9.5 // indirect github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
...@@ -116,13 +116,15 @@ require ( ...@@ -116,13 +116,15 @@ require (
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.uber.org/atomic v1.9.0 // indirect go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect go.uber.org/multierr v1.8.0 // indirect
golang.org/x/net v0.8.0 // indirect golang.org/x/net v0.11.0 // indirect
golang.org/x/sync v0.1.0 // indirect golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.7.0 // indirect golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.7.0 // indirect golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.8.0 // indirect golang.org/x/text v0.10.0 // indirect
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd // indirect google.golang.org/genproto v0.0.0-20230626202813-9b080da550b3 // indirect
google.golang.org/protobuf v1.30.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230626202813-9b080da550b3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230626202813-9b080da550b3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
......
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment