protected void Application_Start() { RouteTable.Routes.MapHubs(); AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); if (_configured) { return; } var connectionString = ConfigureDatabase(); Cohort.Initialize(DatabaseType.Sqlite, connectionString, cs => UnitOfWork.Current); CohortApi.Register(GlobalConfiguration.Configuration); CohortMvc.Register(); Linger.Backend = () => new DatabaseJobRepository(DatabaseDialect.Sqlite, () => UnitOfWork.Current); Schema.Install(UnitOfWork.Current, DatabaseDialect.Sqlite); Func <bool> hello = () => { Logger.Info("Hello, world!"); return(true); }; hello.PerformAsync(); Linger.StartWorker(); _configured = true; }
public void SockOptLinger() { WithSockets(UnixAddressFamily.AF_INET, UnixSocketType.SOCK_STREAM, UnixSocketProtocol.IPPROTO_TCP, (so1, so2) => { Linger linger = new Linger { l_onoff = 1, l_linger = 42, }; // Set SO_LINGER if (Syscall.setsockopt(so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_LINGER, linger) < 0) { UnixMarshal.ThrowExceptionForLastError(); } // Get and check SO_LINGER Linger value; if (Syscall.getsockopt(so1, UnixSocketProtocol.SOL_SOCKET, UnixSocketOptionName.SO_LINGER, out value) < 0) { UnixMarshal.ThrowExceptionForLastError(); } if (value.l_onoff == 0) { Assert.Fail("Linger not enabled"); } Assert.AreEqual(linger.l_linger, value.l_linger); }); }
private static void InstallLinger(DatabaseDialect dialect) { var repository = new DatabaseJobRepository(dialect, () => UnitOfWork.Current); repository.InstallSchema(); Linger.Backend = repository; Linger.StartWorker(); }
public void Job_is_executed_when_attempted() { Linger.DelayJobs = false; var success = Linger.QueueForExecution(new HelloWorldJob(), 0); Assert.IsTrue(success); Linger.DelayJobs = true; }
private ScheduledJob SaveJob() { var job = new HelloWorldJob(); var scheduled = Linger.CreateScheduledJob(job, 0, null); _repository.Save(scheduled); Assert.AreEqual(1, scheduled.Id); return(scheduled); }
// GET linger/jobs public ActionResult Jobs() { return(new ContentResult { Content = Linger.Dump(), ContentEncoding = Encoding.UTF8, ContentType = "application/json" }); }
public void Dumps_json_on_request() { Linger.DelayJobs = true; Linger.QueueForExecution(new HelloWorldJob(), runAt: DateTime.Now.AddYears(100)); var json = Linger.Dump(); Assert.IsNotNullOrEmpty(json); Trace.WriteLine(json); }
public void Respects_repeat_information_when_present() { Linger.DelayJobs = true; Linger.QueueForExecution(new HelloWorldJob(), runAt: DateTime.Now.AddYears(100), repeat: job => job.Every().Day()); var json = Linger.Dump(); Assert.IsNotNullOrEmpty(json); Trace.WriteLine(json); }
// GET linger public ActionResult Index() { JsonSerializer.Serialize(new { environment = Environment.MachineName }); return(new ContentResult { Content = Linger.Dump(), ContentEncoding = Encoding.UTF8, ContentType = "application/json" }); }
public void Jobs_in_batches_arent_fetched() { Assert.DoesNotThrow(() => { var scheduled1 = Linger.CreateScheduledJob(new HelloWorldJob(), 0, null); _repository.Save(scheduled1); var scheduled2 = Linger.CreateScheduledJob(new HelloWorldJob(), 0, null); _repository.Save(scheduled2); var batch = _repository.CreateBatch("test", new[] { scheduled2 }); Assert.IsNotNull(batch); Assert.IsTrue(batch.Jobs.Contains(scheduled2)); var all = _repository.GetAll(); Assert.IsNotNull(all); Assert.AreEqual(1, all.Count); var available = _repository.GetNextAvailable(2); Assert.IsNotNull(available); Assert.AreEqual(1, available.Count); }); }
public static bool TryCopy (IntPtr source, out Linger destination) { return ToLinger (source, out destination) == 0; }
private static extern int ToLinger (IntPtr source, out Linger destination);
public static bool TryCopy (ref Linger source, IntPtr destination) { return FromLinger (ref source, destination) == 0; }
private static extern int FromLinger (ref Linger source, IntPtr destination);
public static bool TryCopy(IntPtr source, out Linger destination) { return(ToLinger(source, out destination) == 0); }
private static extern int ToLinger(IntPtr source, out Linger destination);
public static bool TryCopy(ref Linger source, IntPtr destination) { return(FromLinger(ref source, destination) == 0); }
private static extern int FromLinger(ref Linger source, IntPtr destination);
internal static extern SocketError getsockopt( [In] SafeCloseSocket socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [Out] out Linger optionValue, [In, Out] ref int optionLength);
internal static partial SocketError getsockopt( SafeSocketHandle socketHandle, SocketOptionLevel optionLevel, SocketOptionName optionName, out Linger optionValue, ref int optionLength);
private void SetLingerOption(LingerOption lref) { var optionValue = new Linger() { OnOff = lref.Enabled ? (ushort)1 : (ushort)0, Time = (ushort)lref.LingerTime }; if (UnsafeMethods.setsockopt(Handle, SocketOptionLevel.Socket, SocketOptionName.Linger, ref optionValue, 4) == SocketError.SocketError) { throw new SocketException(); } }
internal static extern SocketError setsockopt( [In] SafeSocketHandle socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, [In] ref Linger linger, [In] int optionLength);
internal static partial SocketError setsockopt( SafeSocketHandle socketHandle, SocketOptionLevel optionLevel, SocketOptionName optionName, ref Linger linger, int optionLength);