public static void Main() { var manager = new RoleTaskManager <Configuration>( new ITaskFactory <Configuration>[] { new Factory() , new TaskFinderFactory <Configuration>() }); var config = new Configuration() { ConnectionString = "UseDevelopmentStorage=true;", TableName = "table", GenericQueueName = "queue", ContainerName = "container", FastQueueName = "fast", ModerateQueueName = "moderate", SlowQueueName = "slow", ShardQueueName = "shard" }; if (manager.OnStart(config)) { manager.Run(); while (true) { Thread.Sleep(10000); } } }
public void RunNoServices() { var factory = Substitute.For <ITaskFactory <object> >(); var manager = new RoleTaskManager <object>(factory); manager.Run(); }
public static void Main(string[] args) { // Write out standard out Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); // Load Config var config = new AppConfig { ConnectionString = args[0], CompanyQueueName = "companies", AtQueueName = "always", TopicName = "employees" }; // Start tasks using (var manager = new RoleTaskManager <AppConfig>(new TaskFactory())) { // On Start manager.OnStart(config); // Run manager.Run(); // Pin loading thread while (true) { Thread.Sleep(1500); } } }
public static void Main(string[] args) { // Load Config var config = new AppConfig() { ConnectionString = "UseDevelopmentStorage=true;", TableName = "table", GenericQueueName = "queue", ContainerName = "container", FastQueueName = "fast", ModerateQueueName = "moderate", SlowQueueName = "slow", ShardQueueName = "shard" }; // Construct runtime using (var manager = new RoleTaskManager <AppConfig>(new Factory(), new DataGenerationFactory(), new TaskFinderFactory <AppConfig>())) { // Start runtime manager.OnStart(config); // Run manager.Run(); // Hang on loaded thread while (true) { Thread.Sleep(1500); } } }
public void Run() { var tasks = new List <IRunnable>(); var task = Substitute.For <IRunnable>(); task.Start(); tasks.Add(task); var starter = Substitute.For <IStarter>(); var factory = Substitute.For <ITaskFactory <object> >(); factory.Tasks(Arg.Any <RoleTaskManager <object> >()).Returns(tasks); var manager = new RoleTaskManager <object>(new [] { factory }, starter); manager.OnStart(); manager.Run(); task.Received().Start(); factory.Received().Tasks(Arg.Any <RoleTaskManager <object> >()); starter.Received().Start(Arg.Any <IReadOnlyCollection <IRunnable> >()); }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { var manager = new RoleTaskManager<object>(new Factory()); manager.OnStart(); var host = new JobHost(); manager.Run(); host.RunAndBlock(); manager.OnStop(); }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { var manager = new RoleTaskManager <object>(new Factory()); manager.OnStart(); var host = new JobHost(); manager.Run(); host.RunAndBlock(); manager.OnStop(); }
public void Tasks() { var tasks = new List<IRunnable>(); var task = Substitute.For<IRunnable>(); task.Start(); tasks.Add(task); var factory = Substitute.For<ITaskFactory<object>>(); factory.Tasks(Arg.Any<RoleTaskManager<object>>()).Returns(tasks); var manager = new RoleTaskManager<object>(factory); manager.OnStart(); manager.Run(); Assert.AreEqual(tasks, manager.Tasks); }
public static void Main(string[] args) { var config = new AppConfig() { ConnectionString = "", }; using (var manager = new RoleTaskManager <AppConfig>(new TaskFactory())) { manager.OnStart(config); manager.Run(); while (true) { Thread.Sleep(1500); } } }
public void RunThrows() { var services = new List <IRunnable>(); var service = Substitute.For <IRunnable>(); service.When(s => s.Start()).Do(x => { throw new Exception(); }); services.Add(service); var factory = Substitute.For <ITaskFactory <object> >(); factory.Tasks(Arg.Any <RoleTaskManager <object> >()).Returns(services); var manager = new RoleTaskManager <object>(factory); manager.OnStart(); manager.Run(); factory.Received().Tasks(Arg.Any <RoleTaskManager <object> >()); }
public void Tasks() { var tasks = new List <IRunnable>(); var task = Substitute.For <IRunnable>(); task.Start(); tasks.Add(task); var factory = Substitute.For <ITaskFactory <object> >(); factory.Tasks(Arg.Any <RoleTaskManager <object> >()).Returns(tasks); var manager = new RoleTaskManager <object>(factory); manager.OnStart(); manager.Run(); Assert.AreEqual(tasks, manager.Tasks); }
public static void Main() { var manager = new RoleTaskManager<Configuration>(new Factory()); var config = new Configuration() { ConnectionString = "UseDevelopmentStorage=true;", TableName = "table", QueueName = "queue", ContainerName = "container", }; if (manager.OnStart(config)) { manager.Run(); while (true) { Thread.Sleep(10000); } } }
public void Factories() { var tasks = new List <IRunnable>(); var task = Substitute.For <IRunnable>(); tasks.Add(task); var factory1 = Substitute.For <ITaskFactory <object> >(); factory1.Tasks(Arg.Any <RoleTaskManager <object> >()).Returns(tasks); var factory2 = Substitute.For <ITaskFactory <object> >(); factory2.Tasks(Arg.Any <RoleTaskManager <object> >()).Returns(tasks); var manager = new RoleTaskManager <object>(new[] { factory1, factory2 }); manager.OnStart(); manager.Run(); Assert.AreEqual(2, manager.Tasks.Count); }
/// <summary> /// Scale Up by one unit /// </summary> /// <param name="factory">Factory</param> /// <param name="configuration">Configuration</param> /// <param name="taskName">Task Name</param> public virtual void ScaleUp(ITaskFactory <T> factory, T configuration, string taskName) { if (null == factory) { throw new ArgumentNullException("factory"); } if (string.IsNullOrWhiteSpace(taskName)) { throw new ArgumentException("taskName"); } Trace.TraceInformation("Scaling up: '{0}'.", taskName); var unit = new RoleTaskManager <T>(factory); var success = unit.OnStart(); if (success) { unit.Run(); if (units.TryAdd(unit)) { Trace.TraceInformation("Scaled up: '{0}'.", taskName); } else { unit.Dispose(); Trace.TraceWarning("Failed to add scale unit: '{0}'.", taskName); } } else { unit.Dispose(); Trace.TraceWarning("Failed to start scale unit: '{0}'.", taskName); } }
public void Dispose() { var tasks = new List <IRunnable>(); var task = Substitute.For <IRunnable>(); task.Start(); tasks.Add(task); var factory = Substitute.For <ITaskFactory <object> >(); factory.Tasks(Arg.Any <RoleTaskManager <object> >()).Returns(tasks); using (var manager = new RoleTaskManager <object>(factory)) { manager.OnStart(); manager.Run(); } task.Received().Start(); task.Received().Dispose(); factory.Received().Tasks(Arg.Any <RoleTaskManager <object> >()); }
public static void Main(string[] args) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); foreach (var arg in args) { Trace.TraceInformation("arg: {0}", arg); } // Load Config var config = new AppConfig { ConnectionString = args[0], TableName = "table", GenericQueueName = "queue", ContainerName = "container", FastQueueName = "fast", ModerateQueueName = "moderate", SlowQueueName = "slow", ShardQueueName = "shard" }; // Construct runtime using (var manager = new RoleTaskManager <AppConfig>(new Factory(), new DataGenerationFactory(), new TaskFinderFactory <AppConfig>())) { // Start runtime manager.OnStart(config); // Run manager.Run(); // Hang on loaded thread while (true) { Thread.Sleep(1500); } } }
public void RunNoServices() { var factory = Substitute.For<ITaskFactory<object>>(); var manager = new RoleTaskManager<object>(factory); manager.Run(); }
public void RunThrows() { var services = new List<IRunnable>(); var service = Substitute.For<IRunnable>(); service.When(s => s.Start()).Do(x => { throw new Exception(); }); services.Add(service); var factory = Substitute.For<ITaskFactory<object>>(); factory.Tasks(Arg.Any<RoleTaskManager<object>>()).Returns(services); var manager = new RoleTaskManager<object>(factory); manager.OnStart(); manager.Run(); service.Received().Start(); factory.Received().Tasks(Arg.Any<RoleTaskManager<object>>()); }
public void Dispose() { var tasks = new List<IRunnable>(); var task = Substitute.For<IRunnable>(); task.Start(); tasks.Add(task); var factory = Substitute.For<ITaskFactory<object>>(); factory.Tasks(Arg.Any<RoleTaskManager<object>>()).Returns(tasks); using (var manager = new RoleTaskManager<object>(factory)) { manager.OnStart(); manager.Run(); } task.Received().Start(); task.Received().Dispose(); factory.Received().Tasks(Arg.Any<RoleTaskManager<object>>()); }