Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(239)

Unified Diff: app/models/models.js

Issue 8824044: Handle service life
Patch Set: Handle service life Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « app/models/handlers.js ('k') | app/views/topology/service.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/models/models.js
=== modified file 'app/models/models.js'
--- app/models/models.js 2013-04-12 16:04:02 +0000
+++ app/models/models.js 2013-04-17 13:28:40 +0000
@@ -91,7 +91,26 @@
});
models.Environment = Environment;
- var Service = Y.Base.create('service', Y.Model, [], {}, {
+ var ALIVE = 'alive';
+
+ var Service = Y.Base.create('service', Y.Model, [], {
+
+ /**
+ Return true if this service life is "alive", false otherwise.
+
+ A model instance is alive if its life cycle (i.e. the "life" attribute)
+ is set to "alive". Other possible values, as they arrive from the
+ juju-core delta stream, are "dying" and "dead", in which cases the
+ service is not considered alive.
+
+ @method isAlive
+ @return {Boolean} Whether this service is alive.
+ */
+ isAlive: function() {
+ return this.get('life') === ALIVE;
+ }
+
+ }, {
ATTRS: {
displayName: {
/**
@@ -115,6 +134,9 @@
pending: {
value: false
},
+ life: {
+ value: ALIVE
+ },
unit_count: {},
aggregated_status: {}
}
@@ -124,6 +146,18 @@
var ServiceList = Y.Base.create('serviceList', Y.ModelList, [], {
model: Service,
+ /**
+ Return a list of alive model instances.
+
+ @method alive
+ @return {Y.ModelList} The model instances having life === 'alive'.
+ */
+ alive: function() {
+ return this.filter({asList: true}, function(model) {
+ return model.isAlive();
+ });
+ },
+
process_delta: function(action, data) {
_process_delta(this, action, data, {exposed: false});
}
« no previous file with comments | « app/models/handlers.js ('k') | app/views/topology/service.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b