Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -22,6 +23,7 @@ jobs:
test:
name: Unit Tests
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -20,6 +21,7 @@ jobs:
test:
name: Unit Tests
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/go-orb/plugins/cli/tests
go 1.23.6

require (
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8
github.com/stretchr/testify v1.10.0
)

Expand Down
4 changes: 2 additions & 2 deletions cli/tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ github.com/cornelk/hashmap v1.0.8/go.mod h1:RfZb7JO3RviW/rT6emczVuC/oxpdz4UsSB2L
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e h1:/dzN721EqiJogdtjXVp0LBY2+daFm1p84PeB/fV9ya0=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8 h1:AoIUSRLgbOn+XNQu2nCV1xlwD33j3JgpUiMElOt7PgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down
2 changes: 1 addition & 1 deletion cli/urfave/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/go-orb/plugins/cli/urfave
go 1.23.6

require (
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8
github.com/hashicorp/go-multierror v1.1.1
github.com/stretchr/testify v1.10.0
github.com/urfave/cli/v2 v2.27.6
Expand Down
4 changes: 2 additions & 2 deletions cli/urfave/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6N
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e h1:/dzN721EqiJogdtjXVp0LBY2+daFm1p84PeB/fV9ya0=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8 h1:AoIUSRLgbOn+XNQu2nCV1xlwD33j3JgpUiMElOt7PgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
2 changes: 1 addition & 1 deletion client/middleware/log/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/go-orb/plugins/client/middleware/log

go 1.23.6

require github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e
require github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8

require (
dario.cat/mergo v1.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions client/middleware/log/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/cornelk/hashmap v1.0.8 h1:nv0AWgw02n+iDcawr5It4CjQIAcdMMKRrs10HOJYlrc=
github.com/cornelk/hashmap v1.0.8/go.mod h1:RfZb7JO3RviW/rT6emczVuC/oxpdz4UsSB2LJSclR1k=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e h1:/dzN721EqiJogdtjXVp0LBY2+daFm1p84PeB/fV9ya0=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8 h1:AoIUSRLgbOn+XNQu2nCV1xlwD33j3JgpUiMElOt7PgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion client/middleware/retry/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/go-orb/plugins/client/middleware/retry

go 1.23.6

require github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e
require github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8

require (
dario.cat/mergo v1.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions client/middleware/retry/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/cornelk/hashmap v1.0.8 h1:nv0AWgw02n+iDcawr5It4CjQIAcdMMKRrs10HOJYlrc=
github.com/cornelk/hashmap v1.0.8/go.mod h1:RfZb7JO3RviW/rT6emczVuC/oxpdz4UsSB2LJSclR1k=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e h1:/dzN721EqiJogdtjXVp0LBY2+daFm1p84PeB/fV9ya0=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8 h1:AoIUSRLgbOn+XNQu2nCV1xlwD33j3JgpUiMElOt7PgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
68 changes: 27 additions & 41 deletions client/orb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,54 +112,57 @@ func (c *Client) selectNode(ctx context.Context, service string, opts *client.Ca
}

// Resolve the service to a list of nodes in a per transport map.
nodes, err := c.resolveService(ctx, service, opts.PreferredTransports...)
nodes, err := c.resolveService(ctx, service, opts)
if err != nil {
c.Logger().Error("Failed to resolve service", "error", err, "service", service)
return "", "", err
}

// Run the configured Selector to get a node from the resolved nodes.
node, err := opts.Selector(ctx, service, nodes, opts.PreferredTransports, opts.AnyTransport)
node, err := opts.Selector(ctx, service, nodes)
if err != nil {
c.Logger().Error("Failed to resolve service", "error", err, "service", service)
return "", "", err
}

return node.Address, node.Transport, nil
return node.Address, node.Scheme, nil
}

// resolveService resolves a servicename to a Node with the help of the registry.
func (c *Client) resolveService(
_ context.Context,
service string,
preferredTransports ...string,
) (client.NodeMap, error) {
opts *client.CallOptions,
) ([]registry.ServiceNode, error) {
if service == "" {
return nil, client.ErrServiceArgumentEmpty
}

// Try to resolve the service with retries
var (
services []*registry.Service
services []registry.ServiceNode
err error
)

// Retry up to 3 times with a small delay between attempts
for retries := 0; retries < 1000; retries++ {
// Retry up to 5 times with a small delay between attempts
for retries := 0; retries < 5; retries++ {
if _, err := client.ResolveMemoryServer(service); err == nil {
rNodes := make(client.NodeMap)
rNodes["memory"] = []*registry.Node{
{
ID: "memory",
Address: "",
Transport: "memory",
},
}
rNodes := make([]registry.ServiceNode, 0)
rNodes = append(rNodes, registry.ServiceNode{
Name: service,
Scheme: "memory",
Address: "",
})

return rNodes, nil
}

services, err = c.registry.GetService(service)
if !opts.AnyTransport {
services, err = c.registry.GetService(context.Background(), opts.Namespace, opts.Region, service, nil)
} else {
services, err = c.registry.GetService(context.Background(), opts.Namespace, opts.Region, service, opts.PreferredTransports)
}

if err == nil && len(services) > 0 {
c.logger.Debug("service resolution successful", "service", service)
break // Service found, exit retry loop
Expand All @@ -178,32 +181,12 @@ func (c *Client) resolveService(
return nil, fmt.Errorf("no instances found for service: %s", service)
}

rNodes := make(client.NodeMap)

// Find nodes to query
for _, service := range services {
for _, node := range service.Nodes {
tNodes, ok := rNodes[node.Transport]
if !ok {
tNodes = []*registry.Node{}
}

tNodes = append(tNodes, node)
rNodes[node.Transport] = tNodes
}
}

// Not one node found.
if len(rNodes) == 0 {
return nil, fmt.Errorf("%w: requested transports was: %s", client.ErrNoNodeFound, preferredTransports)
}

return rNodes, nil
return services, nil
}

func (c *Client) makeOptions(opts ...client.CallOption) *client.CallOptions {
// Construct CallOptions, use the client's config as base.
co := &client.CallOptions{
callOpts := &client.CallOptions{
ContentType: c.config.Config.ContentType,
PreferredTransports: c.config.Config.PreferredTransports,
AnyTransport: c.config.Config.AnyTransport,
Expand All @@ -222,14 +205,17 @@ func (c *Client) makeOptions(opts ...client.CallOption) *client.CallOptions {
Retries: client.DefaultCallOptionsRetries,
MaxCallRecvMsgSize: client.DefaultMaxCallRecvMsgSize,
MaxCallSendMsgSize: client.DefaultMaxCallSendMsgSize,

Namespace: c.config.Config.Namespace,
Region: c.config.Config.Region,
}

// Apply options.
for _, o := range opts {
o(co)
o(callOpts)
}

return co
return callOpts
}

func (c *Client) transport(transport string) (Transport, error) {
Expand Down
2 changes: 1 addition & 1 deletion client/orb/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/go-orb/plugins/client/orb

go 1.23.6

require github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e
require github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8

require (
dario.cat/mergo v1.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions client/orb/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/cornelk/hashmap v1.0.8 h1:nv0AWgw02n+iDcawr5It4CjQIAcdMMKRrs10HOJYlrc=
github.com/cornelk/hashmap v1.0.8/go.mod h1:RfZb7JO3RviW/rT6emczVuC/oxpdz4UsSB2LJSclR1k=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e h1:/dzN721EqiJogdtjXVp0LBY2+daFm1p84PeB/fV9ya0=
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8 h1:AoIUSRLgbOn+XNQu2nCV1xlwD33j3JgpUiMElOt7PgM=
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8/go.mod h1:DBamAST285wD+Ydbil1HGl9X19Sj+0xR1ZqFzKDxOgM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
14 changes: 8 additions & 6 deletions client/orb_transport/drpc/drpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,26 @@ import (
fileproto "github.com/go-orb/plugins/client/tests/proto/file"

// Blank imports here are fine.
_ "github.com/go-orb/plugins-experimental/registry/mdns"
_ "github.com/go-orb/plugins/codecs/json"
_ "github.com/go-orb/plugins/codecs/proto"
_ "github.com/go-orb/plugins/codecs/yaml"
_ "github.com/go-orb/plugins/log/slog"
_ "github.com/go-orb/plugins/registry/mdns"
)

func setupServer(sn string) (*tests.SetupData, error) {
ctx, cancel := context.WithCancel(context.Background())

setupData := &tests.SetupData{}

sv := ""

logger, err := log.New()
logger, err := log.New(log.WithLevel(log.LevelDebug))
if err != nil {
cancel()

return nil, err
}

reg, err := registry.New(sn, sv, nil, &types.Components{}, logger)
reg, err := registry.New(nil, &types.Components{}, logger)
if err != nil {
cancel()

Expand All @@ -55,7 +53,11 @@ func setupServer(sn string) (*tests.SetupData, error) {
fileHInstance := new(filehandler.Handler)
fileHRegister := fileproto.RegisterFileServiceHandler(fileHInstance)

ep, err := drpc.New(drpc.NewConfig(drpc.WithHandlers(echoHRegister, fileHRegister)), logger, reg)
options := []server.Option{
drpc.WithHandlers(echoHRegister, fileHRegister),
}

ep, err := drpc.New(sn, "", drpc.NewConfig(options...), logger, reg)
if err != nil {
cancel()

Expand Down
30 changes: 16 additions & 14 deletions client/orb_transport/drpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,39 @@ module github.com/go-orb/plugins/client/orb_transport/drpc
go 1.23.6

require (
github.com/go-orb/go-orb v0.2.2-0.20250320223438-2869142c7d3e
github.com/go-orb/plugins-experimental/registry/mdns v0.0.0-20250320212500-13fd51a437b3
github.com/go-orb/plugins/client/orb v0.1.4-0.20250320235901-3af29c3a3b34
github.com/go-orb/plugins/client/tests v0.2.1-0.20250320235901-3af29c3a3b34
github.com/go-orb/plugins/codecs/json v0.1.1-0.20250320235901-3af29c3a3b34
github.com/go-orb/plugins/codecs/proto v0.1.1-0.20250320235901-3af29c3a3b34
github.com/go-orb/plugins/codecs/yaml v0.1.1-0.20250320235901-3af29c3a3b34
github.com/go-orb/plugins/log/slog v0.1.1-0.20250320235901-3af29c3a3b34
github.com/go-orb/plugins/server/drpc v0.1.1-0.20250320235901-3af29c3a3b34
github.com/go-orb/go-orb v0.2.2-0.20250324112306-5f5f154933b8
github.com/go-orb/plugins/client/orb v0.1.4-0.20250324122813-09813c7b9d65
github.com/go-orb/plugins/client/tests v0.2.1-0.20250324122813-09813c7b9d65
github.com/go-orb/plugins/codecs/json v0.1.1-0.20250324122813-09813c7b9d65
github.com/go-orb/plugins/codecs/proto v0.1.1-0.20250324122813-09813c7b9d65
github.com/go-orb/plugins/codecs/yaml v0.1.1-0.20250324122813-09813c7b9d65
github.com/go-orb/plugins/log/slog v0.1.1-0.20250324122813-09813c7b9d65
github.com/go-orb/plugins/registry/mdns v0.0.0-20250324122813-09813c7b9d65
github.com/go-orb/plugins/server/drpc v0.1.1-0.20250324122813-09813c7b9d65
github.com/stretchr/testify v1.10.0
google.golang.org/protobuf v1.36.5
google.golang.org/protobuf v1.36.6
storj.io/drpc v0.0.34
)

require (
dario.cat/mergo v1.0.1 // indirect
github.com/cornelk/hashmap v1.0.8 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/go-orb/plugins/server/http v0.1.1-0.20250320235901-3af29c3a3b34 // indirect
github.com/go-orb/plugins/server/memory v0.0.0-20250320235901-3af29c3a3b34 // indirect
github.com/go-orb/plugins/registry/regutil v0.1.1-0.20250324122813-09813c7b9d65 // indirect
github.com/go-orb/plugins/server/http v0.1.1-0.20250324122813-09813c7b9d65 // indirect
github.com/go-orb/plugins/server/memory v0.0.0-20250324122813-09813c7b9d65 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/lithammer/shortuuid/v3 v3.0.7 // indirect
github.com/miekg/dns v1.1.64 // indirect
github.com/onsi/ginkgo/v2 v2.23.2 // indirect
github.com/onsi/ginkgo/v2 v2.23.3 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/quic-go/qpack v0.5.1 // indirect
github.com/quic-go/quic-go v0.50.0 // indirect
github.com/quic-go/quic-go v0.50.1 // indirect
github.com/zeebo/errs v1.4.0 // indirect
go.uber.org/mock v0.5.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
Expand Down
Loading
Loading