Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
b708176a
Commit
b708176a
authored
1 year ago
by
Akshay Mahendrakar
Browse files
Options
Downloads
Patches
Plain Diff
variable naming convention changes, and method description(more specific).
parent
4684e851
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!270
Core ImmuDB package and TOTP plugin - Implementation
,
!269
Core ImmuDB package and TOTP plugin - Implementation
,
!267
List users and list databases feature, Creating specified (hidden) directory…
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dalmdl/coreimmudb/coreimmudb.go
+42
-38
dalmdl/coreimmudb/coreimmudb.go
with
42 additions
and
38 deletions
dalmdl/coreimmudb/coreimmudb.go
+
42
−
38
View file @
b708176a
...
...
@@ -85,49 +85,49 @@ func InitUsingJson(filePath string) error {
mutex
.
Lock
()
defer
mutex
.
Unlock
()
for
_
,
h
:=
range
hosts
{
if
h
.
IsDisabled
{
// Not connecting to database if isDisabled == true
for
_
,
h
ost
:=
range
hosts
{
if
h
ost
.
IsDisabled
{
// Not connecting to database if isDisabled == true
continue
}
var
client
immudb
.
ImmuClient
opts
:=
immudb
.
DefaultOptions
()
opts
.
Address
=
h
.
Server
opts
.
Port
=
h
.
Port
if
h
.
Dir
!=
""
{
opts
.
Address
=
h
ost
.
Server
opts
.
Port
=
h
ost
.
Port
if
h
ost
.
Dir
!=
""
{
// Checking if folder name contains extension
if
filepath
.
Ext
(
h
.
Dir
)
!=
""
{
return
errormdl
.
Wrap
(
"DIRECTORY NAME CONTAINS EXTENSION "
+
filepath
.
Ext
(
h
.
Dir
))
if
filepath
.
Ext
(
h
ost
.
Dir
)
!=
""
{
return
errormdl
.
Wrap
(
"DIRECTORY NAME CONTAINS EXTENSION "
+
filepath
.
Ext
(
h
ost
.
Dir
))
}
path
:=
strings
.
Split
(
h
.
Dir
,
"/"
)
path
:=
strings
.
Split
(
h
ost
.
Dir
,
"/"
)
// Hiding folder by adding prefix '.'
if
!
strings
.
HasPrefix
(
path
[
len
(
path
)
-
1
],
"."
)
{
path
[
len
(
path
)
-
1
]
=
"."
+
path
[
len
(
path
)
-
1
]
}
h
.
Dir
=
strings
.
Join
(
path
,
"/"
)
h
ost
.
Dir
=
strings
.
Join
(
path
,
"/"
)
if
_
,
err
:=
os
.
Stat
(
h
.
Dir
);
os
.
IsNotExist
(
err
)
{
// Checking directory is present and accessible
if
err
=
os
.
Mkdir
(
h
.
Dir
,
0740
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
h
ost
.
Dir
);
os
.
IsNotExist
(
err
)
{
// Checking directory is present and accessible
if
err
=
os
.
Mkdir
(
h
ost
.
Dir
,
0740
);
err
!=
nil
{
return
err
}
}
opts
.
Dir
=
h
.
Dir
opts
.
Dir
=
h
ost
.
Dir
}
if
h
.
MaxRecvMsgSize
>
0
{
// Setting maximum receive message size if provided
opts
.
MaxRecvMsgSize
=
h
.
MaxRecvMsgSize
*
1024
*
1024
if
h
ost
.
MaxRecvMsgSize
>
0
{
// Setting maximum receive message size if provided
opts
.
MaxRecvMsgSize
=
h
ost
.
MaxRecvMsgSize
*
1024
*
1024
}
client
=
immudb
.
NewClient
()
.
WithOptions
(
opts
)
err
:=
client
.
OpenSession
(
context
.
TODO
(),
[]
byte
(
h
.
Username
),
[]
byte
(
h
.
Password
),
h
.
Database
)
err
:=
client
.
OpenSession
(
context
.
TODO
(),
[]
byte
(
h
ost
.
Username
),
[]
byte
(
h
ost
.
Password
),
h
ost
.
Database
)
if
err
!=
nil
{
instances
=
make
(
map
[
string
]
immudb
.
ImmuClient
)
return
err
}
instances
[
h
.
HostName
]
=
client
if
h
.
IsDefault
{
DefaultHostName
=
h
.
HostName
instances
[
h
ost
.
HostName
]
=
client
if
h
ost
.
IsDefault
{
DefaultHostName
=
h
ost
.
HostName
}
}
return
nil
...
...
@@ -138,47 +138,47 @@ func InitImmuDBConnections(hosts []ImmuHost) error {
instances
=
make
(
map
[
string
]
immudb
.
ImmuClient
)
mutex
.
Lock
()
defer
mutex
.
Unlock
()
for
_
,
v
:=
range
hosts
{
if
v
.
IsDisabled
{
// Not connecting to database if isDisabled == true
for
_
,
host
:=
range
hosts
{
if
host
.
IsDisabled
{
// Not connecting to database if isDisabled == true
continue
}
var
client
immudb
.
ImmuClient
opts
:=
immudb
.
DefaultOptions
()
opts
.
Address
=
v
.
Server
opts
.
Port
=
v
.
Port
if
v
.
Dir
!=
""
{
opts
.
Address
=
host
.
Server
opts
.
Port
=
host
.
Port
if
host
.
Dir
!=
""
{
// Checking if folder name contains extension
if
filepath
.
Ext
(
v
.
Dir
)
!=
""
{
return
errormdl
.
Wrap
(
"DIRECTORY NAME CONTAINS EXTENSION "
+
filepath
.
Ext
(
v
.
Dir
))
if
filepath
.
Ext
(
host
.
Dir
)
!=
""
{
return
errormdl
.
Wrap
(
"DIRECTORY NAME CONTAINS EXTENSION "
+
filepath
.
Ext
(
host
.
Dir
))
}
path
:=
strings
.
Split
(
v
.
Dir
,
"/"
)
path
:=
strings
.
Split
(
host
.
Dir
,
"/"
)
// Hiding folder by adding prefix '.'
if
!
strings
.
HasPrefix
(
path
[
len
(
path
)
-
1
],
"."
)
{
path
[
len
(
path
)
-
1
]
=
"."
+
path
[
len
(
path
)
-
1
]
}
v
.
Dir
=
strings
.
Join
(
path
,
"/"
)
if
_
,
err
:=
os
.
Stat
(
v
.
Dir
);
os
.
IsNotExist
(
err
)
{
// Checking directory is present and accessible
if
err
=
os
.
Mkdir
(
v
.
Dir
,
0740
);
err
!=
nil
{
host
.
Dir
=
strings
.
Join
(
path
,
"/"
)
if
_
,
err
:=
os
.
Stat
(
host
.
Dir
);
os
.
IsNotExist
(
err
)
{
// Checking directory is present and accessible
if
err
=
os
.
Mkdir
(
host
.
Dir
,
0740
);
err
!=
nil
{
return
err
}
}
opts
.
Dir
=
v
.
Dir
opts
.
Dir
=
host
.
Dir
}
if
v
.
MaxRecvMsgSize
>
0
{
// Setting maximum receive message size if provided
opts
.
MaxRecvMsgSize
=
v
.
MaxRecvMsgSize
*
1024
*
1024
if
host
.
MaxRecvMsgSize
>
0
{
// Setting maximum receive message size if provided
opts
.
MaxRecvMsgSize
=
host
.
MaxRecvMsgSize
*
1024
*
1024
}
client
=
immudb
.
NewClient
()
.
WithOptions
(
opts
)
err
:=
client
.
OpenSession
(
context
.
TODO
(),
[]
byte
(
v
.
Username
),
[]
byte
(
v
.
Password
),
v
.
Database
)
err
:=
client
.
OpenSession
(
context
.
TODO
(),
[]
byte
(
host
.
Username
),
[]
byte
(
host
.
Password
),
host
.
Database
)
if
err
!=
nil
{
instances
=
make
(
map
[
string
]
immudb
.
ImmuClient
)
return
err
}
instances
[
v
.
HostName
]
=
client
if
v
.
IsDefault
{
DefaultHostName
=
v
.
HostName
instances
[
host
.
HostName
]
=
client
if
host
.
IsDefault
{
DefaultHostName
=
host
.
HostName
}
}
return
nil
...
...
@@ -404,7 +404,7 @@ func (i *ImmuDAO) ExpirableKeySet(key, value []byte, expiresAt time.Time) (*sche
/* END OF WRITE OPERATIONS */
// CreateDatabase - Creates new database in ImmuDB
// CreateDatabase - Creates new database in ImmuDB
, current database user requires SysAdmin permission level.
func
(
i
*
ImmuDAO
)
CreateDatabase
(
dbName
string
,
dbSettings
*
schema
.
DatabaseNullableSettings
)
(
*
schema
.
CreateDatabaseResponse
,
error
)
{
client
,
err
:=
GetImmuDbConnection
(
i
.
HostName
)
if
err
!=
nil
{
...
...
@@ -464,7 +464,11 @@ func (i *ImmuDAO) CreateUser(username, password, dbName string, permission int)
}
/*
ListUsers - List all database users
ListUsers - List all database of user
This call requires Admin or SysAdmin permission level.
When called as a SysAdmin user, all users in the database are returned. When called as an Admin user, users for currently selected database are returned.
*/
func
(
i
*
ImmuDAO
)
ListUsers
()
(
*
schema
.
UserList
,
error
)
{
client
,
err
:=
GetImmuDbConnection
(
i
.
HostName
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets