Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route is responsible for tickets processing.
func NewRoute ¶
func NewRoute(params RouteParams) *Route
NewRoute creates new route for tickets processing.
func (*Route) CompleteTicket ¶
CompleteTicket completes a ticket. Waits for previous taken tickets to complete first, if any.
type RouteParams ¶
type RouteParams struct { // TicketAllocator sets custom ticket allocator. // Optional. TicketAllocator TicketAllocator }
RouteParams sets route parameters.
type StdAllocator ¶
type StdAllocator struct{}
StdAllocator is a standard ticket allocator without any memory reuse.
func (StdAllocator) AcquireTicket ¶
func (StdAllocator) AcquireTicket() *Ticket
AcquireTicket acquires a new ticket.
func (StdAllocator) ReleaseTicket ¶
func (StdAllocator) ReleaseTicket(t *Ticket)
ReleaseTicket does nothing. Let GC erase ticket for us.
type SyncpoolAllocator ¶
type SyncpoolAllocator struct {
// contains filtered or unexported fields
}
SyncpoolAllocator uses sync.Pool under the hood to reuse allocated tickets.
func NewSyncpoolAllocator ¶
func NewSyncpoolAllocator() *SyncpoolAllocator
NewSyncpoolAllocator creates new SyncpoolAllocator.
func (*SyncpoolAllocator) AcquireTicket ¶
func (a *SyncpoolAllocator) AcquireTicket() *Ticket
AcquireTicket acquires a new ticket from the pool.
func (*SyncpoolAllocator) ReleaseTicket ¶
func (a *SyncpoolAllocator) ReleaseTicket(t *Ticket)
ReleaseTicket releases ticket to the pool.
type Ticket ¶
type Ticket struct {
// contains filtered or unexported fields
}
Ticket is a route ticket.
type TicketAllocator ¶
TicketAllocator is responsible for ticket allocation.