-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a session manager for index writer
- Loading branch information
ssinno28
committed
Nov 21, 2023
1 parent
680d86a
commit 8fbbad5
Showing
11 changed files
with
266 additions
and
60 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
13 changes: 4 additions & 9 deletions
13
Lucene.Net.IndexProvider/Helpers/ServiceCollectionHelpers.cs
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
12 changes: 12 additions & 0 deletions
12
Lucene.Net.IndexProvider/Interfaces/IIndexConfigurationManager.cs
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,12 @@ | ||
using System.Collections.Generic; | ||
using Lucene.Net.Index; | ||
using Lucene.Net.IndexProvider.Models; | ||
|
||
namespace Lucene.Net.IndexProvider.Interfaces; | ||
|
||
public interface IIndexConfigurationManager | ||
{ | ||
List<LuceneConfig> Configurations { get; } | ||
void AddConfiguration(LuceneConfig config); | ||
LuceneConfig GetConfiguration(string indexName); | ||
} |
12 changes: 12 additions & 0 deletions
12
Lucene.Net.IndexProvider/Interfaces/IIndexSessionManager.cs
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,12 @@ | ||
using System.Collections.Generic; | ||
using Lucene.Net.Index; | ||
|
||
namespace Lucene.Net.IndexProvider.Interfaces; | ||
|
||
public interface IIndexSessionManager | ||
{ | ||
IndexWriter GetSessionFrom(string indexName); | ||
IndexWriter GetTransientSession(string indexName); | ||
void CloseSessionOn(string indexName); | ||
IDictionary<string, IndexWriter> ContextSessions { get; } | ||
} |
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
41 changes: 41 additions & 0 deletions
41
Lucene.Net.IndexProvider/Managers/IndexConfigurationManager.cs
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,41 @@ | ||
using Microsoft.Extensions.Logging; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Lucene.Net.IndexProvider.Interfaces; | ||
using Lucene.Net.IndexProvider.Models; | ||
|
||
namespace Lucene.Net.IndexProvider.Managers; | ||
|
||
public class IndexConfigurationManager : IIndexConfigurationManager | ||
{ | ||
private readonly Lazy<List<LuceneConfig>> _configurations = | ||
new Lazy<List<LuceneConfig>>(() => new List<LuceneConfig>()); | ||
|
||
private readonly ILoggerFactory _loggerFactory; | ||
|
||
public IndexConfigurationManager(ILoggerFactory loggerFactory) | ||
{ | ||
_loggerFactory = loggerFactory; | ||
} | ||
|
||
private ILogger Logger => CreateLogger<IndexConfigurationManager>(); | ||
|
||
private ILogger CreateLogger<T>() | ||
{ | ||
return _loggerFactory.CreateLogger<IndexConfigurationManager>(); | ||
} | ||
|
||
public List<LuceneConfig> Configurations => _configurations.Value; | ||
|
||
public void AddConfiguration(LuceneConfig config) | ||
{ | ||
Configurations.Add(config); | ||
} | ||
|
||
public LuceneConfig GetConfiguration(string indexName) | ||
{ | ||
var config = Configurations.First(x => x.IndexTypes.Any(t => t.Name.Equals(indexName))); | ||
return config; | ||
} | ||
} |
Oops, something went wrong.