Exemple #1
0
        public TaskAllocatorTests()
        {
            host = new HostBuilder()
                   .ConfigureServices((hostContext, services) =>
            {
                services
                .AddWorkerAllocator(options =>
                {
                    options.TimeoutWaitingTasksPerExecutor = TimeSpan.FromSeconds(2);
                    options.MaxTasksPerExecutor            = 2;
                })
                .AddTaskType <TestTask>();

                services.AddSingleton <TaskAllocator>();
            })
                   .Build();

            metadataManager = host.Services.GetRequiredService <ITaskMetadataManager>();
            allocator       = (TaskAllocator)host.Services.GetRequiredService <ITaskAllocator>();
        }
Exemple #2
0
        public TaskAllocatorAfterRestoreTests()
        {
            host = new HostBuilder()
                   .ConfigureServices((hostContext, services) =>
            {
                services
                .AddWorkerAllocator(options =>
                {
                    options.TimeoutWaitingTasksPerExecutor = TimeSpan.FromSeconds(2);
                })
                .AddTaskRepository <MemoryTaskRepository>()
                .AddTaskType(typeof(TestTask));

                services.AddSingleton <TaskAllocator>();
            })
                   .Build();

            manager        = host.Services.GetService <ITaskMetadataManager>();
            allocator      = (TaskAllocator)host.Services.GetRequiredService <ITaskAllocator>();
            taskRepository = (MemoryTaskRepository)host.Services.GetRequiredService <ITaskRepository>();
        }