Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[courier] rename providers #6317

Merged
merged 2 commits into from
Mar 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/buckets/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import _ from 'lodash';
import angular from 'angular';
import AggTypesBucketsBucketAggTypeProvider from 'ui/agg_types/buckets/_bucket_agg_type';
import AggTypesBucketsCreateFilterFiltersProvider from 'ui/agg_types/buckets/create_filter/filters';
import CourierDataSourceDecorateQueryProvider from 'ui/courier/data_source/_decorate_query';
import DecorateQueryProvider from 'ui/courier/data_source/_decorate_query';
import filtersTemplate from 'ui/agg_types/controls/filters.html';
export default function FiltersAggDefinition(Private, Notifier) {
var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider);
var createFilter = Private(AggTypesBucketsCreateFilterFiltersProvider);
var decorateQuery = Private(CourierDataSourceDecorateQueryProvider);
var decorateQuery = Private(DecorateQueryProvider);
var notif = new Notifier({ location: 'Filters Agg' });

return new BucketAggType({
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import _ from 'lodash';
import ConfigDefaultsProvider from 'ui/config/defaults';
import ConfigDelayedUpdaterProvider from 'ui/config/_delayed_updater';
import ConfigValsProvider from 'ui/config/_vals';
import CourierDataSourceDocSourceProvider from 'ui/courier/data_source/doc_source';
import DocSourceProvider from 'ui/courier/data_source/doc_source';
import uiRoutes from 'ui/routes';
import uiModules from 'ui/modules';
import Notifier from 'ui/notify/notifier';
Expand All @@ -30,7 +30,7 @@ module.service('config', function (Private, kbnVersion, kbnIndex, $rootScope, bu
// update once it is requested by calling #set() or #clear().
var updater;

var DocSource = Private(CourierDataSourceDocSourceProvider);
var DocSource = Private(DocSourceProvider);
var doc = (new DocSource())
.index(kbnIndex)
.type('config')
Expand Down
51 changes: 27 additions & 24 deletions src/ui/public/courier/courier.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
import errors from 'ui/errors';
import _ from 'lodash';

import errors from 'ui/errors';
import 'ui/es';
import 'ui/promises';
import 'ui/safe_confirm';
import 'ui/index_patterns';
import CourierDataSourceDocSourceProvider from 'ui/courier/data_source/doc_source';
import CourierDataSourceSearchSourceProvider from 'ui/courier/data_source/search_source';
import CourierFetchStrategySearchProvider from 'ui/courier/fetch/strategy/search';
import CourierRequestQueueProvider from 'ui/courier/_request_queue';
import CourierErrorHandlersProvider from 'ui/courier/_error_handlers';
import CourierFetchFetchProvider from 'ui/courier/fetch/fetch';
import CourierLooperDocProvider from 'ui/courier/looper/doc';
import CourierLooperSearchProvider from 'ui/courier/looper/search';
import CourierDataSourceRootSearchSourceProvider from 'ui/courier/data_source/_root_search_source';
import CourierSavedObjectSavedObjectProvider from 'ui/courier/saved_object/saved_object';
import CourierRedirectWhenMissingProvider from 'ui/courier/_redirect_when_missing';
import uiModules from 'ui/modules';
import Notifier from 'ui/notify/notifier';

import DocSourceProvider from './data_source/doc_source';
import SearchSourceProvider from './data_source/search_source';
import SearchStrategyProvider from './fetch/strategy/search';
import RequestQueueProvider from './_request_queue';
import ErrorHandlersProvider from './_error_handlers';
import FetchProvider from './fetch';
import DocLooperProvider from './looper/doc';
import SearchLooperProvider from './looper/search';
import RootSearchSourceProvider from './data_source/_root_search_source';
import SavedObjectProvider from './saved_object';
import RedirectWhenMissingProvider from './_redirect_when_missing';


uiModules.get('kibana/courier')
.service('courier', function ($rootScope, Private, Promise, indexPatterns, Notifier) {
.service('courier', function ($rootScope, Private, Promise, indexPatterns) {
function Courier() {
var self = this;

var DocSource = Private(CourierDataSourceDocSourceProvider);
var SearchSource = Private(CourierDataSourceSearchSourceProvider);
var searchStrategy = Private(CourierFetchStrategySearchProvider);
var DocSource = Private(DocSourceProvider);
var SearchSource = Private(SearchSourceProvider);
var searchStrategy = Private(SearchStrategyProvider);

var requestQueue = Private(CourierRequestQueueProvider);
var errorHandlers = Private(CourierErrorHandlersProvider);
var requestQueue = Private(RequestQueueProvider);
var errorHandlers = Private(ErrorHandlersProvider);

var fetch = Private(CourierFetchFetchProvider);
var docLooper = self.docLooper = Private(CourierLooperDocProvider);
var searchLooper = self.searchLooper = Private(CourierLooperSearchProvider);
var fetch = Private(FetchProvider);
var docLooper = self.docLooper = Private(DocLooperProvider);
var searchLooper = self.searchLooper = Private(SearchLooperProvider);

// expose some internal modules
self.setRootSearchSource = Private(CourierDataSourceRootSearchSourceProvider).set;
self.setRootSearchSource = Private(RootSearchSourceProvider).set;

self.SavedObject = Private(CourierSavedObjectSavedObjectProvider);
self.SavedObject = Private(SavedObjectProvider);
self.indexPatterns = indexPatterns;
self.redirectWhenMissing = Private(CourierRedirectWhenMissingProvider);
self.redirectWhenMissing = Private(RedirectWhenMissingProvider);

self.DocSource = DocSource;
self.SearchSource = SearchSource;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/courier/data_source/__tests__/decorate_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import moment from 'moment';
import expect from 'expect.js';
import ngMock from 'ngMock';
import _ from 'lodash';
import CourierDataSourceDecorateQueryProvider from 'ui/courier/data_source/_decorate_query';
import DecorateQueryProvider from 'ui/courier/data_source/_decorate_query';

describe('Query decorator', function () {

Expand All @@ -29,7 +29,7 @@ describe('Query decorator', function () {

beforeEach(ngMock.inject(function (Private, $injector, _config_) {
config = _config_;
fn = Private(CourierDataSourceDecorateQueryProvider);
fn = Private(DecorateQueryProvider);
}));

it('should be a function', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import 'ui/private';
import ngMock from 'ngMock';
import expect from 'expect.js';
import CourierDataSourceNormalizeSortRequestProvider from 'ui/courier/data_source/_normalize_sort_request';
import NormalizeSortRequestProvider from 'ui/courier/data_source/_normalize_sort_request';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

describe('SearchSource#normalizeSortRequest', function () {


var normalizeSortRequest;
var indexPattern;
var normalizedSort;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
normalizeSortRequest = Private(CourierDataSourceNormalizeSortRequestProvider);
normalizeSortRequest = Private(NormalizeSortRequestProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);

normalizedSort = [{
Expand Down
19 changes: 11 additions & 8 deletions src/ui/public/courier/data_source/_abstract.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import _ from 'lodash';
import angular from 'angular';
import CourierRequestQueueProvider from 'ui/courier/_request_queue';
import CourierErrorHandlersProvider from 'ui/courier/_error_handlers';
import CourierFetchFetchProvider from 'ui/courier/fetch/fetch';
import CourierDataSourceDecorateQueryProvider from 'ui/courier/data_source/_decorate_query';

import 'ui/promises';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this just accidentally creep into this change? If not, what is it doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I added it because I noticed that this module requires/uses the Promise and PromiseEmitter services, but don't actually import them. It's been a while since I wrote this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... how was this service working before then? I'd err on the side of not including this unless we're certain it's necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, I think I understand now. This is likely only working by accident because of the way angular handles modules, but if you were to somehow try to run this service by itself, it wouldn't have the promise services loaded that are necessary. So adding this back in is basically a noop right now, but it is technically more appropriate than not having it.


import RequestQueueProvider from '../_request_queue';
import ErrorHandlersProvider from '../_error_handlers';
import FetchProvider from '../fetch';
import DecorateQueryProvider from './_decorate_query';

export default function SourceAbstractFactory(Private, Promise, PromiseEmitter) {
var requestQueue = Private(CourierRequestQueueProvider);
var errorHandlers = Private(CourierErrorHandlersProvider);
var courierFetch = Private(CourierFetchFetchProvider);
var requestQueue = Private(RequestQueueProvider);
var errorHandlers = Private(ErrorHandlersProvider);
var courierFetch = Private(FetchProvider);

function SourceAbstract(initialState, strategy) {
var self = this;
Expand Down Expand Up @@ -268,7 +271,7 @@ export default function SourceAbstractFactory(Private, Promise, PromiseEmitter)
.then(function () {
if (type === 'search') {
// This is down here to prevent the circular dependency
var decorateQuery = Private(CourierDataSourceDecorateQueryProvider);
var decorateQuery = Private(DecorateQueryProvider);

flatState.body = flatState.body || {};

Expand Down
1 change: 1 addition & 0 deletions src/ui/public/courier/data_source/_decorate_query.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';

export default function DecorateQuery(config) {
/**
* Decorate queries with default parameters
Expand Down
9 changes: 5 additions & 4 deletions src/ui/public/courier/data_source/_doc_send_to_es.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import _ from 'lodash';

import errors from 'ui/errors';
import CourierRequestQueueProvider from 'ui/courier/_request_queue';
import CourierFetchFetchProvider from 'ui/courier/fetch/fetch';
import RequestQueueProvider from 'ui/courier/_request_queue';
import FetchProvider from 'ui/courier/fetch/fetch';

export default function (Promise, Private, es) {
var requestQueue = Private(CourierRequestQueueProvider);
var courierFetch = Private(CourierFetchFetchProvider);
var requestQueue = Private(RequestQueueProvider);
var courierFetch = Private(FetchProvider);

/**
* Backend for doUpdate and doIndex
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'lodash';

export default function normalizeSortRequest(config) {
var defaultSortOptions = config.get('sort:options');

Expand Down Expand Up @@ -48,4 +49,3 @@ export default function normalizeSortRequest(config) {
return normalized;
}
};

4 changes: 2 additions & 2 deletions src/ui/public/courier/data_source/_root_search_source.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CourierDataSourceSearchSourceProvider from 'ui/courier/data_source/search_source';
import SearchSourceProvider from 'ui/courier/data_source/search_source';

export default function RootSearchSource(Private, $rootScope, timefilter, Notifier) {
var SearchSource = Private(CourierDataSourceSearchSourceProvider);
var SearchSource = Private(SearchSourceProvider);

var notify = new Notifier({ location: 'Root Search Source' });

Expand Down
18 changes: 10 additions & 8 deletions src/ui/public/courier/data_source/doc_source.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import _ from 'lodash';
import CourierDataSourceDocSendToEsProvider from 'ui/courier/data_source/_doc_send_to_es';
import CourierDataSourceAbstractProvider from 'ui/courier/data_source/_abstract';
import CourierFetchRequestDocProvider from 'ui/courier/fetch/request/doc';
import CourierFetchStrategyDocProvider from 'ui/courier/fetch/strategy/doc';

import 'ui/es';
import 'ui/storage';

import DocSendToEsProvider from './_doc_send_to_es';
import AbstractDataSourceProvider from './_abstract';
import DocRequestProvider from '../fetch/request/doc';
import DocStrategyProvider from '../fetch/strategy/doc';

export default function DocSourceFactory(Private, Promise, es, sessionStorage) {
var sendToEs = Private(CourierDataSourceDocSendToEsProvider);
var SourceAbstract = Private(CourierDataSourceAbstractProvider);
var DocRequest = Private(CourierFetchRequestDocProvider);
var docStrategy = Private(CourierFetchStrategyDocProvider);
var sendToEs = Private(DocSendToEsProvider);
var SourceAbstract = Private(AbstractDataSourceProvider);
var DocRequest = Private(DocRequestProvider);
var docStrategy = Private(DocStrategyProvider);

_.class(DocSource).inherits(SourceAbstract);
function DocSource(initialState) {
Expand Down
24 changes: 13 additions & 11 deletions src/ui/public/courier/data_source/search_source.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import _ from 'lodash';
import rootSearchSource from 'ui/courier/data_source/_root_search_source';
import CourierDataSourceAbstractProvider from 'ui/courier/data_source/_abstract';
import CourierFetchRequestSearchProvider from 'ui/courier/fetch/request/search';
import CourierFetchRequestSegmentedProvider from 'ui/courier/fetch/request/segmented';
import CourierFetchStrategySearchProvider from 'ui/courier/fetch/strategy/search';
import CourierDataSourceNormalizeSortRequestProvider from 'ui/courier/data_source/_normalize_sort_request';

import NormalizeSortRequestProvider from './_normalize_sort_request';
import rootSearchSource from './_root_search_source';
import AbstractDataSourceProvider from './_abstract';
import SearchRequestProvider from '../fetch/request/search';
import SegmentedRequestProvider from '../fetch/request/segmented';
import SearchStrategyProvider from '../fetch/strategy/search';

export default function SearchSourceFactory(Promise, Private) {
var SourceAbstract = Private(CourierDataSourceAbstractProvider);
var SearchRequest = Private(CourierFetchRequestSearchProvider);
var SegmentedRequest = Private(CourierFetchRequestSegmentedProvider);
var searchStrategy = Private(CourierFetchStrategySearchProvider);
var normalizeSortRequest = Private(CourierDataSourceNormalizeSortRequestProvider);
var SourceAbstract = Private(AbstractDataSourceProvider);
var SearchRequest = Private(SearchRequestProvider);
var SegmentedRequest = Private(SegmentedRequestProvider);
var searchStrategy = Private(SearchStrategyProvider);
var normalizeSortRequest = Private(NormalizeSortRequestProvider);

_.class(SearchSource).inherits(SourceAbstract);
function SearchSource(initialState) {
Expand Down
6 changes: 5 additions & 1 deletion src/ui/public/courier/looper/_looper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import _ from 'lodash';
export default function LooperFactory($timeout, Notifier, Promise) {

import 'ui/promises';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous answer

import Notifier from 'ui/notify/notifier';

export default function LooperFactory($timeout, Promise) {
var notify = new Notifier();

function Looper(ms, fn) {
Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/courier/looper/doc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import CourierFetchFetchProvider from 'ui/courier/fetch/fetch';
import CourierLooperLooperProvider from 'ui/courier/looper/_looper';
import CourierFetchStrategyDocProvider from 'ui/courier/fetch/strategy/doc';
import FetchProvider from '../fetch';
import LooperProvider from './_looper';
import DocStrategyProvider from '../fetch/strategy/doc';

export default function DocLooperService(Private) {
var fetch = Private(CourierFetchFetchProvider);
var Looper = Private(CourierLooperLooperProvider);
var docStrategy = Private(CourierFetchStrategyDocProvider);
var fetch = Private(FetchProvider);
var Looper = Private(LooperProvider);
var DocStrategy = Private(DocStrategyProvider);

/**
* The Looper which will manage the doc fetch interval
* @type {Looper}
*/
var docLooper = new Looper(1500, function () {
fetch.fetchQueued(docStrategy);
fetch.fetchQueued(DocStrategy);
});

return docLooper;
Expand Down
16 changes: 8 additions & 8 deletions src/ui/public/courier/looper/search.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import CourierFetchFetchProvider from 'ui/courier/fetch/fetch';
import CourierFetchStrategySearchProvider from 'ui/courier/fetch/strategy/search';
import CourierRequestQueueProvider from 'ui/courier/_request_queue';
import CourierLooperLooperProvider from 'ui/courier/looper/_looper';
import FetchProvider from '../fetch';
import SearchStrategyProvider from '../fetch/strategy/search';
import RequestQueueProvider from '../_request_queue';
import LooperProvider from './_looper';

export default function SearchLooperService(Private, Promise, Notifier, $rootScope) {
var fetch = Private(CourierFetchFetchProvider);
var searchStrategy = Private(CourierFetchStrategySearchProvider);
var requestQueue = Private(CourierRequestQueueProvider);
var fetch = Private(FetchProvider);
var searchStrategy = Private(SearchStrategyProvider);
var requestQueue = Private(RequestQueueProvider);

var Looper = Private(CourierLooperLooperProvider);
var Looper = Private(LooperProvider);
var notif = new Notifier({ location: 'Search Looper' });

/**
Expand Down
17 changes: 10 additions & 7 deletions src/ui/public/courier/saved_object/saved_object.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import angular from 'angular';
import errors from 'ui/errors';
import _ from 'lodash';

import errors from 'ui/errors';
import slugifyId from 'ui/utils/slugify_id';
import CourierDataSourceDocSourceProvider from 'ui/courier/data_source/doc_source';
import CourierDataSourceSearchSourceProvider from 'ui/courier/data_source/search_source';
import UtilsMappingSetupProvider from 'ui/utils/mapping_setup';
import MappingSetupProvider from 'ui/utils/mapping_setup';

import DocSourceProvider from '../data_source/doc_source';
import SearchSourceProvider from '../data_source/search_source';

export default function SavedObjectFactory(es, kbnIndex, Promise, Private, Notifier, safeConfirm, indexPatterns) {

var DocSource = Private(CourierDataSourceDocSourceProvider);
var SearchSource = Private(CourierDataSourceSearchSourceProvider);
var mappingSetup = Private(UtilsMappingSetupProvider);
var DocSource = Private(DocSourceProvider);
var SearchSource = Private(SearchSourceProvider);
var mappingSetup = Private(MappingSetupProvider);

function SavedObject(config) {
if (!_.isObject(config)) config = {};
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/index_patterns/__tests__/_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import errors from 'ui/errors';
import IndexedArray from 'ui/IndexedArray';
import FixturesLogstashFieldsProvider from 'fixtures/logstash_fields';
import FixturesStubbedDocSourceResponseProvider from 'fixtures/stubbed_doc_source_response';
import CourierDataSourceDocSourceProvider from 'ui/courier/data_source/doc_source';
import DocSourceProvider from 'ui/courier/data_source/doc_source';
import IndexPatternsMapperProvider from 'ui/index_patterns/_mapper';
import UtilsMappingSetupProvider from 'ui/utils/mapping_setup';
import IndexPatternsIntervalsProvider from 'ui/index_patterns/_intervals';
Expand All @@ -33,7 +33,7 @@ describe('index pattern', function () {
mockLogstashFields = Private(FixturesLogstashFieldsProvider);
docSourceResponse = Private(FixturesStubbedDocSourceResponseProvider);

DocSource = Private(CourierDataSourceDocSourceProvider);
DocSource = Private(DocSourceProvider);
sinon.stub(DocSource.prototype, 'doIndex');
sinon.stub(DocSource.prototype, 'fetch');

Expand Down
Loading