discovery: introduce session to discovery
Currently we have only one discovery instance per runtime and all
discovery clients share the same instance. Although this makes sense
and required, it may cause inconvenience in some cases like when a
user wants to excludes services that are advertised by the same
discovery client.
This change introduces 'session' to discovery so that we can
distinguish discovery clients including
o simplify discovery.T interface
- remove unnecessary/not-used interfaces.
o make discovery.T as a sessioned discovery and change v23 API for
getting discovery instance.
o change scan() to filter out advertisements from the same discovery.T
instance.
o remove discovery service
- the current interface is not sufficient. E.g., there is no way
to remove obsolete advertisement.
- discovery as a service doesn't make sense for now.
- if needed, we can add it again with more complete
api/implementation later.
MultiPart: 2/4
Change-Id: I3cd7f60150b0b3265c598a968564bd2d2185e514
diff --git a/runtime/factories/roaming/roaming.go b/runtime/factories/roaming/roaming.go
index 873a074..9272b03 100644
--- a/runtime/factories/roaming/roaming.go
+++ b/runtime/factories/roaming/roaming.go
@@ -51,7 +51,7 @@
}
ac := appcycle.New()
- discovery, err := dfactory.New()
+ discoveryFactory, err := dfactory.New(ctx)
if err != nil {
ac.Shutdown()
return nil, nil, nil, err
@@ -67,12 +67,12 @@
ishutdown := func() {
ac.Shutdown()
- discovery.Close()
+ discoveryFactory.Shutdown()
}
publisher := pubsub.NewPublisher()
- runtime, ctx, shutdown, err := rt.Init(ctx, ac, discovery, nil, &listenSpec, publisher, commonFlags.RuntimeFlags(), reservedDispatcher)
+ runtime, ctx, shutdown, err := rt.Init(ctx, ac, discoveryFactory, nil, &listenSpec, publisher, commonFlags.RuntimeFlags(), reservedDispatcher)
if err != nil {
ishutdown()
return nil, nil, nil, err