-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from liuhaoyang/dev
publish 0.0.3-preview
- Loading branch information
Showing
30 changed files
with
279 additions
and
76 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
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,29 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Butterfly.DataContract.Tracing; | ||
using Butterfly.Storage; | ||
using Butterfly.Storage.Query; | ||
using Nest; | ||
|
||
namespace Butterfly.Elasticsearch | ||
{ | ||
internal class ElasticSearchServiceQuery : IServiceQuery | ||
{ | ||
private readonly ElasticClient _elasticClient; | ||
private readonly IIndexManager _indexManager; | ||
|
||
public ElasticSearchServiceQuery(IElasticClientFactory elasticClientFactory, IIndexManager indexManager) | ||
{ | ||
_indexManager = indexManager; | ||
_elasticClient = elasticClientFactory.Create(); | ||
} | ||
|
||
public async Task<IEnumerable<Service>> GetServices(TimeRangeQuery query) | ||
{ | ||
var index = _indexManager.CreateServiceIndex(); | ||
var countResult = await _elasticClient.CountAsync<Service>(x => x.Index(index)); | ||
var serviceResult = await _elasticClient.SearchAsync<Service>(s => s.Index(index).Size((int)countResult.Count)); | ||
return serviceResult.Documents; | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
namespace Butterfly.Server.Common | ||
{ | ||
public static class TimestampHelpers | ||
{ | ||
public static DateTimeOffset? Convert(long? timestamp) | ||
{ | ||
if (!timestamp.HasValue) | ||
{ | ||
return null; | ||
} | ||
return DateTimeOffset.FromUnixTimeMilliseconds(timestamp.Value); | ||
} | ||
} | ||
} |
Oops, something went wrong.