Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Tweak ribbon-webapp so that it runs under a /ribbon context.
Browse files Browse the repository at this point in the history
(And doesn't include Booker bits.)
  • Loading branch information
lance committed Nov 2, 2015
1 parent 2e834df commit a98f9a2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 89 deletions.
Expand Up @@ -26,7 +26,7 @@
/**
* @author Bob McWhirter
*/
@WebServlet(urlPatterns = {"/system/ribbon/stream"}, asyncSupported = true)
@WebServlet(urlPatterns = {"/system/stream"}, asyncSupported = true)
public class RibbonToTheCurbSSEServlet extends HttpServlet {

private RibbonTopology topology;
Expand Down
@@ -1,6 +1,5 @@
package org.wildfly.swarm.ribbon.webapp.runtime;

import com.netflix.ribbon.Ribbon;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
Expand Down Expand Up @@ -33,7 +32,8 @@ public List<Archive> getImplicitDeployments(RibbonWebAppFraction fraction) throw
WARArchive war = ShrinkWrap.create( WARArchive.class );
war.addClass( RibbonToTheCurbSSEServlet.class );
war.addModule("org.wildfly.swarm.netflix.ribbon");
war.addAsResource(new ClassLoaderAsset("ribbon.js", this.getClass().getClassLoader()), "js/ribbon.js");
war.addAsWebResource(new ClassLoaderAsset("ribbon.js", this.getClass().getClassLoader()), "ribbon.js");
war.setContextRoot("/ribbon");
war.as(RibbonArchive.class);
list.add(war);
return list;
Expand Down
86 changes: 0 additions & 86 deletions ribbon-webapp/runtime/src/main/resources/ribbon.js
@@ -1,90 +1,4 @@

Booker.Actions.Topology = Reflux.createAction();

Booker.State.Topology = Reflux.createStore({
init: function() {
this.listenTo( Booker.Actions.Topology, this.output );
this.sse = new EventSource( "/system/ribbon/stream" );
this.sse.onmessage = Booker.Actions.Topology;
this.sse.onerror = function(e) {
console.log( "SSE error", e );
}
this.sse.onopen = function() {
console.log( "SEE opened" );
}
this.topology = {};
},

output: function(topology) {
console.log( "update topology", topology );
this.topology = JSON.parse( topology.data );
this.trigger(this.topology);
},

services: function() {
return Object.getOwnPropertyNames( this.topology ).sort( function(l,r) {
return l.localeCompare(r);
});
},

servers: function(serviceName) {
return this.topology[serviceName] || [];
}

});

Booker.Topology = React.createClass({
mixins: [Reflux.connect(Booker.State.Topology,"topology")],

render: function() {
var services = Booker.State.Topology.services();
return (
<div>
<h1>Topology</h1>
<div className="explanation">
<p>The <b>topology</b> is the layout of the services,
and how they connect together. WildFly node discovery
is used to link up the NetflixOSS Ribbon components.
</p>
<p>
This topology is then made available to the web-app,
and kept up-to-date using Server-Sent Events (SSE)
to the browser.
</p>
</div>
{
services.map( function(e) {
return (
<Booker.TopologyService name={e} key={e} servers={Booker.State.Topology.servers(e)}/>
)
})
}
</div>
);
}
});

Booker.TopologyService = React.createClass({
render: function() {
return (
<div>
<h3>{this.props.name}</h3>
<ul>
{
this.props.servers.map(function(e){
return (
<li key={e}>{e}</li>
)
})
}
</ul>
</div>

)
}
});


Ribbon = {};

Ribbon.ajax = function(serviceName, url, settings) {
Expand Down

0 comments on commit a98f9a2

Please sign in to comment.