Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wei.xuan
getty
Commits
222f82f0
Commit
222f82f0
authored
Aug 19, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add: use multiple service config
parent
8b875c4a
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
244 additions
and
145 deletions
+244
-145
change_log.md
micro/change_log.md
+7
-3
config.go
micro/server/app/config.go
+22
-8
server.go
micro/server/app/server.go
+0
-3
version.go
micro/server/app/version.go
+1
-1
app.properties
micro/server/assembly/common/app.properties
+1
-1
config.toml
micro/server/profiles/dev/config.toml
+0
-43
config.yml
micro/server/profiles/dev/config.yml
+71
-0
config.toml
micro/server/profiles/release/config.toml
+0
-43
config.yml
micro/server/profiles/release/config.yml
+71
-0
config.toml
micro/server/profiles/test/config.toml
+0
-43
config.yml
micro/server/profiles/test/config.yml
+71
-0
No files found.
micro/change_log.md
View file @
222f82f0
#
rpc
#
#
Micro
#
---
---
*getty
rpc
examples*
*getty
micro
examples*
## LICENSE ##
## LICENSE ##
---
---
...
@@ -10,6 +10,10 @@
...
@@ -10,6 +10,10 @@
## develop history ##
## develop history ##
---
---
-
2018/08/06
-
2018/08/19
> Feature
*
use multiple service config
-
2018/08/13
> Init
> Init
*
add client/server
*
add client/server
micro/server/app/config.go
View file @
222f82f0
...
@@ -11,6 +11,7 @@ package main
...
@@ -11,6 +11,7 @@ package main
import
(
import
(
"fmt"
"fmt"
"io/ioutil"
"os"
"os"
"path"
"path"
)
)
...
@@ -18,9 +19,10 @@ import (
...
@@ -18,9 +19,10 @@ import (
import
(
import
(
"github.com/AlexStocks/getty/micro"
"github.com/AlexStocks/getty/micro"
"github.com/AlexStocks/getty/rpc"
"github.com/AlexStocks/getty/rpc"
"github.com/AlexStocks/goext/log"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
jerrors
"github.com/juju/errors"
jerrors
"github.com/juju/errors"
config
"github.com/koding/multiconfig
"
"gopkg.in/yaml.v2
"
)
)
const
(
const
(
...
@@ -29,8 +31,8 @@ const (
...
@@ -29,8 +31,8 @@ const (
)
)
type
microConfig
struct
{
type
microConfig
struct
{
rpc
.
ServerConfig
rpc
.
ServerConfig
`yaml:"core" json:"core, omitempty"`
Registry
micro
.
RegistryConfig
Registry
micro
.
ProviderRegistryConfig
`yaml:"registry" json:"registry, omitempty"`
}
}
var
(
var
(
...
@@ -44,12 +46,25 @@ func initConf() {
...
@@ -44,12 +46,25 @@ func initConf() {
panic
(
fmt
.
Sprintf
(
"application configure file name is nil"
))
panic
(
fmt
.
Sprintf
(
"application configure file name is nil"
))
return
// I know it is of no usage. Just Err Protection.
return
// I know it is of no usage. Just Err Protection.
}
}
if
path
.
Ext
(
confFile
)
!=
".
to
ml"
{
if
path
.
Ext
(
confFile
)
!=
".
y
ml"
{
panic
(
fmt
.
Sprintf
(
"application configure file name{%v} suffix must be .
to
ml"
,
confFile
))
panic
(
fmt
.
Sprintf
(
"application configure file name{%v} suffix must be .
y
ml"
,
confFile
))
return
return
}
}
conf
=
&
microConfig
{}
conf
=
&
microConfig
{}
config
.
MustLoadWithPath
(
confFile
,
conf
)
confFileStream
,
err
:=
ioutil
.
ReadFile
(
confFile
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"ioutil.ReadFile(file:%s) = error:%s"
,
confFile
,
jerrors
.
ErrorStack
(
err
)))
return
}
err
=
yaml
.
Unmarshal
(
confFileStream
,
conf
)
if
err
!=
nil
{
panic
(
fmt
.
Sprintf
(
"yaml.Unmarshal() = error:%s"
,
jerrors
.
ErrorStack
(
err
)))
return
}
gxlog
.
CError
(
"conf:%#v"
,
conf
)
if
err
:=
conf
.
ServerConfig
.
CheckValidity
();
err
!=
nil
{
if
err
:=
conf
.
ServerConfig
.
CheckValidity
();
err
!=
nil
{
panic
(
jerrors
.
ErrorStack
(
err
))
panic
(
jerrors
.
ErrorStack
(
err
))
return
return
...
@@ -58,8 +73,7 @@ func initConf() {
...
@@ -58,8 +73,7 @@ func initConf() {
panic
(
jerrors
.
ErrorStack
(
err
))
panic
(
jerrors
.
ErrorStack
(
err
))
return
return
}
}
// log
// log
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
confFile
=
os
.
Getenv
(
APP_LOG_CONF_FILE
)
if
confFile
==
""
{
if
confFile
==
""
{
...
...
micro/server/app/server.go
View file @
222f82f0
...
@@ -21,7 +21,6 @@ import (
...
@@ -21,7 +21,6 @@ import (
import
(
import
(
"github.com/AlexStocks/getty-examples/micro/proto"
"github.com/AlexStocks/getty-examples/micro/proto"
"github.com/AlexStocks/getty/micro"
"github.com/AlexStocks/getty/micro"
"github.com/AlexStocks/goext/log"
"github.com/AlexStocks/goext/net"
"github.com/AlexStocks/goext/net"
log
"github.com/AlexStocks/log4go"
log
"github.com/AlexStocks/log4go"
jerrors
"github.com/juju/errors"
jerrors
"github.com/juju/errors"
...
@@ -41,8 +40,6 @@ func main() {
...
@@ -41,8 +40,6 @@ func main() {
initProfiling
()
initProfiling
()
initServer
()
initServer
()
gxlog
.
CInfo
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
log
.
Info
(
"%s starts successfull! its version=%s, its listen ends=%s:%s
\n
"
,
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
conf
.
AppName
,
Version
,
conf
.
Host
,
conf
.
Ports
)
...
...
micro/server/app/version.go
View file @
222f82f0
...
@@ -10,5 +10,5 @@
...
@@ -10,5 +10,5 @@
package
main
package
main
var
(
var
(
Version
=
"1.0.
1
"
Version
=
"1.0.
2
"
)
)
micro/server/assembly/common/app.properties
View file @
222f82f0
...
@@ -12,6 +12,6 @@
...
@@ -12,6 +12,6 @@
export
TARGET_EXEC_NAME
=
"micro_server"
export
TARGET_EXEC_NAME
=
"micro_server"
export
BUILD_PACKAGE
=
"app"
export
BUILD_PACKAGE
=
"app"
export
TARGET_CONF_FILE
=
"conf/config.
to
ml"
export
TARGET_CONF_FILE
=
"conf/config.
y
ml"
export
TARGET_LOG_CONF_FILE
=
"conf/log.xml"
export
TARGET_LOG_CONF_FILE
=
"conf/log.xml"
micro/server/profiles/dev/config.toml
deleted
100644 → 0
View file @
8b875c4a
# toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
AppName
=
"MICRO-SERVER"
Host
=
"127.0.0.1"
Ports
=
[
"10000"
,
"20000"
]
ProfilePort
=
10086
# client与server之间连接的超时时间
SessionTimeout
=
"20s"
SessionNumber
=
700
# app
FailFastTimeout
=
"3s"
# tcp
[GettySessionParam]
CompressEncoding
=
true
TcpNoDelay
=
true
TcpKeepAlive
=
true
KeepAlivePeriod
=
"120s"
TcpRBufSize
=
262144
TcpWBufSize
=
524288
PkgRQSize
=
1024
PkgWQSize
=
512
TcpReadTimeout
=
"1s"
TcpWriteTimeout
=
"5s"
WaitTimeout
=
"1s"
MaxMsgLen
=
1024
SessionName
=
"getty-micro-server"
[Registry]
Type
=
"zookeeper"
Addr
=
"127.0.0.1:2181"
# 与 registry 之间的 lease 时长
KeepaliveTimeout
=
10
Root
=
"/getty-root"
IDC
=
"bj-yizhuang"
NodeID
=
"srv-node1"
Codec
=
"protobuf"
\ No newline at end of file
micro/server/profiles/dev/config.yml
0 → 100644
View file @
222f82f0
core
:
app_name
:
"
MICRO-SERVER"
host
:
"
127.0.0.1"
ports
:
[
"
10000"
,
"
20000"
]
profile_port
:
10086
# client与server之间连接的超时时间
session_timeout
:
"
20s"
session_number
:
700
fail_fast_timeout
:
"
3s"
# tcp
getty_session_param
:
compress_encoding
:
true
tcp_no_delay
:
true
tcp_keep_alive
:
true
keep_alive_period
:
"
120s"
tcp_r_buf_size
:
262144
tcp_w_buf_size
:
524288
pkg_rq_size
:
1024
pkg_wq_size
:
512
tcp_read_timeout
:
"
1s"
tcp_write_timeout
:
"
5s"
wait_timeout
:
"
1s"
max_msg_len
:
1024
session_name
:
"
getty-micro-server"
registry
:
basic
:
type
:
"
zookeeper"
reg_addr
:
"
127.0.0.1:2181"
# 与 registry 之间的 lease 时长
keepalive_timeout
:
10
root
:
"
/getty"
service_array
:
-
local_host
:
"
127.0.0.1"
local_port
:
10000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:10000-pb"
protocol
:
"
protobuf"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
20000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:20000-pb"
protocol
:
"
protobuf"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
10000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:10000-json"
protocol
:
"
json"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
20000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:20000-json"
protocol
:
"
json"
service
:
"
TestService"
version
:
"
v1.0"
\ No newline at end of file
micro/server/profiles/release/config.toml
deleted
100644 → 0
View file @
8b875c4a
# toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
AppName
=
"MICRO-SERVER"
Host
=
"127.0.0.1"
Ports
=
[
"10000"
,
"20000"
]
ProfilePort
=
10086
# client与server之间连接的超时时间
SessionTimeout
=
"20s"
SessionNumber
=
700
# app
FailFastTimeout
=
"3s"
# tcp
[GettySessionParam]
CompressEncoding
=
true
TcpNoDelay
=
true
TcpKeepAlive
=
true
KeepAlivePeriod
=
"120s"
TcpRBufSize
=
262144
TcpWBufSize
=
524288
PkgRQSize
=
1024
PkgWQSize
=
512
TcpReadTimeout
=
"1s"
TcpWriteTimeout
=
"5s"
WaitTimeout
=
"1s"
MaxMsgLen
=
1024
SessionName
=
"getty-micro-server"
[Registry]
Type
=
"zookeeper"
Addr
=
"127.0.0.1:2181"
# 与 registry 之间的 lease 时长
KeepaliveTimeout
=
10
Root
=
"/getty-root"
IDC
=
"bj-yizhuang"
NodeID
=
"srv-node1"
Codec
=
"protobuf"
\ No newline at end of file
micro/server/profiles/release/config.yml
0 → 100644
View file @
222f82f0
core
:
app_name
:
"
MICRO-SERVER"
host
:
"
127.0.0.1"
ports
:
[
"
10000"
,
"
20000"
]
profile_port
:
10086
# client与server之间连接的超时时间
session_timeout
:
"
20s"
session_number
:
700
fail_fast_timeout
:
"
3s"
# tcp
getty_session_param
:
compress_encoding
:
true
tcp_no_delay
:
true
tcp_keep_alive
:
true
keep_alive_period
:
"
120s"
tcp_r_buf_size
:
262144
tcp_w_buf_size
:
524288
pkg_rq_size
:
1024
pkg_wq_size
:
512
tcp_read_timeout
:
"
1s"
tcp_write_timeout
:
"
5s"
wait_timeout
:
"
1s"
max_msg_len
:
1024
session_name
:
"
getty-micro-server"
registry
:
basic
:
type
:
"
zookeeper"
reg_addr
:
"
127.0.0.1:2181"
# 与 registry 之间的 lease 时长
keepalive_timeout
:
10
root
:
"
/getty"
service_array
:
-
local_host
:
"
127.0.0.1"
local_port
:
10000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:10000-pb"
protocol
:
"
protobuf"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
20000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:20000-pb"
protocol
:
"
protobuf"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
10000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:10000-json"
protocol
:
"
json"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
20000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:20000-json"
protocol
:
"
json"
service
:
"
TestService"
version
:
"
v1.0"
\ No newline at end of file
micro/server/profiles/test/config.toml
deleted
100644 → 0
View file @
8b875c4a
# toml configure file
# toml中key的首字母可以小写,但是对应的golang中的struct成员首字母必须大写
AppName
=
"MICRO-SERVER"
Host
=
"127.0.0.1"
Ports
=
[
"10000"
,
"20000"
]
ProfilePort
=
10086
# client与server之间连接的超时时间
SessionTimeout
=
"20s"
SessionNumber
=
700
# app
FailFastTimeout
=
"3s"
# tcp
[GettySessionParam]
CompressEncoding
=
true
TcpNoDelay
=
true
TcpKeepAlive
=
true
KeepAlivePeriod
=
"120s"
TcpRBufSize
=
262144
TcpWBufSize
=
524288
PkgRQSize
=
1024
PkgWQSize
=
512
TcpReadTimeout
=
"1s"
TcpWriteTimeout
=
"5s"
WaitTimeout
=
"1s"
MaxMsgLen
=
1024
SessionName
=
"getty-micro-server"
[Registry]
Type
=
"zookeeper"
Addr
=
"127.0.0.1:2181"
# 与 registry 之间的 lease 时长
KeepaliveTimeout
=
10
Root
=
"/getty-root"
IDC
=
"bj-yizhuang"
NodeID
=
"srv-node1"
Codec
=
"protobuf"
\ No newline at end of file
micro/server/profiles/test/config.yml
0 → 100644
View file @
222f82f0
core
:
app_name
:
"
MICRO-SERVER"
host
:
"
127.0.0.1"
ports
:
[
"
10000"
,
"
20000"
]
profile_port
:
10086
# client与server之间连接的超时时间
session_timeout
:
"
20s"
session_number
:
700
fail_fast_timeout
:
"
3s"
# tcp
getty_session_param
:
compress_encoding
:
true
tcp_no_delay
:
true
tcp_keep_alive
:
true
keep_alive_period
:
"
120s"
tcp_r_buf_size
:
262144
tcp_w_buf_size
:
524288
pkg_rq_size
:
1024
pkg_wq_size
:
512
tcp_read_timeout
:
"
1s"
tcp_write_timeout
:
"
5s"
wait_timeout
:
"
1s"
max_msg_len
:
1024
session_name
:
"
getty-micro-server"
registry
:
basic
:
type
:
"
zookeeper"
reg_addr
:
"
127.0.0.1:2181"
# 与 registry 之间的 lease 时长
keepalive_timeout
:
10
root
:
"
/getty"
service_array
:
-
local_host
:
"
127.0.0.1"
local_port
:
10000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:10000-pb"
protocol
:
"
protobuf"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
20000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:20000-pb"
protocol
:
"
protobuf"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
10000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:10000-json"
protocol
:
"
json"
service
:
"
TestService"
version
:
"
v1.0"
-
local_host
:
"
127.0.0.1"
local_port
:
20000
group
:
"
bj-yizhuang"
node_id
:
"
srv-node-127.0.0.1:20000-json"
protocol
:
"
json"
service
:
"
TestService"
version
:
"
v1.0"
\ No newline at end of file
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