Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemanager
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
nodemanager
Commits
2ae53176
Commit
2ae53176
authored
May 22, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mogo
parent
5083c77d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
104 additions
and
28 deletions
+104
-28
Dockerfile
Dockerfile
+2
-1
config.toml
config.toml
+9
-4
Config.go
config/Config.go
+15
-8
docker-compose.yml
docker/docker-compose.yml
+0
-9
script.js
docker/scripts/script.js
+18
-3
go.mod
go.mod
+11
-1
go.sum
go.sum
+16
-2
node.go
server/node.go
+8
-0
workerManager.go
server/workerManager.go
+4
-0
mongodb.go
utils/mongodb.go
+21
-0
No files found.
Dockerfile
View file @
2ae53176
...
...
@@ -9,9 +9,10 @@ RUN go env -w CGO_ENABLED="1"
WORKDIR
/build
RUN
git clone https://code.wuban.net.cn/odysseus/nodemanager
&&
\
RUN
git clone
-b
nmapi-v2
https://code.wuban.net.cn/odysseus/nodemanager
&&
\
git clone https://code.wuban.net.cn/odysseus/odysseus-protocol
&&
\
git clone https://code.wuban.net.cn/odysseus/cache
&&
\
git clone https://code.wuban.net.cn/odysseus/mogo
&&
\
git clone https://code.wuban.net.cn/odysseus/service-registry
RUN
cd
/build/nodemanager
&&
make
&&
cp
build/bin/manager /manager
...
...
config.toml
View file @
2ae53176
remote_host
=
"192.168.
2.30
"
local_host
=
"192.168.
2.30
"
remote_host
=
"192.168.
1.116
"
local_host
=
"192.168.
1.116
"
port
=
10001
metrics_port
=
28010
private_key
=
"E671C143A110C239B563F702E9F4017CA6B2B2912F675EED9AA4FED684EB30CC"
...
...
@@ -7,6 +7,11 @@ standard_task_file = "standardtask.json"
worker_multiple
=
2
worker_signature_expired_time
=
1
[mongodb]
url
=
"mongodb://0.0.0.0:27017"
user
=
"admin"
password
=
"admin"
[redis]
addr
=
"127.0.0.1:6379"
password
=
"123456"
...
...
@@ -18,7 +23,7 @@ db=0
#user="root"
#password="12345678"
#database="liuxuzhong"
host
=
"1
27.0.0.1
"
host
=
"1
8.167.203.17
"
port
=
3306
user
=
"ai"
password
=
"RFnnKHRar5xk7TEF"
...
...
@@ -35,4 +40,4 @@ heart_beat = 10
status_ticker
=
10
device_info_ticker
=
120
device_usage_ticker
=
100
worker_task_expire_ticker
=
60
worker_task_expire_ticker
=
60
00
config/Config.go
View file @
2ae53176
...
...
@@ -29,6 +29,12 @@ type RedisConfig struct {
DbIndex
int
`json:"db_index" toml:"db_index"`
}
type
MongoDbConfig
struct
{
Url
string
`json:"url" toml:"url"`
User
string
`json:"user" toml:"user"`
Passwd
string
`json:"password" toml:"password"`
}
type
TickerConfig
struct
{
HeartBeat
int
`json:"heart_beat" toml:"heart_beat"`
StatusTicker
int
`json:"status_ticker" toml:"status_ticker"`
...
...
@@ -44,14 +50,15 @@ type Config struct {
Port
int
`json:"port" toml:"port"`
StandardTaskFile
string
`json:"standard_task_file" toml:"standard_task_file"`
//Endpoint string `json:"endpoint" toml:"endpoint"`
MetricPort
int
`json:"metrics_port" toml:"metrics_port"`
EnablePay
bool
`json:"enable_pay" toml:"enable_pay"`
WorkerMultiple
int
`json:"worker_multiple" toml:"worker_multiple"`
WorkerSignatureExpiredTime
int64
`json:"worker_signature_expired_time" toml:"worker_signature_expired_time"`
Redis
RedisConfig
`json:"redis" toml:"redis"`
DbConfig
MysqlConfig
`json:"mysql" toml:"mysql"`
Tickers
TickerConfig
`json:"ticker" toml:"ticker"`
Kafka
KafkaConfig
`json:"kafka" toml:"kafka"`
MetricPort
int
`json:"metrics_port" toml:"metrics_port"`
EnablePay
bool
`json:"enable_pay" toml:"enable_pay"`
WorkerMultiple
int
`json:"worker_multiple" toml:"worker_multiple"`
WorkerSignatureExpiredTime
int64
`json:"worker_signature_expired_time" toml:"worker_signature_expired_time"`
Redis
RedisConfig
`json:"redis" toml:"redis"`
DbConfig
MysqlConfig
`json:"mysql" toml:"mysql"`
Tickers
TickerConfig
`json:"ticker" toml:"ticker"`
Kafka
KafkaConfig
`json:"kafka" toml:"kafka"`
Mongo
MongoDbConfig
`json:"mongodb" toml:"mongodb"`
}
var
_cfg
*
Config
=
nil
...
...
docker/docker-compose.yml
View file @
2ae53176
...
...
@@ -6,9 +6,6 @@ networks:
services
:
influxdb
:
image
:
influxdb:1.8
networks
:
-
k6
-
grafana
ports
:
-
"
8086:8086"
environment
:
...
...
@@ -16,8 +13,6 @@ services:
grafana
:
image
:
grafana/grafana:9.3.8
networks
:
-
grafana
ports
:
-
"
3000:3000"
environment
:
...
...
@@ -30,8 +25,6 @@ services:
k6
:
image
:
grafana/k6:latest
networks
:
-
k6
ports
:
-
"
6565:6565"
environment
:
...
...
@@ -73,8 +66,6 @@ services:
-
"
6379:6379"
volumes
:
-
"
/etc/localtime:/etc/localtime"
-
"
./redis/conf/redis.conf:/etc/redis/redis.conf"
-
"
./redis/data:/data"
zookeeper
:
image
:
library/zookeeper
container_name
:
zookeeper
...
...
docker/scripts/script.js
View file @
2ae53176
...
...
@@ -7,13 +7,16 @@ export const options = {
};
export
default
function
()
{
const
url
=
'
http://43.198.252.255:8000/api/v1//txt2img/base/llm
'
;
const
url
=
'
http://43.198.252.255:8000/api/v1/txt2img/base/llm
'
;
// const url = 'http://18.167.203.17:8000/api/v1/txt2img/base/llm';
// const url = 'https://api.dev.aigic.ai/api/v1/txt2img/base/llm';
const
payload
=
JSON
.
stringify
({
"
test
"
:
1
})
const
param
=
{
headers
:{
'
apikey
'
:
'
L6eXzteHYa2Uq0ar4kdMaBOiOIjmRI08
'
,
// 'apikey': '4oipB83LZCpkrVN3i12f38WcBUYH5MR9',
'
Content-Type
'
:
'
application/json
'
},
};
...
...
@@ -21,6 +24,7 @@ export default function() {
const
statusCheck
=
check
(
res
,
{
'
status is 200
'
:
(
r
)
=>
r
.
status
===
200
,
});
const
taskCheck
=
check
(
res
,
{
'
task is success
'
:
(
r
)
=>
r
.
json
(
'
task.is_success
'
)
===
true
,
});
...
...
@@ -28,7 +32,18 @@ export default function() {
// console.log('task status failed', res.status);
fail
(
'
task
'
+
res
.
headers
[
'
Task-Id
'
]
+
'
failed with status error:
'
+
res
.
status
);
}
else
if
(
!
taskCheck
)
{
fail
(
'
task
'
+
res
.
headers
[
'
Task-Id
'
]
+
'
failed with execute error:
'
+
res
.
json
(
'
task.error
'
));
// check res.boy is empty
if
(
res
.
body
==
null
)
{
fail
(
'
task
'
+
res
.
headers
[
'
Task-Id
'
]
+
'
failed with empty response
'
);
}
else
{
if
(
res
.
json
(
'
task.api_error.message
'
)
!==
undefined
)
{
fail
(
'
task
'
+
res
.
headers
[
'
Task-Id
'
]
+
'
failed with api error:
'
+
res
.
json
(
'
task.api_error.message
'
));
}
if
(
res
.
json
(
'
task.error
'
)
!==
undefined
)
{
fail
(
'
task
'
+
res
.
headers
[
'
Task-Id
'
]
+
'
failed with execute error:
'
+
res
.
json
(
'
task.error
'
));
}
}
}
//
console.log("res is ", res);
console
.
log
(
"
res is
"
,
res
);
}
go.mod
View file @
2ae53176
...
...
@@ -11,11 +11,12 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.3
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/uuid v1.
5
.0
github.com/google/uuid v1.
6
.0
github.com/hashicorp/golang-lru v0.5.4
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/magiconair/properties v1.8.7
github.com/odysseus/cache v0.0.0-00010101000000-000000000000
github.com/odysseus/mogo v0.0.0-00010101000000-000000000000
github.com/odysseus/odysseus-protocol v0.0.0-00010101000000-000000000000
github.com/odysseus/service-registry v0.0.0-00010101000000-000000000000
github.com/prometheus/client_golang v1.18.0
...
...
@@ -24,6 +25,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
go.mongodb.org/mongo-driver v1.15.0
golang.org/x/crypto v0.17.0
google.golang.org/grpc v1.60.1
)
...
...
@@ -57,6 +59,7 @@ require (
github.com/lestrrat-go/strftime v1.0.6 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/pkg/errors v0.9.1 // indirect
...
...
@@ -71,10 +74,15 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
...
...
@@ -89,3 +97,5 @@ replace github.com/odysseus/odysseus-protocol => ../odysseus-protocol
replace github.com/odysseus/cache => ../cache
replace github.com/odysseus/service-registry => ../service-registry
replace github.com/odysseus/mogo => ../mogo
go.sum
View file @
2ae53176
...
...
@@ -99,8 +99,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.
5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU
=
github.com/google/uuid v1.
5
.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.
6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0
=
github.com/google/uuid v1.
6
.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
...
...
@@ -169,6 +169,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
...
...
@@ -258,10 +260,20 @@ github.com/syndtr/goleveldb v0.0.0-20160425020131-cfa635847112/go.mod h1:Z4AUp2K
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/ugorji/go v0.0.0-20171122102828-84cb69a8af83/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ=
github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
go.mongodb.org/mongo-driver v1.15.0 h1:rJCKC8eEliewXjZGf0ddURtl7tTVy1TK3bfl0gkUSLc=
go.mongodb.org/mongo-driver v1.15.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
...
...
@@ -301,6 +313,7 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
...
...
@@ -325,6 +338,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
...
...
server/node.go
View file @
2ae53176
...
...
@@ -16,6 +16,7 @@ import (
"github.com/odysseus/service-registry/registry"
"github.com/redis/go-redis/v9"
log
"github.com/sirupsen/logrus"
"go.mongodb.org/mongo-driver/mongo"
"google.golang.org/grpc"
"net"
"strings"
...
...
@@ -32,6 +33,7 @@ type Node struct {
kafkaProducer
sarama
.
AsyncProducer
taskResultCh
chan
*
basev1
.
TaskReceipt
taskProofCh
chan
*
basev1
.
TaskProof
mogo
*
mongo
.
Client
}
func
NewNode
()
*
Node
{
...
...
@@ -41,6 +43,11 @@ func NewNode() *Node {
log
.
WithError
(
err
)
.
Error
(
"failed to parse node manager private key"
)
return
nil
}
mogo
,
err
:=
utils
.
ConnectMongoDB
(
config
.
GetConfig
()
.
Mongo
.
Url
,
config
.
GetConfig
()
.
Mongo
.
User
,
config
.
GetConfig
()
.
Mongo
.
Passwd
)
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"failed to connect mongodb"
)
return
nil
}
querier
:=
query
.
NewQuery
(
registry
.
RedisConnParam
{
Addr
:
redisConfig
.
Addr
,
...
...
@@ -86,6 +93,7 @@ func NewNode() *Node {
kafkaProducer
:
producer
,
taskResultCh
:
make
(
chan
*
basev1
.
TaskReceipt
,
100000
),
taskProofCh
:
make
(
chan
*
basev1
.
TaskProof
,
100000
),
mogo
:
mogo
,
}
node
.
wm
=
NewWorkerManager
(
rdb
,
node
)
...
...
server/workerManager.go
View file @
2ae53176
...
...
@@ -10,6 +10,7 @@ import (
"github.com/google/uuid"
lru
"github.com/hashicorp/golang-lru"
"github.com/odysseus/cache/cachedata"
"github.com/odysseus/mogo/operator"
"github.com/odysseus/nodemanager/config"
"github.com/odysseus/nodemanager/standardlib"
"github.com/odysseus/nodemanager/utils"
...
...
@@ -69,6 +70,9 @@ type WorkerManager struct {
node
NodeInterface
std
*
standardlib
.
StandardTasks
workerInfoOperator
*
operator
.
WorkerInfoOperator
workerInstalledOperator
*
operator
.
WorkerInstalledOperator
workerRunningOperator
*
operator
.
WorkerRunningOperator
}
func
NewWorkerManager
(
rdb
*
redis
.
Client
,
node
NodeInterface
)
*
WorkerManager
{
...
...
utils/mongodb.go
0 → 100644
View file @
2ae53176
package
utils
import
(
"context"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"time"
)
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
}
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