Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web 网关 模式 #88

Closed
cashwar3 opened this issue Apr 1, 2021 · 6 comments
Closed

web 网关 模式 #88

cashwar3 opened this issue Apr 1, 2021 · 6 comments

Comments

@cashwar3
Copy link

cashwar3 commented Apr 1, 2021

可否提供一下,web作为网关的demo呢?
初始化传输模式为grpc是怎么处理的呢?

@cashwar3 cashwar3 changed the title stream 模式 web 网关 模式 Apr 7, 2021
@printfcoder
Copy link
Member

web作为网关?网关本身就是http的,把http向下转成rpc。

网关启动时transport=grpc即可,下游服务也一样启动方式。

@printfcoder
Copy link
Member

@printfcoder
Copy link
Member

@cashwar3
Copy link
Author

没有找到具体demo.
我的这边具体代码如下:
service := stack.NewWebService(...)
if err := service.Init(); err != nil {
panic(err)
}

/*
	转换为grpc
*/
//micro1.8版本:service.Options().Service.Init(micro.Transport(grpc.NewTransport()))
//stack怎么转换呢?

client := protoConfig.NewConfigService("go.micro.srv.exam", service.Client())

@printfcoder
Copy link
Member

目前不支持web应用直接把transport替换成grpc的,可以另行声明一个客户端

	rpcClient := grpc.NewClient(
		client.Registry(s.Options().Registry),
		// ...
	)
	// 创建客户端
	greeter := proto.NewGreeterService("stack.rpc.greeter", rpcClient)

@cashwar3
Copy link
Author

谢谢,舒大,我这边试一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants