Skip to content

Commit 84b7145

Browse files
committed
Added aliases for some types from internal folder
1 parent cb08a6e commit 84b7145

27 files changed

Lines changed: 159 additions & 79 deletions

attributes.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 RPCPlatform Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rpcplatform
18+
19+
import (
20+
"github.com/nexcode/rpcplatform/internal/attributes"
21+
)
22+
23+
// NewAttributes returns attributes with default values.
24+
func NewAttributes() *Attributes {
25+
return attributes.New()
26+
}
27+
28+
// Attributes provides server attribute values.
29+
type Attributes = attributes.Attributes

client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
)
2323

2424
type Client struct {
25+
id string
2526
target string
2627
client *grpc.ClientConn
2728
resolver *manual.Resolver
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
package serverinfo
17+
package rpcplatform
1818

19-
import (
20-
"github.com/nexcode/rpcplatform/attributes"
21-
)
22-
23-
type ServerInfo struct {
24-
Address string
25-
Attributes *attributes.Attributes
19+
// ID return the client identifier.
20+
func (c *Client) ID() string {
21+
return c.id
2622
}

client_updatestate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
package rpcplatform
1818

1919
import (
20-
"github.com/nexcode/rpcplatform/internal/serverinfo"
2120
"google.golang.org/grpc/attributes"
2221
"google.golang.org/grpc/resolver"
2322
)
2423

25-
func (c *Client) updateState(init bool, serverInfoTree map[string]*serverinfo.ServerInfo) {
24+
func (c *Client) updateState(init bool, serverInfoTree map[string]*ServerInfo) {
2625
state := resolver.State{
2726
Addresses: make([]resolver.Address, 0, len(serverInfoTree)),
2827
}

examples/attributes/client/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/nexcode/rpcplatform"
2626
"github.com/nexcode/rpcplatform/examples/quickstart/proto"
27-
"github.com/nexcode/rpcplatform/options"
2827
etcd "go.etcd.io/etcd/client/v3"
2928
"google.golang.org/grpc"
3029
"google.golang.org/grpc/credentials/insecure"
@@ -40,16 +39,16 @@ func main() {
4039
}
4140

4241
rpcp, err := rpcplatform.New("rpcplatform", etcdClient,
43-
options.Platform.ClientOptions(
44-
options.Client.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
42+
rpcplatform.PlatformOptions.ClientOptions(
43+
rpcplatform.ClientOptions.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
4544
),
4645
)
4746

4847
if err != nil {
4948
panic(err)
5049
}
5150

52-
client, err := rpcp.NewClient("server", options.Client.MaxActiveServers(2))
51+
client, err := rpcp.NewClient("server", rpcplatform.ClientOptions.MaxActiveServers(2))
5352
if err != nil {
5453
panic(err)
5554
}

examples/attributes/server/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import (
2121
"fmt"
2222

2323
"github.com/nexcode/rpcplatform"
24-
"github.com/nexcode/rpcplatform/attributes"
2524
"github.com/nexcode/rpcplatform/examples/quickstart/proto"
26-
"github.com/nexcode/rpcplatform/options"
2725
etcd "go.etcd.io/etcd/client/v3"
2826
)
2927

@@ -57,10 +55,10 @@ func main() {
5755
panic(err)
5856
}
5957

60-
attributes := attributes.New()
58+
attributes := rpcplatform.NewAttributes()
6159
attributes.BalancerWeight = 4
6260

63-
server, err := rpcp.NewServer("server", "localhost:", options.Server.Attributes(attributes))
61+
server, err := rpcp.NewServer("server", "localhost:", rpcplatform.ServerOptions.Attributes(attributes))
6462
if err != nil {
6563
panic(err)
6664
}

examples/opentelemetry/client/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/nexcode/rpcplatform"
2626
"github.com/nexcode/rpcplatform/examples/quickstart/proto"
27-
"github.com/nexcode/rpcplatform/options"
2827
etcd "go.etcd.io/etcd/client/v3"
2928
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
3029
"go.opentelemetry.io/otel/exporters/zipkin"
@@ -56,10 +55,10 @@ func main() {
5655
}
5756

5857
rpcp, err := rpcplatform.New("rpcplatform", etcdClient,
59-
options.Platform.ClientOptions(
60-
options.Client.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
58+
rpcplatform.PlatformOptions.ClientOptions(
59+
rpcplatform.ClientOptions.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
6160
),
62-
options.Platform.OpenTelemetry("client", 1, otlpExporter, zipkinExporter),
61+
rpcplatform.PlatformOptions.OpenTelemetry("client", 1, otlpExporter, zipkinExporter),
6362
)
6463

6564
if err != nil {

examples/opentelemetry/server/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
"github.com/nexcode/rpcplatform"
2424
"github.com/nexcode/rpcplatform/examples/quickstart/proto"
25-
"github.com/nexcode/rpcplatform/options"
2625
etcd "go.etcd.io/etcd/client/v3"
2726
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
2827
"go.opentelemetry.io/otel/exporters/zipkin"
@@ -68,7 +67,7 @@ func main() {
6867
}
6968

7069
rpcp, err := rpcplatform.New("rpcplatform", etcdClient,
71-
options.Platform.OpenTelemetry("server", 1, otlpExporter, zipkinExporter),
70+
rpcplatform.PlatformOptions.OpenTelemetry("server", 1, otlpExporter, zipkinExporter),
7271
)
7372

7473
if err != nil {

examples/quickstart/client/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/nexcode/rpcplatform"
2626
"github.com/nexcode/rpcplatform/examples/quickstart/proto"
27-
"github.com/nexcode/rpcplatform/options"
2827
etcd "go.etcd.io/etcd/client/v3"
2928
"google.golang.org/grpc"
3029
"google.golang.org/grpc/credentials/insecure"
@@ -40,8 +39,8 @@ func main() {
4039
}
4140

4241
rpcp, err := rpcplatform.New("rpcplatform", etcdClient,
43-
options.Platform.ClientOptions(
44-
options.Client.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
42+
rpcplatform.PlatformOptions.ClientOptions(
43+
rpcplatform.ClientOptions.GRPCOptions(grpc.WithTransportCredentials(insecure.NewCredentials())),
4544
),
4645
)
4746

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
package attributes
1818

19-
// New returns attributes with default values.
2019
func New() *Attributes {
2120
return &Attributes{
2221
BalancerWeight: 1,
2322
}
2423
}
2524

26-
// Attributes provides server attribute values.
2725
type Attributes struct {
2826
BalancerPriority int
2927
BalancerWeight int

0 commit comments

Comments
 (0)