Skip to content

Commit 10efa2c

Browse files
committed
endpointsharding + pickfirst is used instead of base balancer
1 parent 2b5425b commit 10efa2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+654
-1216
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.png filter=lfs diff=lfs merge=lfs -text

README.md

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,83 @@ If there is no etcd in your infrastructure, you can install it from a
1414
[docker container](https://etcd.io/docs/v3.6/op-guide/container/) for tests:
1515

1616
```shell
17-
docker run -d \
18-
-p 2379:2379 \
19-
-p 2380:2380 \
20-
--name etcd gcr.io/etcd-development/etcd:v3.6.5 \
21-
/usr/local/bin/etcd \
22-
--name etcd \
23-
--initial-advertise-peer-urls http://127.0.0.1:2380 --listen-peer-urls http://0.0.0.0:2380 \
24-
--advertise-client-urls http://127.0.0.1:2379 --listen-client-urls http://0.0.0.0:2379 \
25-
--initial-cluster etcd=http://127.0.0.1:2380
17+
docker run -d --name etcd \
18+
-p 2379:2379 -p 2380:2380 \
19+
gcr.io/etcd-development/etcd:v3.6.5 /usr/local/bin/etcd \
20+
--name etcd --initial-cluster etcd=http://127.0.0.1:2380 \
21+
--initial-advertise-peer-urls http://127.0.0.1:2380 --listen-peer-urls http://0.0.0.0:2380 \
22+
--advertise-client-urls http://127.0.0.1:2379 --listen-client-urls http://0.0.0.0:2379
2623
```
2724

2825
Of course, you can use docker in production or install etcd using your favorite package manager.
2926
Just remember that the example above is for testing purposes!
3027

31-
## Usage examples
28+
## How does it work?
29+
30+
All you need to do is give your server a name. When it starts, it will automatically select a free port and run on it (unless you specify otherwise).
31+
All clients will connect to this server by its name. If there are multiple servers with the same name, load balancing will be performed between them.
32+
33+
> In the following code examples, error handling will be removed to improve readability. A pre-built [proto](examples/quickstart/proto) will also be used.
34+
35+
First, let's create a new `rpcplatform` instance:
36+
37+
```go
38+
rpcp, err := rpcplatform.New("rpcplatform", etcdClient,
39+
rpcplatform.PlatformOptions.ClientOptions(
40+
rpcplatform.ClientOptions.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
41+
),
42+
)
43+
````
44+
45+
Now let's create a new server named `myServerName`, give it the implementation of our `Sum` service and run it on the localhost (`sumServer` implementation will be omitted):
46+
47+
```go
48+
server, err := rpcp.NewServer("myServerName", "localhost:")
49+
proto.RegisterSumServer(server.Server(), &sumServer{})
50+
err = server.Serve()
51+
````
52+
53+
And finally, we create a client that connects to our `myServerName` (`sumClient` usage will be omitted):
54+
55+
```go
56+
client, err := rpcp.NewClient("myServerName")
57+
sumClient := proto.NewSumClient(client.Client())
58+
````
59+
60+
This is already enough for everything to work, we can add or remove copies of our server and add new clients — everything will work!
61+
But to see our **service graph** and get **telemetry for all gRPC methods**, we need to run containers with telemetry services and enable telemetry in `rpcplatform`.
62+
63+
Let's run containers with Zipkin and Jaeger:
64+
65+
```shell
66+
docker run -d --name zipkin -p 9411:9411 openzipkin/zipkin
67+
docker run -d --name jaeger -p 16686:16686 -p 4317:4317 jaegertracing/all-in-one
68+
```
69+
70+
Now let's create the necessary collectors and add `OpenTelemetry` option to the `rpcplatform` instance:
71+
72+
```go
73+
otlpExporter, err := otlptracegrpc.New(context.Background(),
74+
otlptracegrpc.WithEndpoint("localhost:4317"), otlptracegrpc.WithInsecure(),
75+
)
76+
77+
zipkinExporter, err := zipkin.New("http://localhost:9411/api/v2/spans")
78+
79+
rpcp, err := rpcplatform.New("rpcplatform", etcdClient,
80+
rpcplatform.PlatformOptions.ClientOptions(
81+
rpcplatform.ClientOptions.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
82+
),
83+
rpcplatform.PlatformOptions.OpenTelemetry("myServiceName", 1, otlpExporter, zipkinExporter),
84+
)
85+
````
86+
87+
The tracing system's web interface is available in a browser:
88+
89+
| Zipkin (`http://localhost:9411`) | Jaeger (`http://localhost:16686`) |
90+
| :------------------------------------------: | :------------------------------------------: |
91+
| ![Zipkin](examples/opentelemetry/zipkin.png) | ![Jaeger](examples/opentelemetry/jaeger.png) |
92+
93+
## Usage examples (with source code)
3294

3395
- [QuickStart](examples/quickstart): contains the simplest example without additional features
3496
- [OpenTelemetry](examples/opentelemetry): example with connecting distributed tracing systems

client_updatestate.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import (
2323

2424
func (c *Client) updateState(init bool, serverInfoTree map[string]*ServerInfo) {
2525
state := resolver.State{
26-
Addresses: make([]resolver.Address, 0, len(serverInfoTree)),
27-
// Attributes: grpcattrs.SetClientConfig(nil, c.config), // https://github.com/grpc/grpc-go/pull/8696
26+
Endpoints: make([]resolver.Endpoint, 0, len(serverInfoTree)),
27+
Attributes: grpcattrs.SetClientConfig(nil, c.config),
2828
}
2929

3030
for _, value := range serverInfoTree {
31-
state.Addresses = append(state.Addresses, resolver.Address{
32-
Addr: value.Address,
33-
Attributes: grpcattrs.SetClientConfig(grpcattrs.SetAttributes(nil, value.Attributes), c.config),
31+
state.Endpoints = append(state.Endpoints, resolver.Endpoint{
32+
Addresses: []resolver.Address{{Addr: value.Address}},
33+
Attributes: grpcattrs.SetAttributes(nil, value.Attributes),
3434
})
3535
}
3636

examples/attributes/README.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
## Adding attributes
22

3-
This example is very similar to [QuickStart](../quickstart), but now we will use additional attributes for server.
4-
5-
For the client, we will set the maximum number of active servers (all other servers above this value will be backup servers):
6-
7-
```go
8-
client, err := rpcp.NewClient("server", options.Client.MaxActiveServers(2))
9-
if err != nil {
10-
panic(err)
11-
}
12-
```
13-
14-
And for the server we will set the balancing weight attribute:
15-
16-
```go
17-
attributes := attributes.New()
18-
attributes.BalancerWeight = 4
19-
20-
server, err := rpcp.NewServer("server", "localhost:", options.Server.Attributes(attributes))
21-
if err != nil {
22-
panic(err)
23-
}
24-
```
3+
This example is very similar to [QuickStart](../quickstart), but now we will use additional attributes for the server and will receive them on every update in the channel.
254

265
## Launching this demo
276

@@ -42,8 +21,4 @@ go run .
4221

4322
## Additional comments
4423

45-
Currently there are two servers and one client running. If you launch another server, then one of the three servers will become a backup server, and the client will continue to interact with only two servers.
46-
47-
If we want active servers to be selected using priority, we can use the `BalancerPriority` option for server attributes.
48-
49-
Each server receives requests based on its weight, so by changing the value of `BalancerWeight` attribute we will distribute load the way we need.
24+
Currently there are two servers and one client running. If you launch another server, then one of the three servers will become a backup server, and the client will continue to interact with only two servers. If we want active servers to be selected using priority, we can use the `BalancerPriority` option for server attributes. Each server receives requests based on its weight, so by changing the value of `BalancerWeight` attribute we will distribute load the way we need.

examples/attributes/client/go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ replace github.com/nexcode/rpcplatform => ../../..
88

99
require (
1010
github.com/nexcode/rpcplatform v1.3.0
11-
go.etcd.io/etcd/client/v3 v3.6.5
12-
google.golang.org/grpc v1.76.0
11+
go.etcd.io/etcd/client/v3 v3.6.6
12+
google.golang.org/grpc v1.77.0
1313
)
1414

1515
require (
@@ -21,20 +21,20 @@ require (
2121
github.com/golang/protobuf v1.5.4 // indirect
2222
github.com/google/uuid v1.6.0 // indirect
2323
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
24-
go.etcd.io/etcd/api/v3 v3.6.5 // indirect
25-
go.etcd.io/etcd/client/pkg/v3 v3.6.5 // indirect
24+
go.etcd.io/etcd/api/v3 v3.6.6 // indirect
25+
go.etcd.io/etcd/client/pkg/v3 v3.6.6 // indirect
2626
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
2727
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
2828
go.opentelemetry.io/otel v1.38.0 // indirect
2929
go.opentelemetry.io/otel/metric v1.38.0 // indirect
3030
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
3131
go.opentelemetry.io/otel/trace v1.38.0 // indirect
3232
go.uber.org/multierr v1.11.0 // indirect
33-
go.uber.org/zap v1.27.0 // indirect
34-
golang.org/x/net v0.46.0 // indirect
35-
golang.org/x/sys v0.37.0 // indirect
36-
golang.org/x/text v0.30.0 // indirect
37-
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect
38-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
33+
go.uber.org/zap v1.27.1 // indirect
34+
golang.org/x/net v0.47.0 // indirect
35+
golang.org/x/sys v0.38.0 // indirect
36+
golang.org/x/text v0.31.0 // indirect
37+
google.golang.org/genproto/googleapis/api v0.0.0-20251124214823-79d6a2a48846 // indirect
38+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect
3939
google.golang.org/protobuf v1.36.10 // indirect
4040
)

examples/attributes/client/go.sum

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
2727
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
2828
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
2929
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
30-
go.etcd.io/etcd/api/v3 v3.6.5 h1:pMMc42276sgR1j1raO/Qv3QI9Af/AuyQUW6CBAWuntA=
31-
go.etcd.io/etcd/api/v3 v3.6.5/go.mod h1:ob0/oWA/UQQlT1BmaEkWQzI0sJ1M0Et0mMpaABxguOQ=
32-
go.etcd.io/etcd/client/pkg/v3 v3.6.5 h1:Duz9fAzIZFhYWgRjp/FgNq2gO1jId9Yae/rLn3RrBP8=
33-
go.etcd.io/etcd/client/pkg/v3 v3.6.5/go.mod h1:8Wx3eGRPiy0qOFMZT/hfvdos+DjEaPxdIDiCDUv/FQk=
34-
go.etcd.io/etcd/client/v3 v3.6.5 h1:yRwZNFBx/35VKHTcLDeO7XVLbCBFbPi+XV4OC3QJf2U=
35-
go.etcd.io/etcd/client/v3 v3.6.5/go.mod h1:ZqwG/7TAFZ0BJ0jXRPoJjKQJtbFo/9NIY8uoFFKcCyo=
30+
go.etcd.io/etcd/api/v3 v3.6.6 h1:mcaMp3+7JawWv69p6QShYWS8cIWUOl32bFLb6qf8pOQ=
31+
go.etcd.io/etcd/api/v3 v3.6.6/go.mod h1:f/om26iXl2wSkcTA1zGQv8reJRSLVdoEBsi4JdfMrx4=
32+
go.etcd.io/etcd/client/pkg/v3 v3.6.6 h1:uoqgzSOv2H9KlIF5O1Lsd8sW+eMLuV6wzE3q5GJGQNs=
33+
go.etcd.io/etcd/client/pkg/v3 v3.6.6/go.mod h1:YngfUVmvsvOJ2rRgStIyHsKtOt9SZI2aBJrZiWJhCbI=
34+
go.etcd.io/etcd/client/v3 v3.6.6 h1:G5z1wMf5B9SNexoxOHUGBaULurOZPIgGPsW6CN492ec=
35+
go.etcd.io/etcd/client/v3 v3.6.6/go.mod h1:36Qv6baQ07znPR3+n7t+Rk5VHEzVYPvFfGmfF4wBHV8=
3636
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
3737
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
3838
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 h1:YH4g8lQroajqUwWbq/tr2QX1JFmEXaDLgG+ew9bLMWo=
@@ -51,8 +51,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
5151
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
5252
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
5353
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
54-
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
55-
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
54+
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
55+
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
5656
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5757
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
5858
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -62,20 +62,20 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
6262
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6363
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6464
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
65-
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
66-
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
65+
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
66+
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
6767
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6868
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6969
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7070
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7171
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7272
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
73-
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
74-
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
73+
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
74+
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
7575
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
7676
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
77-
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
78-
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
77+
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
78+
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
7979
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
8080
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
8181
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -86,12 +86,12 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
8686
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
8787
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
8888
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
89-
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 h1:mepRgnBZa07I4TRuomDE4sTIYieg/osKmzIf4USdWS4=
90-
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8/go.mod h1:fDMmzKV90WSg1NbozdqrE64fkuTv6mlq2zxo9ad+3yo=
91-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 h1:M1rk8KBnUsBDg1oPGHNCxG4vc1f49epmTO7xscSajMk=
92-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
93-
google.golang.org/grpc v1.76.0 h1:UnVkv1+uMLYXoIz6o7chp59WfQUYA2ex/BXQ9rHZu7A=
94-
google.golang.org/grpc v1.76.0/go.mod h1:Ju12QI8M6iQJtbcsV+awF5a4hfJMLi4X0JLo94ULZ6c=
89+
google.golang.org/genproto/googleapis/api v0.0.0-20251124214823-79d6a2a48846 h1:ZdyUkS9po3H7G0tuh955QVyyotWvOD4W0aEapeGeUYk=
90+
google.golang.org/genproto/googleapis/api v0.0.0-20251124214823-79d6a2a48846/go.mod h1:Fk4kyraUvqD7i5H6S43sj2W98fbZa75lpZz/eUyhfO0=
91+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 h1:Wgl1rcDNThT+Zn47YyCXOXyX/COgMTIdhJ717F0l4xk=
92+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk=
93+
google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM=
94+
google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig=
9595
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
9696
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
9797
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

examples/attributes/client/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"fmt"
2223
"math/rand"
2324
"time"
@@ -48,7 +49,19 @@ func main() {
4849
panic(err)
4950
}
5051

51-
client, err := rpcp.NewClient("server", rpcplatform.ClientOptions.MaxActiveServers(2))
52+
lookup, err := rpcp.Lookup(context.Background(), "myServerName", true)
53+
if err != nil {
54+
panic(err)
55+
}
56+
57+
go func() {
58+
for {
59+
lookup, _ := json.MarshalIndent(<-lookup, "", " ")
60+
fmt.Printf("lookup: %s\n", lookup)
61+
}
62+
}()
63+
64+
client, err := rpcp.NewClient("myServerName", rpcplatform.ClientOptions.MaxActiveServers(2))
5265
if err != nil {
5366
panic(err)
5467
}

examples/attributes/server/go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ replace github.com/nexcode/rpcplatform => ../../..
88

99
require (
1010
github.com/nexcode/rpcplatform v1.3.0
11-
go.etcd.io/etcd/client/v3 v3.6.5
11+
go.etcd.io/etcd/client/v3 v3.6.6
12+
google.golang.org/grpc v1.77.0
1213
)
1314

1415
require (
@@ -20,21 +21,20 @@ require (
2021
github.com/golang/protobuf v1.5.4 // indirect
2122
github.com/google/uuid v1.6.0 // indirect
2223
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
23-
go.etcd.io/etcd/api/v3 v3.6.5 // indirect
24-
go.etcd.io/etcd/client/pkg/v3 v3.6.5 // indirect
24+
go.etcd.io/etcd/api/v3 v3.6.6 // indirect
25+
go.etcd.io/etcd/client/pkg/v3 v3.6.6 // indirect
2526
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
2627
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
2728
go.opentelemetry.io/otel v1.38.0 // indirect
2829
go.opentelemetry.io/otel/metric v1.38.0 // indirect
2930
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
3031
go.opentelemetry.io/otel/trace v1.38.0 // indirect
3132
go.uber.org/multierr v1.11.0 // indirect
32-
go.uber.org/zap v1.27.0 // indirect
33-
golang.org/x/net v0.46.0 // indirect
34-
golang.org/x/sys v0.37.0 // indirect
35-
golang.org/x/text v0.30.0 // indirect
36-
google.golang.org/genproto/googleapis/api v0.0.0-20251022142026-3a174f9686a8 // indirect
37-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251022142026-3a174f9686a8 // indirect
38-
google.golang.org/grpc v1.76.0 // indirect
33+
go.uber.org/zap v1.27.1 // indirect
34+
golang.org/x/net v0.47.0 // indirect
35+
golang.org/x/sys v0.38.0 // indirect
36+
golang.org/x/text v0.31.0 // indirect
37+
google.golang.org/genproto/googleapis/api v0.0.0-20251124214823-79d6a2a48846 // indirect
38+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect
3939
google.golang.org/protobuf v1.36.10 // indirect
4040
)

0 commit comments

Comments
 (0)