Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mogo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
mogo
Commits
3c9a1dc1
Commit
3c9a1dc1
authored
May 22, 2024
by
luxq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update package
parent
cae0d7b2
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
22 additions
and
30 deletions
+22
-30
db.go
db/db.go
+0
-22
docker-compose.yml
docker-compose.yml
+1
-1
go.mod
go.mod
+1
-1
taskinfo.go
operator/taskinfo.go
+1
-1
workerInstalledInfo.go
operator/workerInstalledInfo.go
+1
-1
workerRunningInfo.go
operator/workerRunningInfo.go
+1
-1
workerinfo.go
operator/workerinfo.go
+1
-1
workerinfo_test.go
operator/workerinfo_test.go
+16
-2
No files found.
db/db.go
deleted
100644 → 0
View file @
cae0d7b2
package
db
import
(
"context"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func
ConnectMongoDB
(
uri
string
,
username
,
passwd
string
)
(
*
mongo
.
Client
,
error
)
{
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
client
,
err
:=
mongo
.
Connect
(
ctx
,
options
.
Client
()
.
ApplyURI
(
uri
)
.
SetAuth
(
options
.
Credential
{
Username
:
username
,
Password
:
passwd
,
}))
if
err
!=
nil
{
return
nil
,
err
}
return
client
,
nil
}
docker-compose.yml
View file @
3c9a1dc1
...
...
@@ -27,7 +27,7 @@ services:
volumes
:
-
type
:
volume
source
:
MONGO_DATA
target
:
/data/
db
target
:
/data/
operator
-
type
:
volume
source
:
MONGO_CONFIG
target
:
/data/configdb
...
...
go.mod
View file @
3c9a1dc1
module mogo
module
github.com/odysseus/
mogo
go 1.21
...
...
db
/taskinfo.go
→
operator
/taskinfo.go
View file @
3c9a1dc1
package
db
package
operator
type
DbTaskInfo
struct
{
ID
string
`bson:"_id,omitempty" json:"id"`
...
...
db
/workerInstalledInfo.go
→
operator
/workerInstalledInfo.go
View file @
3c9a1dc1
package
db
package
operator
import
(
"context"
...
...
db
/workerRunningInfo.go
→
operator
/workerRunningInfo.go
View file @
3c9a1dc1
package
db
package
operator
import
(
"context"
...
...
db
/workerinfo.go
→
operator
/workerinfo.go
View file @
3c9a1dc1
package
db
package
operator
import
(
"context"
...
...
db
/workerinfo_test.go
→
operator
/workerinfo_test.go
View file @
3c9a1dc1
package
db
package
operator
import
(
"context"
...
...
@@ -8,6 +8,7 @@ import (
"github.com/google/uuid"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"log"
"math/rand"
"mogo/types"
...
...
@@ -25,6 +26,19 @@ var (
workerRunningCollection
=
"worker_running"
)
func
ConnectMongoDB
(
uri
string
,
username
,
passwd
string
)
(
*
mongo
.
Client
,
error
)
{
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
client
,
err
:=
mongo
.
Connect
(
ctx
,
options
.
Client
()
.
ApplyURI
(
uri
)
.
SetAuth
(
options
.
Credential
{
Username
:
username
,
Password
:
passwd
,
}))
if
err
!=
nil
{
return
nil
,
err
}
return
client
,
nil
}
func
init
()
{
client
,
err
:=
ConnectMongoDB
(
"mongodb://localhost:27017"
,
"admin"
,
"admin"
)
if
err
!=
nil
{
...
...
@@ -38,7 +52,7 @@ func initdata(client *mongo.Client) []string {
db
:=
NewDBWorker
(
client
,
database
)
dbRunning
:=
NewDBWorkerRunning
(
client
,
database
)
// Insert 1,000,000 DbWorkerInfo to
db
// Insert 1,000,000 DbWorkerInfo to
operator
for
i
:=
0
;
i
<
1000
;
i
++
{
worker
:=
generateAWroker
()
result
,
err
:=
db
.
InsertWorker
(
context
.
Background
(),
worker
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment