Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Wire server to the code

  • Loading branch information...
commit 4d02c23d8e67861b26fa22078a204a2cc4513b21 1 parent 13944b6
@abdullin abdullin authored
View
2  Source/Btw.Redis.Tests/TestRedisManual.cs
@@ -17,7 +17,7 @@ public void Name()
using (var test = new RedisClient())
using (var store = new RedisAppendOnlyStore(test))
{
- store.Append("test", Encoding.UTF8.GetBytes("me data"), -1);
+ store.Append("test2", Encoding.UTF8.GetBytes("me data"), -1);
}
}
View
4 Source/Btw.Redis/Btw.Redis.csproj
@@ -53,10 +53,6 @@
<Project>{A435667B-5C71-41A0-A7C8-4700BDADF8B2}</Project>
<Name>Btw.Portable</Name>
</ProjectReference>
- <ProjectReference Include="..\Gtd.Console\Gtd.Shell.csproj">
- <Project>{B5516C60-3F2C-4CF1-9174-ED3ED2C7BF75}</Project>
- <Name>Gtd.Shell</Name>
- </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
2  Source/Btw.Redis/RedisAppendOnlyStore.cs
@@ -130,8 +130,6 @@ public IEnumerable<StoreData> ReadRecords(long afterVersion, int maxCount)
{
yield return new StoreData(items[i], i + start + 1);
}
-
- throw new Exception(items.ToArray().ToString());
}
public void Close()
View
10 Source/Gtd.Console/Gtd.Shell.csproj
@@ -35,6 +35,12 @@
<Reference Include="protobuf-net">
<HintPath>..\..\Library\ProtoBuf-net\protobuf-net.dll</HintPath>
</Reference>
+ <Reference Include="ServiceStack.Interfaces">
+ <HintPath>..\..\Library\ServiceStack\ServiceStack.Interfaces.dll</HintPath>
+ </Reference>
+ <Reference Include="ServiceStack.Redis">
+ <HintPath>..\..\Library\ServiceStack\ServiceStack.Redis.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
@@ -85,6 +91,10 @@
<Project>{A435667B-5C71-41A0-A7C8-4700BDADF8B2}</Project>
<Name>Btw.Portable</Name>
</ProjectReference>
+ <ProjectReference Include="..\Btw.Redis\Btw.Redis.csproj">
+ <Project>{66A6C5E4-3732-4955-8247-620377E261F2}</Project>
+ <Name>Btw.Redis</Name>
+ </ProjectReference>
<ProjectReference Include="..\Gtd.CoreDomain\Gtd.CoreDomain.csproj">
<Project>{BAB02576-30C8-4DE2-AC43-23766F9FD6A1}</Project>
<Name>Gtd.CoreDomain</Name>
View
48 Source/Gtd.Console/Program.cs
@@ -2,11 +2,14 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Text;
using System.Threading;
using Gtd.CoreDomain;
+using Gtd.Redis;
using Gtd.Shell.Commands;
using Gtd.Shell.Filters;
using Gtd.Shell.Projections;
+using ServiceStack.Redis;
namespace Gtd.Shell
{
@@ -18,8 +21,13 @@ static void Main(string[] args)
// setup and wire our console environment
Log.Info("Starting Being The Worst interactive GTD shell :)");
+ var setup = new Setup();
+ setup.UseRedis = true;
+
+ Log.Info(setup.ToString());
+
Log.Info("");
- var env = ConsoleEnvironment.Build();
+ var env = ConsoleEnvironment.Build(setup);
Log.Info("");
Log.Info("Type 'help' to get more info");
Log.Info("");
@@ -65,6 +73,19 @@ static void Main(string[] args)
}
}
+ public class Setup
+ {
+ public bool UseRedis;
+
+ public override string ToString()
+ {
+ var builder = new StringBuilder();
+ builder.AppendFormat("UseRedis={0}", UseRedis).AppendLine();
+
+ return builder.ToString();
+ }
+ }
+
public sealed class ConsoleEnvironment
{
public IEventStore Store { get; private set; }
@@ -79,18 +100,33 @@ public sealed class ConsoleEnvironment
public DateTime CurrentDate { get { return DateTime.Now; } }
- public static ConsoleEnvironment Build()
+ public static ConsoleEnvironment Build(Setup setup)
{
var handler = new SynchronousEventHandler();
var inbox = new ConsoleProjection();
handler.RegisterHandler(inbox);
+ IAppendOnlyStore store;
+ if (setup.UseRedis)
+ {
+ store = new RedisAppendOnlyStore(new RedisClient());
+ try
+ {
+ store.GetCurrentVersion();
+ }
+ catch (RedisException ex)
+ {
+ throw new ApplicationException("It looks like redis is not running. Please start Library\\Redis.Win\\redis.server.exe :)");
+ }
+ }
+ else
+ {
+ var file = new FileAppendOnlyStore(new DirectoryInfo(Directory.GetCurrentDirectory()));
+ file.Initialize();
+ store = file;
+ }
- //var store = new InMemoryStore(handler);
-
- var store = new FileAppendOnlyStore(new DirectoryInfo(Directory.GetCurrentDirectory()));
- store.Initialize();
var messageStore = new MessageStore(store);
messageStore.LoadDataContractsFromAssemblyOf(typeof(ActionDefined));
var currentVersion = store.GetCurrentVersion();
Please sign in to comment.
Something went wrong with that request. Please try again.