Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
ichunt-micro-v2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
de4fe148
authored
Jan 12, 2021
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
87d003c3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
0 deletions
conf/prod/base.toml
main.go
registry/etcd/etcd.go
registry/options.go
conf/prod/base.toml
View file @
de4fe148
...
...
@@ -23,4 +23,5 @@
addrs
=
[
"192.168.2.232:2379"
]
username
=
""
password
=
""
main.go
View file @
de4fe148
...
...
@@ -26,6 +26,7 @@ func registryEtcd(){
//registry.WithAddrs([]string{"192.168.2.232:2379"}),
registry
.
WithAddrs
(
lib
.
GetStringSliceConf
(
"base.etcd.addrs"
)),
registry
.
WithTimeout
(
5
*
time
.
Second
),
registry
.
WithUsername
(
"base.etcd.username"
),
registry
.
WithPasswrod
(
"base.etcd.password"
),
registry
.
WithRegistryPath
(
"/ichuntMicroService/"
),
registry
.
WithHeartBeat
(
5
),
...
...
registry/etcd/etcd.go
View file @
de4fe148
...
...
@@ -82,6 +82,8 @@ func (e *EtcdRegistry) Init(ctx context.Context, opts ...registry.Option) (err e
Endpoints
:
e
.
options
.
Addrs
,
DialTimeout
:
e
.
options
.
Timeout
,
Password
:
e
.
options
.
Password
,
Username
:
e
.
options
.
Username
,
}
e
.
client
,
err
=
clientv3
.
New
(
clientConfig
)
...
...
registry/options.go
View file @
de4fe148
...
...
@@ -7,6 +7,7 @@ import (
type
Options
struct
{
Addrs
[]
string
Timeout
time
.
Duration
Username
string
Password
string
// example: /xxx_company/app/kuaishou/service_A/10.192.1.1:8801
// example: /xxx_company/app/kuaishou/service_A/10.192.1.2:8801
...
...
@@ -34,6 +35,12 @@ func WithPasswrod(password string) Option {
}
}
func
WithUsername
(
username
string
)
Option
{
return
func
(
opts
*
Options
)
{
opts
.
Username
=
username
}
}
func
WithRegistryPath
(
path
string
)
Option
{
return
func
(
opts
*
Options
)
{
opts
.
RegistryPath
=
path
...
...
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