pull/1/head
a.bozhenov 5 years ago
parent 4f721fdbc8
commit 9d03789686

@ -31,7 +31,8 @@ namespace TestApp
StoreConnection("mytest", new IPEndPoint(IPAddress.Loopback, 8800));
StoreConnection("mymeta", new IPEndPoint(IPAddress.Loopback, 8801));
Sheduller.RemindEvery(TimeSpan.FromSeconds(1), () =>
int count = 0;
Sheduller.RemindWhile(TimeSpan.FromSeconds(1), () =>
{
var client = ConnectToService("mytest");
client.Send("pum");
@ -42,6 +43,8 @@ namespace TestApp
s => Log.Info($"Response: {s}"));
client.Request<string>("now", s => Log.Info($"Response date: {s}"));
client.Request<string>(BaseSocket.DEFAULT_REQUEST_WITHOUT_ARGS_INBOX, s => Log.Info($"Response ip: {s}"));
count++;
return count > 3;
});
Sheduller.RemindEvery(TimeSpan.FromSeconds(3), () =>

@ -1,6 +1,4 @@
using System;
using System.Net;
using ZeroLevel;
using ZeroLevel;
namespace TestApp
{
@ -10,8 +8,8 @@ namespace TestApp
{
Bootstrap.Startup<MyService>(args,
() => Configuration.ReadSetFromIniFile("config.ini"))
//.ReadServiceInfo()
//.UseDiscovery()
.EnableConsoleLog(ZeroLevel.Services.Logging.LogLevel.System | ZeroLevel.Services.Logging.LogLevel.FullDebug)
.UseDiscovery()
.Run()
.WaitWhileStatus(ZeroServiceStatus.Running)
.Stop();

@ -8,7 +8,6 @@ ServiceType=site
[log]
path=logs
console=true
[webapi]
port=8183

@ -21,7 +21,7 @@ namespace ZeroLevel.Discovery
Injector.Default.Register<RouteTable>(routeTable);
var socketPort = Configuration.Default.First<int>("socketport");
_exInbox = UseHost(socketPort);
_exInbox.RegisterInbox<IEnumerable<ServiceEndpointsInfo>>("services", (_, __) => routeTable.Get());
_exInbox.RegisterInbox<IEnumerable<ServiceEndpointsInfo>>("services", (_) => routeTable.Get());
_exInbox.RegisterInbox<ZeroServiceInfo, InvokeResult>("register", (client, info) => routeTable.Append(info, client));
}

@ -4,7 +4,11 @@
{
private static void Main(string[] args)
{
Bootstrap.Startup<DiscoveryService>(args);
Bootstrap.Startup<DiscoveryService>(args)
.Run()
.WaitWhileStatus(ZeroServiceStatus.Running)
.Stop();
Bootstrap.Shutdown();
}
}
}

@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using ZeroLevel.Services.Logging;
namespace ZeroLevel
{
@ -38,6 +39,8 @@ namespace ZeroLevel
public BootstrapFluent ReadServiceInfo() { _service?.ReadServiceInfo(); return this; }
public BootstrapFluent ReadServiceInfo(IConfigurationSet config) { _service?.ReadServiceInfo(config); return this; }
public BootstrapFluent EnableConsoleLog(LogLevel level = LogLevel.FullStandart) { Log.AddConsoleLogger(level); return this; }
public ZeroServiceStatus Status { get { return _service.Status; } }
public IServiceExecution Run() { _service.Start(); return this; }
public IServiceExecution Stop()

@ -60,8 +60,8 @@ namespace ZeroLevel.Network
_sendThread = new Thread(SendFramesJob);
_sendThread.IsBackground = true;
_sendThread.Start();
_stream.BeginRead(_buffer, 0, DEFAULT_RECEIVE_BUFFER_SIZE, ReceiveAsyncCallback, null);
Working();
_stream.BeginRead(_buffer, 0, DEFAULT_RECEIVE_BUFFER_SIZE, ReceiveAsyncCallback, null);
}
#region API
@ -295,7 +295,8 @@ namespace ZeroLevel.Network
_parser.Push(_buffer, count);
_last_rw_time = DateTime.UtcNow.Ticks;
}
if (Status == SocketClientStatus.Working)
if (Status == SocketClientStatus.Working
|| Status == SocketClientStatus.Initialized)
{
_stream.BeginRead(_buffer, 0, DEFAULT_RECEIVE_BUFFER_SIZE, ReceiveAsyncCallback, null);
}

Loading…
Cancel
Save

Powered by TurnKey Linux.