com.atlassian.stash.throttle.Ticket |
A ticket to access a named
resource. When the resource is no longer needed, the ticket
holder should release
their ticket, allowing another request to acquire it.
ExecutorService
exposed
for plugins by the system, ticket state from the calling thread is automatically propagated to the executor thread
when the task is run. As a result, queueing code does not need to pass the ticket reference it acquired to the
new thread; instead, it should release the ticket. For threads managed any other way--for example, plugins which spin
up their own ExecutorService
--tickets must be reacquired on the new thread; they cannot be passed in.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Retrieves the name of the resource to which this ticket grants access.
| |||||||||||
Releases the ticket, indicating the named resource is now available to service another request.
|
Retrieves the name of the resource to which this ticket grants access.
Releases the ticket, indicating the named resource is now available to service another request.
The system performs best effort detection of "lost" tickets and attempts to release them. However, it is better for ticketholders to release their own tickets after the guarded operation has been performed. This both reduces the duration during which the ticket is locked, allowing other code to acquire the ticket more readily, and helps ensure all tickets are eventually released.