changed server command to subscribe to update topics
@@ -15,6 +15,7 @@ import (
"github.com/hellofresh/janus/pkg/plugin"
"github.com/hellofresh/janus/pkg/proxy"
"github.com/hellofresh/janus/pkg/router"
+ "github.com/hellofresh/janus/pkg/store"
"github.com/hellofresh/janus/pkg/web"
"github.com/spf13/cobra"
mgo "gopkg.in/mgo.v2"
@@ -117,11 +118,20 @@ func RunServer(cmd *cobra.Command, args []string) {
// create proxy register
register := proxy.NewRegister(r, p)
+ var (
+ apiSubs *store.Subscription
+ oauthSubs *store.Subscription
+ )
+
+ if subscriber, ok := storage.(store.Subscriber); ok {
+ apiSubs = subscriber.Subscribe("api_updates")
+ oauthSubs = subscriber.Subscribe("oauth_updates")
+ }
- apiLoader := loader.NewLoader(register, pluginLoader)
+ apiLoader := loader.NewAPILoader(register, pluginLoader, apiSubs)
apiLoader.LoadDefinitions(repo)
- oauthLoader := oauth.NewLoader(register, storage)
+ oauthLoader := loader.NewOAuthLoader(register, storage, oauthSubs)
oauthLoader.LoadDefinitions(oAuthServersRepo)
wp := web.Provider{
@@ -133,6 +143,11 @@ func RunServer(cmd *cobra.Command, args []string) {
AuthRepo: oAuthServersRepo,
ReadOnly: globalConfig.Web.ReadOnly,
}
+
+ if publisher, ok := storage.(store.Publisher); ok {
+ wp.Publisher = publisher
+ }
+
wp.Provide()
log.Fatal(listenAndServe(r))
