1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/plugins/config/source/grpc
2021-11-11 14:03:34 +00:00
..
proto add all the plugins 2020-12-26 15:32:45 +00:00
go.mod upgrade to go 1.17 (#2346) 2021-11-11 14:03:34 +00:00
go.sum upgrade to go 1.17 (#2346) 2021-11-11 14:03:34 +00:00
grpc.go update 2021-10-13 13:31:23 +01:00
options.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
README.md add all the plugins 2020-12-26 15:32:45 +00:00
util.go update 2021-10-13 13:31:23 +01:00
watcher.go update 2021-10-13 13:31:23 +01:00

gRPC Source

The gRPC source reads from a gRPC server

Server

A gRPC source server should implement the Source proto interface.

service Source {
	rpc Read(ReadRequest) returns (ReadResponse) {};
	rpc Watch(WatchRequest) returns (stream WatchResponse) {};
}

New Source

Specify source with address and path

source := grpc.NewSource(
	// optionally specify server address; default to localhost:8080
	grpc.WithAddress("10.0.0.10:8500"),
	// optionally specify a path; defaults to /micro/config
	grpc.WithPath("/my/config/path"),
)

Load Source

Load the source into config

// Create new config
conf := config.NewConfig()

// Load file source
conf.Load(grpcSource)