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

micro源码亮点借鉴 #39

Open
yudidi opened this issue Jul 8, 2020 · 3 comments
Open

micro源码亮点借鉴 #39

yudidi opened this issue Jul 8, 2020 · 3 comments

Comments

@yudidi
Copy link
Member

yudidi commented Jul 8, 2020

Micro In Action, Part 1: Getting Started

@yudidi
Copy link
Member Author

yudidi commented Jul 8, 2020

go-micro使用的Client, 有5个修改点

  1. var定义时设置 rpc client
  2. import包时, 执行init()设置 grpc client
  3. newService() 通过option参数修改
  4. Service接口.Init() 方法也可以修改。
  5. 程序启动时命令行修改

@yudidi
Copy link
Member Author

yudidi commented Jul 8, 2020

Golang 选项模式(Option模式)

使用场景

func newOptions(opts ...Option) Options {
	opt := Options{
		Auth:      auth.DefaultAuth,
		Broker:    broker.DefaultBroker,
		Cmd:       cmd.DefaultCmd,
		Config:    config.DefaultConfig,
		Client:    client.DefaultClient,
		Server:    server.DefaultServer,
		Store:     store.DefaultStore,
		Registry:  registry.DefaultRegistry,
		Runtime:   runtime.DefaultRuntime,
		Transport: transport.DefaultTransport,
		Context:   context.Background(),
		Signal:    true,
	}

	for _, o := range opts {
		o(&opt)
	}

	return opt
}

https://github.com/micro/go-micro/blob/a39e6515daae4897c00e5b218ee878ec408adec5/options.go#L50

Copy link
Member Author

yudidi commented Sep 28, 2020

There is currently no support for file upload
View in Slack

@yudidi yudidi closed this as completed Sep 28, 2020
@yudidi yudidi reopened this Sep 28, 2020
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

1 participant