-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[full-ci] enhancement: use reva client pool selectors (#6452)
* enhancement: use reva client pool selectors register mock service to registry and pass tests * enhancement: bump reva * Fix a couple of linter issues --------- Co-authored-by: Ralf Haferkamp <[email protected]>
- Loading branch information
Showing
157 changed files
with
2,834 additions
and
1,890 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Enhancement: Use reva client selectors | ||
|
||
Use reva client selectors instead of the static clients, this introduces the ocis service registry in reva. | ||
The service discovery now resolves reva services by name and the client selectors pick a random registered service node. | ||
|
||
https://github.com/owncloud/ocis/pull/6452 | ||
https://github.com/cs3org/reva/pull/3939 | ||
https://github.com/cs3org/reva/pull/3953 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package registry | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/owncloud/ocis/v2/ocis-pkg/log" | ||
mRegistry "go-micro.dev/v4/registry" | ||
) | ||
|
||
// RegisterService publishes an arbitrary endpoint to the service-registry. This allows querying nodes of | ||
// non-micro services like reva. No health-checks are done, thus the caller is responsible for canceling. | ||
func RegisterService(ctx context.Context, service *mRegistry.Service, logger log.Logger) error { | ||
registry := GetRegistry() | ||
node := service.Nodes[0] | ||
|
||
logger.Info().Msgf("registering external service %v@%v", node.Id, node.Address) | ||
|
||
rOpts := []mRegistry.RegisterOption{mRegistry.RegisterTTL(time.Minute)} | ||
if err := registry.Register(service, rOpts...); err != nil { | ||
logger.Fatal().Err(err).Msgf("Registration error for external service %v", service.Name) | ||
} | ||
|
||
t := time.NewTicker(time.Second * 30) | ||
|
||
go func() { | ||
for { | ||
select { | ||
case <-t.C: | ||
logger.Debug().Interface("service", service).Msg("refreshing external service-registration") | ||
err := registry.Register(service, rOpts...) | ||
if err != nil { | ||
logger.Error().Err(err).Msgf("registration error for external service %v", service.Name) | ||
} | ||
case <-ctx.Done(): | ||
logger.Debug().Interface("service", service).Msg("unregistering") | ||
t.Stop() | ||
err := registry.Deregister(service) | ||
if err != nil { | ||
logger.Err(err).Msgf("Error unregistering external service %v", service.Name) | ||
} | ||
} | ||
} | ||
}() | ||
|
||
return nil | ||
} |
2 changes: 1 addition & 1 deletion
2
ocis-pkg/service/external/external_test.go → ocis-pkg/registry/register_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package external | ||
package registry | ||
|
||
// | ||
//import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package registry | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"strconv" | ||
"strings" | ||
|
||
mRegistry "go-micro.dev/v4/registry" | ||
"go-micro.dev/v4/util/addr" | ||
) | ||
|
||
func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistry.Service { | ||
var host string | ||
var port int | ||
|
||
parts := strings.Split(address, ":") | ||
if len(parts) > 1 { | ||
host = strings.Join(parts[:len(parts)-1], ":") | ||
port, _ = strconv.Atoi(parts[len(parts)-1]) | ||
} else { | ||
host = parts[0] | ||
} | ||
|
||
addr, err := addr.Extract(host) | ||
if err != nil { | ||
addr = host | ||
} | ||
|
||
node := &mRegistry.Node{ | ||
Id: serviceID + "-" + uuid, | ||
Address: net.JoinHostPort(addr, fmt.Sprint(port)), | ||
Metadata: make(map[string]string), | ||
} | ||
|
||
node.Metadata["registry"] = GetRegistry().String() | ||
node.Metadata["server"] = "grpc" | ||
node.Metadata["transport"] = "grpc" | ||
node.Metadata["protocol"] = "grpc" | ||
|
||
return &mRegistry.Service{ | ||
Name: serviceID, | ||
Version: version, | ||
Nodes: []*mRegistry.Node{node}, | ||
Endpoints: make([]*mRegistry.Endpoint, 0), | ||
} | ||
} | ||
|
||
func BuildHTTPService(serviceID, uuid, address string, version string) *mRegistry.Service { | ||
var host string | ||
var port int | ||
|
||
parts := strings.Split(address, ":") | ||
if len(parts) > 1 { | ||
host = strings.Join(parts[:len(parts)-1], ":") | ||
port, _ = strconv.Atoi(parts[len(parts)-1]) | ||
} else { | ||
host = parts[0] | ||
} | ||
|
||
addr, err := addr.Extract(host) | ||
if err != nil { | ||
addr = host | ||
} | ||
|
||
node := &mRegistry.Node{ | ||
Id: serviceID + "-" + uuid, | ||
Address: net.JoinHostPort(addr, fmt.Sprint(port)), | ||
Metadata: make(map[string]string), | ||
} | ||
|
||
node.Metadata["registry"] = GetRegistry().String() | ||
node.Metadata["server"] = "http" | ||
node.Metadata["transport"] = "http" | ||
node.Metadata["protocol"] = "http" | ||
|
||
return &mRegistry.Service{ | ||
Name: serviceID, | ||
Version: version, | ||
Nodes: []*mRegistry.Node{node}, | ||
Endpoints: make([]*mRegistry.Endpoint, 0), | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.