add inner address into config
change algorithm for creating method path
This commit is contained in:
1 parent
7b7bccbca2
commit
c28e08d7a2
6 files changed
+27
-22
No files matched your search
Generated
+9
-8
@@ -191,7 +191,7 @@
|
||||
"utils",
|
||||
"validate"
|
||||
]
|
||||
revision = "df40f552115be0255f43f4392948da11b8dab243"
|
||||
revision = "7a0d3cf1d8e6946ac04491f9c85bbc556417505b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -201,7 +201,7 @@
|
||||
"blowfish",
|
||||
"ssh/terminal"
|
||||
]
|
||||
revision = "37a17fe027db43f76fd88b056ddf588563fc8722"
|
||||
revision = "7f39a6fea4fe9364fb61e1def6a268a51b4f3a06"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
@@ -224,7 +224,7 @@
|
||||
"unix",
|
||||
"windows"
|
||||
]
|
||||
revision = "56ede360ec1c541828fb88741b3f1049406d28f5"
|
||||
revision = "fc8bd948cf46f9c7af0f07d34151ce25fe90e477"
|
||||
|
||||
[[projects]]
|
||||
name = "golang.org/x/text"
|
||||
@@ -264,15 +264,16 @@
|
||||
"balancer",
|
||||
"balancer/base",
|
||||
"balancer/roundrobin",
|
||||
"channelz",
|
||||
"codes",
|
||||
"connectivity",
|
||||
"credentials",
|
||||
"encoding",
|
||||
"encoding/proto",
|
||||
"grpclb/grpc_lb_v1/messages",
|
||||
"grpclog",
|
||||
"internal",
|
||||
"internal/backoff",
|
||||
"internal/channelz",
|
||||
"internal/grpcrand",
|
||||
"keepalive",
|
||||
"metadata",
|
||||
"naming",
|
||||
@@ -285,8 +286,8 @@
|
||||
"tap",
|
||||
"transport"
|
||||
]
|
||||
revision = "7a6a684ca69eb4cae85ad0a484f2e531598c047b"
|
||||
version = "v1.12.2"
|
||||
revision = "168a6198bcb0ef175f7dacec0b8691fc141dc9b8"
|
||||
version = "v1.13.0"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/yaml.v2"
|
||||
@@ -297,6 +298,6 @@
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "b4a0e23a3531c09eeb5780b0fb2354448bca17f703b309b16487e2ad965f685a"
|
||||
inputs-digest = "04d0945c7a50967a960eb1c6d16be7a0ade6783b97332859a8223423ce092fe5"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
+4
-1
@@ -2,7 +2,10 @@ configServiceAddress:
|
||||
ip: "10.250.9.117"
|
||||
port: "9000"
|
||||
grpcOuterAddress:
|
||||
ip: "10.250.9.117"
|
||||
ip: "10.250.101.64"
|
||||
port: "9009"
|
||||
grpcInnerAddress:
|
||||
ip: "0.0.0.0"
|
||||
port: "9009"
|
||||
moduleName: "admin"
|
||||
instanceUuid: "bf482806-0c3d-4e0d-b9d4-12c037b12d70"
|
||||
@@ -3,6 +3,7 @@ package conf
|
||||
type Configuration struct {
|
||||
ConfigServiceAddress AddressConfiguration
|
||||
GrpcOuterAddress AddressConfiguration `valid:"required~Required" json:"grpcOuterAddress"`
|
||||
GrpcInnerAddress AddressConfiguration `valid:"required~Required" json:"grpcInnerAddress"`
|
||||
ModuleName string
|
||||
InstanceUuid string
|
||||
}
|
||||
|
||||
+7
-6
@@ -9,12 +9,13 @@ import (
|
||||
|
||||
type Handlers struct {
|
||||
// ===== AUTH =====
|
||||
Login func(structure.AuthRequest) (*structure.Auth, error) `method:"login" inner:"false"`
|
||||
Logout func(metadata.MD) error `method:"logout" inner:"true"`
|
||||
GetProfile func(metadata.MD) (*structure.AdminUserShort, error) `method:"get_profile" inner:"true"`
|
||||
GetUsers func(structure.UsersRequest) (*structure.UsersResponse, error) `method:"get_users" inner:"true"`
|
||||
CreateUpdateUser func(user libStr.AdminUser) (*libStr.AdminUser, error) `method:"create_update_user" inner:"true"`
|
||||
DeleteUser func(identities structure.IdentitiesRequest) (*structure.DeleteResponse, error) `method:"delete_user" inner:"true"`
|
||||
Login func(structure.AuthRequest) (*structure.Auth, error) `method:"login" group:"auth" inner:"false"`
|
||||
Logout func(metadata.MD) error `method:"logout" group:"auth" inner:"true"`
|
||||
// ===== USER =====
|
||||
GetProfile func(metadata.MD) (*structure.AdminUserShort, error) `method:"get_profile" group:"user" inner:"true"`
|
||||
GetUsers func(structure.UsersRequest) (*structure.UsersResponse, error) `method:"get_users" group:"user" inner:"true"`
|
||||
CreateUpdateUser func(user libStr.AdminUser) (*libStr.AdminUser, error) `method:"create_update_user" group:"user" inner:"true"`
|
||||
DeleteUser func(identities structure.IdentitiesRequest) (*structure.DeleteResponse, error) `method:"delete_user" group:"user" inner:"true"`
|
||||
}
|
||||
|
||||
func GetHandlers() *Handlers {
|
||||
|
||||
@@ -32,6 +32,7 @@ func init() {
|
||||
config.InitConfig(&conf.Configuration{})
|
||||
validLocalConfig()
|
||||
appConfig := config.Get().(*conf.Configuration)
|
||||
createGrpcServer()
|
||||
socket.InitClient(
|
||||
socket.SocketConfiguration{
|
||||
Host: appConfig.ConfigServiceAddress.IP,
|
||||
@@ -70,9 +71,9 @@ func main() {
|
||||
|
||||
// Start a GRPC server.
|
||||
func createGrpcServer() {
|
||||
remoteConfig := config.GetRemote().(*conf.RemoteConfig)
|
||||
addr := structure.AddressConfiguration{IP: remoteConfig.GrpcAddress.IP, Port: remoteConfig.GrpcAddress.Port}
|
||||
backend.StartBackendGrpcServer(addr, backend.GetDefaultService(remoteConfig.GrpcPrefix, helper.GetHandlers()))
|
||||
appConfig := config.Get().(*conf.Configuration)
|
||||
addr := structure.AddressConfiguration{IP: appConfig.GrpcInnerAddress.IP, Port: appConfig.GrpcInnerAddress.Port}
|
||||
backend.StartBackendGrpcServer(addr, backend.GetDefaultService(appConfig.ModuleName, helper.GetHandlers()))
|
||||
}
|
||||
|
||||
func validRemoteConfig(remoteConfig *conf.RemoteConfig) {
|
||||
@@ -113,8 +114,6 @@ func listenConfigChange() {
|
||||
localConfig := config.Get().(*conf.Configuration)
|
||||
remoteConfig := config.GetRemote().(*conf.RemoteConfig)
|
||||
|
||||
backend.StopGrpcServer()
|
||||
createGrpcServer()
|
||||
database.InitDb(remoteConfig.Database)
|
||||
|
||||
addrOuter := structure.AddressConfiguration{
|
||||
@@ -125,7 +124,7 @@ func listenConfigChange() {
|
||||
methods := backend.CreateBackendConfig(
|
||||
structure.ModuleInfo{ModuleName: localConfig.ModuleName, Version: version},
|
||||
addrOuter,
|
||||
remoteConfig.GrpcPrefix, helper.GetHandlers())
|
||||
localConfig.ModuleName, helper.GetHandlers())
|
||||
|
||||
bytes, err := json.Marshal(methods)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user