Skip to content

Commit

Permalink
Fixing bug in Relax.Lucene.SearchProvider; missing dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
arobson committed Jul 18, 2010
1 parent c8e544a commit 9b5d63e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
18 changes: 10 additions & 8 deletions demo/RelaxDemo/Program.cs
@@ -1,11 +1,13 @@
using System.Configuration;
using System;
using System.Configuration;
using Relax;
using Symbiote.Core;
using Symbiote.Daemon;
using Symbiote.JsonRpc.Client;
using Symbiote.JsonRpc.Client.Impl.Rpc;
using Symbiote.Log4Net;
using Symbiote.StructureMap;
using Relax.Lucene.SearchProvider;

namespace RelaxDemo
{
Expand All @@ -15,14 +17,8 @@ static void Main(string[] args)
{
Assimilate
.Core<StructureMapAdapter>()
.Daemon(x => x
.Arguments(args)
.Name("relaxdemo")
.DisplayName("Relax Demo")
.Description("Relax Integration Testing")
)
.Relax(x => x.UseDefaults().Server(ConfigurationManager.AppSettings["couchdb"]))
.JsonRpcClient(x => x.Server(@"http://localhost:8420/").Timeout(80000))
.RelaxLuceneSearchProvider(@"http://localhost:8420/", TimeSpan.FromSeconds(10))
.AddColorConsoleLogger<ChangeWatcher>(x => x
.Info()
.DefineColor()
Expand All @@ -34,6 +30,12 @@ static void Main(string[] args)
.MessageLayout(m => m.Message().Newline())
)
.Dependencies(x => x.For(typeof(IRemoteProxy<>)).Use(typeof(RemoteProxy<>)))
.Daemon(x => x
.Arguments(args)
.Name("relaxdemo")
.DisplayName("Relax Demo")
.Description("Relax Integration Testing")
)
.RunDaemon();
}
}
Expand Down
4 changes: 4 additions & 0 deletions demo/RelaxDemo/RelaxDemo.csproj
Expand Up @@ -94,6 +94,10 @@
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Relax.Lucene.SearchProvider\Relax.Lucene.SearchProvider.csproj">
<Project>{5F1B1763-0BC1-4363-A287-9FE4123BBFC2}</Project>
<Name>Relax.Lucene.SearchProvider</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Relax\Relax.csproj">
<Project>{3A8D40A3-96F9-4878-902E-7CBC3A82AEDD}</Project>
<Name>Relax</Name>
Expand Down
4 changes: 2 additions & 2 deletions demo/RelaxDemo/RelaxDemoService.cs
Expand Up @@ -31,7 +31,7 @@ public void Start()
// start watcher
"Starting change watcher."
.ToInfo<RelaxDemoService>();
_watcher.Start();
//_watcher.Start();

// create bulk documents
"Creating 10 documents via bulk insertion ..."
Expand Down Expand Up @@ -118,7 +118,7 @@ public void Start()
"Your query returned {0} results!"
.ToInfo<RelaxDemoService>(hits.Count);
}
catch (Exception)
catch (Exception ex)
{
"Well your search crapped all over itself."
.ToInfo<RelaxDemoService>();
Expand Down
2 changes: 1 addition & 1 deletion src/CouchDBIndexService/Program.cs
Expand Up @@ -21,7 +21,7 @@ static void Main(string[] args)
.Core<StructureMapAdapter>()
.Relax(x => x.UseDefaults().Preauthorize("admin", "p@ssw0rd"))
.Lucene(x => x.UseDefaults())
.RelaxLuceneService(x => x.UseDefaults().IndexDatabase("post"))
.RelaxLuceneService(x => x.UseDefaults().IndexDatabase("relaxdemo"))
.JsonRpcHost(x => x.UseDefaults().HostService<IRelaxQueryService>())
.Dependencies(x => x.For<IRelaxQueryService>().Use<RelaxQueryService>())
.Daemon(x => x
Expand Down
@@ -1,4 +1,5 @@
using System;
using Relax.Impl;
using Symbiote.Core;
using Symbiote.JsonRpc.Client;

Expand All @@ -8,7 +9,9 @@ public static class RelaxLuceneSearchAssimilation
{
public static IAssimilate RelaxLuceneSearchProvider(this IAssimilate assimilate, string searchServerUri, TimeSpan timeout)
{
return assimilate.JsonRpcClient(x => x.Server(searchServerUri).Timeout((int)timeout.TotalMilliseconds));
return assimilate
.JsonRpcClient(x => x.Server(searchServerUri).Timeout((int)timeout.TotalMilliseconds))
.Dependencies(x => x.For<IDocumentSearchProvider>().Use<RelaxLuceneSearchProvider>());
}
}
}
18 changes: 18 additions & 0 deletions src/Relax.Lucene/RelaxIndexingService.cs
Expand Up @@ -17,6 +17,8 @@ public class RelaxIndexingService
protected ILuceneServiceFactory luceneServiceFactory { get; set; }
protected IDocumentRepository repository { get; set; }
protected IJsonRpcHost server { get; set; }
protected object _lock = new object();
public bool firstRunComplete { get;set; }

public void Start()
{
Expand All @@ -35,6 +37,22 @@ public void Stop()
}

protected void OnChange(string database, ChangeRecord record)
{
if(!firstRunComplete)
{
lock(_lock)
{
IndexDocument(record, database);
firstRunComplete = true;
}
}
else
{
IndexDocument(record, database);
}
}

protected void IndexDocument(ChangeRecord record, string database)
{
"Indexing document id '{0}', sequence {1}"
.ToInfo<RelaxIndexingService>(record.Id, record.Sequence);
Expand Down

0 comments on commit 9b5d63e

Please sign in to comment.