Introduce "noop" go-micro broker
This introduces a no op broker for go-micro. It is set as the default broker for all ocis http services. To avoid starting the default http broker, which opens an unused random http port. Fixes: https://github.com/owncloud/ocis/issues/3829
This commit is contained in:
1 parent
41896fde34
commit
fffd49fc4e
6 files changed
+55
-6
No files matched your search
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/blevesearch/bleve_index_api v1.0.3
|
github.com/blevesearch/bleve_index_api v1.0.3
|
||||||
github.com/coreos/go-oidc/v3 v3.3.0
|
github.com/coreos/go-oidc/v3 v3.3.0
|
||||||
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d
|
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d
|
||||||
github.com/cs3org/reva/v2 v2.10.1-0.20220912153139-05271421a667
|
github.com/cs3org/reva/v2 v2.10.1-0.20220914095102-44dc469bd48b
|
||||||
github.com/disintegration/imaging v1.6.2
|
github.com/disintegration/imaging v1.6.2
|
||||||
github.com/ggwhite/go-masker v1.0.9
|
github.com/ggwhite/go-masker v1.0.9
|
||||||
github.com/go-chi/chi/v5 v5.0.7
|
github.com/go-chi/chi/v5 v5.0.7
|
||||||
|
|||||||
@@ -292,8 +292,8 @@ github.com/crewjam/saml v0.4.6 h1:XCUFPkQSJLvzyl4cW9OvpWUbRf0gE7VUpU8ZnilbeM4=
|
|||||||
github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A=
|
github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A=
|
||||||
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d h1:toyZ7IsXlUdEPZ/IG8fg7hbM8HcLPY0bkX4FKBmgLVI=
|
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d h1:toyZ7IsXlUdEPZ/IG8fg7hbM8HcLPY0bkX4FKBmgLVI=
|
||||||
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
|
github.com/cs3org/go-cs3apis v0.0.0-20220818202316-e92afdddac6d/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
|
||||||
github.com/cs3org/reva/v2 v2.10.1-0.20220912153139-05271421a667 h1:Bb6P6zXtDtSkX5Whs2DWyS01Z+8nXWvqaxRgHV8JbiA=
|
github.com/cs3org/reva/v2 v2.10.1-0.20220914095102-44dc469bd48b h1:mRtQad2TBNE970FYntYSZJJp+Ol0fzcICf/n/UmHb1g=
|
||||||
github.com/cs3org/reva/v2 v2.10.1-0.20220912153139-05271421a667/go.mod h1:+BYVpRV8g1hL8wF3+3BunL9BKPsXVyJYmH8COxq/V7Y=
|
github.com/cs3org/reva/v2 v2.10.1-0.20220914095102-44dc469bd48b/go.mod h1:+BYVpRV8g1hL8wF3+3BunL9BKPsXVyJYmH8COxq/V7Y=
|
||||||
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
|
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
|
||||||
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
|
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
|
||||||
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
|
||||||
@@ -1074,6 +1074,8 @@ github.com/prometheus/statsd_exporter v0.22.4/go.mod h1:N4Z1+iSqc9rnxlT1N8Qn3l65
|
|||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKcyumwBO6qip7RNQ5r77yrssm9bfCowcLEBcU5IA=
|
github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKcyumwBO6qip7RNQ5r77yrssm9bfCowcLEBcU5IA=
|
||||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
|
github.com/rhafer/reva/v2 v2.0.0-20220913142514-cf5b93129713 h1:CLaGrpVJLptZk417YiW4jRHfTKiLMl9RljrxZd5u4l0=
|
||||||
|
github.com/rhafer/reva/v2 v2.0.0-20220913142514-cf5b93129713/go.mod h1:+BYVpRV8g1hL8wF3+3BunL9BKPsXVyJYmH8COxq/V7Y=
|
||||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package broker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"go-micro.dev/v4/broker"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NoOp struct{}
|
||||||
|
|
||||||
|
func (n NoOp) Init(_ ...broker.Option) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) Options() broker.Options {
|
||||||
|
return broker.Options{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) Address() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) Connect() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) Disconnect() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) Publish(topic string, m *broker.Message, opts ...broker.PublishOption) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) Subscribe(topic string, h broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
|
||||||
|
return nil, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NoOp) String() string {
|
||||||
|
return "NoOp"
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBroker(_ ...broker.Option) broker.Broker {
|
||||||
|
return &NoOp{}
|
||||||
|
}
|
||||||
-3
@@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||||
oregistry "github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
oregistry "github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||||
"go-micro.dev/v4/broker"
|
|
||||||
"go-micro.dev/v4/registry"
|
"go-micro.dev/v4/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,7 +19,6 @@ func RegisterGRPCEndpoint(ctx context.Context, serviceID, uuid, addr string, ver
|
|||||||
}
|
}
|
||||||
ocisRegistry := oregistry.GetRegistry()
|
ocisRegistry := oregistry.GetRegistry()
|
||||||
|
|
||||||
node.Metadata["broker"] = broker.String()
|
|
||||||
node.Metadata["registry"] = ocisRegistry.String()
|
node.Metadata["registry"] = ocisRegistry.String()
|
||||||
node.Metadata["server"] = "grpc"
|
node.Metadata["server"] = "grpc"
|
||||||
node.Metadata["transport"] = "grpc"
|
node.Metadata["transport"] = "grpc"
|
||||||
@@ -76,7 +74,6 @@ func RegisterHTTPEndpoint(ctx context.Context, serviceID, uuid, addr string, ver
|
|||||||
}
|
}
|
||||||
ocisRegistry := oregistry.GetRegistry()
|
ocisRegistry := oregistry.GetRegistry()
|
||||||
|
|
||||||
node.Metadata["broker"] = broker.String()
|
|
||||||
node.Metadata["registry"] = ocisRegistry.String()
|
node.Metadata["registry"] = ocisRegistry.String()
|
||||||
node.Metadata["server"] = "http"
|
node.Metadata["server"] = "http"
|
||||||
node.Metadata["transport"] = "http"
|
node.Metadata["transport"] = "http"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/owncloud/ocis/v2/ocis-pkg/broker"
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||||
|
|
||||||
mhttps "github.com/go-micro/plugins/v4/server/http"
|
mhttps "github.com/go-micro/plugins/v4/server/http"
|
||||||
@@ -18,9 +19,11 @@ type Service struct {
|
|||||||
|
|
||||||
// NewService initializes a new http service.
|
// NewService initializes a new http service.
|
||||||
func NewService(opts ...Option) Service {
|
func NewService(opts ...Option) Service {
|
||||||
|
noopBroker := broker.NoOp{}
|
||||||
sopts := newOptions(opts...)
|
sopts := newOptions(opts...)
|
||||||
wopts := []micro.Option{
|
wopts := []micro.Option{
|
||||||
micro.Server(mhttps.NewServer(server.TLSConfig(sopts.TLSConfig))),
|
micro.Server(mhttps.NewServer(server.TLSConfig(sopts.TLSConfig))),
|
||||||
|
micro.Broker(noopBroker),
|
||||||
micro.Address(sopts.Address),
|
micro.Address(sopts.Address),
|
||||||
micro.Name(strings.Join([]string{sopts.Namespace, sopts.Name}, ".")),
|
micro.Name(strings.Join([]string{sopts.Namespace, sopts.Name}, ".")),
|
||||||
micro.Version(sopts.Version),
|
micro.Version(sopts.Version),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/cs3org/reva/v2/pkg/micro/ocdav"
|
"github.com/cs3org/reva/v2/pkg/micro/ocdav"
|
||||||
"github.com/oklog/run"
|
"github.com/oklog/run"
|
||||||
|
"github.com/owncloud/ocis/v2/ocis-pkg/broker"
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||||
"github.com/owncloud/ocis/v2/services/ocdav/pkg/config"
|
"github.com/owncloud/ocis/v2/services/ocdav/pkg/config"
|
||||||
@@ -60,6 +61,7 @@ func Server(cfg *config.Config) *cli.Command {
|
|||||||
ocdav.VersionString(cfg.Status.VersionString),
|
ocdav.VersionString(cfg.Status.VersionString),
|
||||||
ocdav.Edition(cfg.Status.Edition),
|
ocdav.Edition(cfg.Status.Edition),
|
||||||
ocdav.MachineAuthAPIKey(cfg.MachineAuthAPIKey),
|
ocdav.MachineAuthAPIKey(cfg.MachineAuthAPIKey),
|
||||||
|
ocdav.Broker(broker.NoOp{}),
|
||||||
// ocdav.FavoriteManager() // FIXME needs a proper persistence implementation https://github.com/owncloud/ocis/issues/1228
|
// ocdav.FavoriteManager() // FIXME needs a proper persistence implementation https://github.com/owncloud/ocis/issues/1228
|
||||||
// ocdav.LockSystem(), // will default to the CS3 lock system
|
// ocdav.LockSystem(), // will default to the CS3 lock system
|
||||||
// ocdav.TLSConfig() // tls config for the http server
|
// ocdav.TLSConfig() // tls config for the http server
|
||||||
|
|||||||
Reference in new issue
Block a user