Ejemplo n.º 1
0
        /// <summary>
        /// This is the main entry point for your service replica.
        /// This method executes when this replica of your service becomes primary and has write status.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            _searchProvider = new SearchProvider.SearchProvider();

            var searchClient = await _searchProvider.CreateSearchServiceAsync(_searchServiceName, _adminApiKey);

            if (!await _searchProvider.IsAnyIndexExists(searchClient, _indexName))
            {
                await _searchProvider.DeleteIndexIfExistsAsync(searchClient, _indexName);

                await _searchProvider.CreateIndexAsync <Movie>(searchClient, _indexName);

                ISearchIndexClient indexClient = searchClient.Indexes.GetClient(_indexName);
                await _searchProvider.SetDataSourceAsync(indexClient);
            }
        }