Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 0ced9ff

Browse files
committed
Merge pull request #214 from mintsoft/master
Queue: Implementing a maximum size restriction per queue
2 parents 98b1adf + a7a65c5 commit 0ced9ff

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

project/core/Config/DefaultQueueConfiguration.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public class DefaultQueueConfiguration
9292
private string name;
9393
private QueueDuplicateHandlingMode handlingMode = QueueDuplicateHandlingMode.UseFirst;
9494
private string lockQueueNames;
95+
private int maxSize = int.MaxValue;
9596

9697
/// <summary>
9798
/// Initializes a new instance of the <see cref="DefaultQueueConfiguration"/> class.
@@ -143,6 +144,18 @@ public virtual string LockQueueNames
143144
get { return lockQueueNames; }
144145
set { lockQueueNames = value; }
145146
}
147+
148+
/// <summary>
149+
/// The maximum number of items that can be exist in the queue.
150+
/// </summary>
151+
/// <default>none</default>
152+
/// <version>1.4.2</version>
153+
[ReflectorProperty("maxsize", Required = false)]
154+
public virtual int MaxSize
155+
{
156+
get { return maxSize; }
157+
set { maxSize = value; }
158+
}
146159

147160
/// <summary>
148161
/// The list of projects for the queue.

project/core/Config/IQueueConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public interface IQueueConfiguration
2121
/// A list of the names of any other queues which should be locked when a project in this queue is building.
2222
/// </summary>
2323
string LockQueueNames { get; set; }
24+
25+
/// <summary>
26+
/// The maximum size of the the queue
27+
/// </summary>
28+
int MaxSize { get; set; }
2429

2530
/// <summary>
2631
/// Gets or sets the projects.

project/core/Queues/IntegrationQueue.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public void Enqueue(IIntegrationQueueItem integrationQueueItem)
9090
// We can start integration straight away as first in first served
9191
AddToQueue(integrationQueueItem);
9292
}
93+
else if ( Count >= configuration.MaxSize )
94+
{
95+
throw new ConfigurationException(string.Format("Project '{0}' cannot be added to queue '{1}' as the queue is full", integrationQueueItem.Project.Name, Name));
96+
}
9397
else
9498
{
9599
// We need to see if we already have a integration request for this project on the queue

0 commit comments

Comments
 (0)