generated from go-kratos/kratos-layout
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e14f44
commit e8fbc55
Showing
20 changed files
with
325 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
package discovery | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/go-kratos/kratos/contrib/registry/nacos/v2" | ||
"github.com/go-kratos/kratos/v2/registry" | ||
"github.com/shiqinfeng1/goMono/app/common/client" | ||
) | ||
|
||
func MustNacosDiscovery(endpoint string) registry.Discovery { | ||
var ErrServiceKindInvaild = errors.New("service kind is invalid") | ||
|
||
func MustNacosDiscovery(endpoint string, kind string) registry.Discovery { | ||
c, err := client.NewNacosNamingClient(endpoint) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return nacos.New(c) | ||
if kind != "grpc" && kind != "http" { | ||
panic(ErrServiceKindInvaild) | ||
} | ||
return nacos.New(c, nacos.WithDefaultKind(kind)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
server: | ||
http: | ||
addr: ":{{bff_port}}" | ||
timeout: 1s | ||
# 本服务的服务注册地址 | ||
register: | ||
endpoints: | ||
- "{{bff_host}}:{{bff_port}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This is a gateway config. | ||
name: gateway-gomono | ||
version: v1.0.0 | ||
# 全局中间件 | ||
middlewares: | ||
- name: tracing | ||
options: | ||
'@type': type.googleapis.com/gateway.middleware.tracing.v1.Tracing | ||
httpEndpoint: '192.168.72.84:4318' # default opentelemetry collector port | ||
insecure: true | ||
- name: logging | ||
- name: transcoder | ||
- name: cors | ||
options: | ||
'@type': type.googleapis.com/gateway.middleware.cors.v1.Cors | ||
allowCredentials: true | ||
allowOrigins: | ||
- .google.com | ||
allowMethods: | ||
- GET | ||
- POST | ||
- OPTIONS | ||
endpoints: | ||
- path: /demo/v1/* | ||
timeout: 1s | ||
# 业务服务使用的通信协议 | ||
protocol: HTTP | ||
# 请求域名 | ||
# host: localhost | ||
backends: | ||
- target: 'discovery:///bff.http' | ||
weight: 100 | ||
# - target: '192.168.72.84:8200' | ||
# 各个endpoint的中间件 | ||
middlewares: | ||
- name: circuitbreaker | ||
options: | ||
'@type': type.googleapis.com/gateway.middleware.circuitbreaker.v1.CircuitBreaker | ||
successRatio: {"success":0.6, "request":"1", "bucket":"10", "window":"3s"} | ||
backupService: {"endpoint":{"backends":[{"target":"127.0.0.1:8001"}]}} | ||
assertCondtions: | ||
- {"by_status_code":"200"} | ||
- name: rewrite | ||
options: | ||
'@type': type.googleapis.com/gateway.middleware.rewrite.v1.Rewrite | ||
retry: | ||
attempts: 3 | ||
perTryTimeout: 0.1s | ||
conditions: | ||
- byStatusCode: '502-504' | ||
- byHeader: | ||
name: 'Grpc-Status' | ||
value: '14' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
public: | ||
adapter: | ||
database: | ||
driver: mysql | ||
source: "root:root@tcp(192.168.72.84:23306)/test" | ||
redis: | ||
addr: 127.0.0.1:26379 | ||
read_timeout: 0.2s | ||
write_timeout: 0.2s | ||
log: | ||
level: debug | ||
monitor: | ||
endpoint: tcp://127.0.0.1:23224 | ||
file: | ||
max_size: 100 # megabytes | ||
max_backups: 7 # file numbers | ||
max_age: 28 # days | ||
compress: true | ||
|
||
registry: | ||
addrs: | ||
- "192.168.72.84:8848" | ||
- "192.168.72.84:8858" | ||
- "192.168.72.84:8868" | ||
trace: | ||
endpoint: "192.168.72.84:4318" | ||
|
||
discovery: | ||
endpoints: | ||
- "192.168.72.84:8848" | ||
|
||
gateway_register: | ||
endpoints: | ||
- "192.168.72.84:8180" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
server: | ||
grpc: | ||
addr: "0.0.0.0:{{biz_trainer_port}}" | ||
timeout: 1s | ||
# 本服务的服务注册地址 | ||
register: | ||
endpoints: | ||
- "{{biz_trainer_host}}:{{biz_trainer_port}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
server: | ||
grpc: | ||
addr: "0.0.0.0:{{biz_training_port}}" | ||
timeout: 1s | ||
# 本服务的服务注册地址 | ||
register: | ||
endpoints: | ||
- "{{biz_training_host}}:{{biz_training_port}}" |