-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Fix up blocking reconciliation for multiple models (#11237)
> In the future, this should all be moved to each individual repository now, which will mean we can finally get rid of this service. This PR moves reconciliation to 'each individual repository'. I stopped short of getting rid of the service, but its so small now we pretty much don't need it. I'd rather wait until I look at the equivalent DataSink service and see if we can get rid of both equivalent services together (this also currently dependant on work soon to be merged) Reconciliation of models (basically doing the extra work to clean up the ember-data store and bring our frontend 'truth' into line with the actual backend truth) when blocking/long-polling on different views/filters of data is slightly more complicated due to figuring out what should be cleaned up and what should be left in the store. This is especially apparent for KVs. I built in a such a way to hopefully make sure it will all make sense for the future. I also checked that this all worked nicely with all our models, even KV which has never supported blocking queries. I left all that work in so that if we want to enable blocking queries/live updates for KV it now just involves deleting a couple of lines of code. There is a tonne of old stuff that we can clean up here now (our 'fake headers' that we pass around) and I've added that to my list of thing for a 'Big Cleanup PR' that will remove lots of code that we no longer require.
- Loading branch information
Showing
15 changed files
with
144 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Ensure all types of data get reconciled with the backend data | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 1 addition & 35 deletions
36
ui/packages/consul-ui/app/services/data-source/protocols/http.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,13 @@ | ||
import Service, { inject as service } from '@ember/service'; | ||
import { get } from '@ember/object'; | ||
import { getOwner } from '@ember/application'; | ||
import { match } from 'consul-ui/decorators/data-source'; | ||
import { singularize } from 'ember-inflector'; | ||
|
||
export default class HttpService extends Service { | ||
@service('repository/dc') datacenters; | ||
@service('repository/dc') datacenter; | ||
@service('repository/kv') kvs; | ||
@service('repository/kv') kv; | ||
@service('repository/node') leader; | ||
@service('repository/service') gateways; | ||
@service('repository/service-instance') 'proxy-service-instance'; | ||
@service('repository/proxy') 'proxy-instance'; | ||
@service('repository/nspace') namespaces; | ||
@service('repository/nspace') namespace; | ||
@service('repository/metrics') metrics; | ||
@service('repository/oidc-provider') oidc; | ||
@service('ui-config') 'ui-config'; | ||
@service('ui-config') notfound; | ||
|
||
@service('data-source/protocols/http/blocking') type; | ||
|
||
source(src, configuration) { | ||
const [, , , , model] = src.split('/'); | ||
const owner = getOwner(this); | ||
const route = match(src); | ||
const find = route.cb(route.params, owner); | ||
|
||
const repo = this[model] || owner.lookup(`service:repository/${singularize(model)}`); | ||
if (typeof repo.reconcile === 'function') { | ||
configuration.createEvent = function(result = {}, configuration) { | ||
const event = { | ||
type: 'message', | ||
data: result, | ||
}; | ||
const meta = get(event, 'data.meta') || {}; | ||
if (typeof meta.range === 'undefined') { | ||
repo.reconcile(meta); | ||
} | ||
return event; | ||
}; | ||
} | ||
const find = route.cb(route.params, getOwner(this)); | ||
return this.type.source(find, configuration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.