Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
ichunt_golang_demo
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
de07543e
authored
Mar 01, 2021
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增微服务注册相关
parent
2b2334b1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
2 deletions
cmd/main.go
config/dev/proxy.toml
go.mod
go.sum
util/regist_etcd/regist.go
cmd/main.go
View file @
de07543e
...
@@ -2,7 +2,10 @@ package main
...
@@ -2,7 +2,10 @@ package main
import
(
import
(
"flag"
"flag"
"fmt"
"github.com/ichunt2019/cfg/lib"
"ichunt_golang/boot"
"ichunt_golang/boot"
"ichunt_golang/util/regist_etcd"
"os"
"os"
"os/signal"
"os/signal"
"syscall"
"syscall"
...
@@ -20,10 +23,14 @@ func main(){
...
@@ -20,10 +23,14 @@ func main(){
boot
.
Init
(
configPath
,
logPath
)
boot
.
Init
(
configPath
,
logPath
)
fmt
.
Println
(
lib
.
Instance
(
"proxy"
)
.
GetString
(
"micro_service_name"
))
go
func
()
{
go
func
()
{
router
.
HttpServerRun
()
router
.
HttpServerRun
()
}()
}()
regist_etcd
.
Init
()
quit
:=
make
(
chan
os
.
Signal
)
quit
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
quit
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
)
signal
.
Notify
(
quit
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
)
<-
quit
<-
quit
...
...
config/dev/proxy.toml
View file @
de07543e
# This is base config
#服务注册名称
micro_service_name
=
"golang_common_demo"
#etcd配置信息 etcd服务的ip端口用户密码
[etcd_config]
addrs
=
[
"192.168.2.232:2379"
]
username
=
""
password
=
""
#注册到etcd中的ip 端口 权重信息
[etcd_regist]
ip
=
"192.168.2.246"
port
=
60020
weight
=
10
[base]
[base]
debug_mode
=
"debug"
debug_mode
=
"debug"
...
...
go.mod
View file @
de07543e
...
@@ -4,11 +4,17 @@ go 1.14
...
@@ -4,11 +4,17 @@ go 1.14
require (
require (
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect
github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19 // indirect
github.com/gin-gonic/gin v1.6.3
github.com/gin-gonic/gin v1.6.3
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/ichunt2019/cfg v0.0.0-20210225081543-828ee9831d70
github.com/ichunt2019/cfg v0.0.0-20210225081543-828ee9831d70
github.com/ichunt2019/ichunt-micro-registry v1.0.1
github.com/ichunt2019/lxLog v0.0.0-20210226024426-781becb3c042
github.com/ichunt2019/lxLog v0.0.0-20210226024426-781becb3c042
github.com/spf13/viper v1.7.1
github.com/spf13/viper v1.7.1
github.com/tidwall/gjson v1.6.8 // indirect
github.com/tidwall/gjson v1.6.8 // indirect
google.golang.org/grpc/examples v0.0.0-20210226164526-c949703b4b98 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
)
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0
\ No newline at end of file
go.sum
View file @
de07543e
This diff is collapsed.
Click to expand it.
util/regist_etcd/regist.go
0 → 100644
View file @
de07543e
package
regist_etcd
import
(
"github.com/ichunt2019/ichunt-micro-registry/registry"
econfig
"github.com/ichunt2019/ichunt-micro-registry/config"
_
"github.com/ichunt2019/ichunt-micro-registry/registry/etcd"
"github.com/ichunt2019/cfg/lib"
)
func
Init
(){
nodes
:=
[]
*
registry
.
Node
{
{
IP
:
lib
.
Instance
(
"proxy"
)
.
GetString
(
"etcd_regist.ip"
),
Port
:
lib
.
Instance
(
"proxy"
)
.
GetInt
(
"etcd_regist.port"
),
Weight
:
lib
.
Instance
(
"proxy"
)
.
GetInt
(
"etcd_regist.weight"
),
},
}
etcdConfig
:=
registry
.
EtcdConfig
{
Address
:
lib
.
Instance
(
"proxy"
)
.
GetStringSlice
(
"etcd_config.addrs"
),
Username
:
lib
.
Instance
(
"proxy"
)
.
GetString
(
"etcd_config.username"
),
Password
:
lib
.
Instance
(
"proxy"
)
.
GetString
(
"etcd_config.password"
),
Path
:
"/ichuntMicroService/"
,
}
econfig
.
Register
(
lib
.
Instance
(
"proxy"
)
.
GetString
(
"micro_service_name"
),
etcdConfig
,
nodes
)
}
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