Struct NamingRequestBucket
- Namespace
- FishMMO.Server.Core.World.SceneServer
- Assembly
- FishMMO.Server.dll
One connection's naming request budget: a token bucket.
public struct NamingRequestBucket
- Inherited Members
Remarks
Replaces a 75 ms per-connection drop window, which answered the first request of any burst and silently dropped the rest: opening a 100-member roster sent 100 requests in one frame and 99 were thrown away (hot-path audit M18). A bucket admits a burst up to its capacity and then the refill rate, which bounds the database work a connection can cause just as firmly.
Fields
LastRefillTicks
Ticks of the last refill, on whichever clock the caller keeps the bucket on. The naming system keeps it on NowTicks: a refill rate is a local duration.
public long LastRefillTicks
Field Value
Tokens
Tokens available.
public double Tokens
Field Value
Methods
Full(int, long)
A bucket for a connection seen for the first time: full.
public static NamingRequestBucket Full(int capacity, long nowTicks)
Parameters
Returns
TryTake(long, int, double)
Refills for the time elapsed and takes one token.
public bool TryTake(long nowTicks, int capacity, double refillPerSecond)
Parameters
nowTickslongTicks now, on the bucket's clock.
capacityintBurst capacity. Zero or less admits everything.
refillPerSeconddoubleTokens returned per second.
Returns
- bool
True if the request is admitted.
TryTakeUpTo(long, int, double, int)
Refills for the time elapsed and takes as many of requested tokens as
the bucket holds.
public int TryTakeUpTo(long nowTicks, int capacity, double refillPerSecond, int requested)
Parameters
nowTickslongTicks now, on the bucket's clock.
capacityintBurst capacity. Zero or less admits everything.
refillPerSeconddoubleTokens returned per second.
requestedintTokens wanted.
Returns
- int
The number admitted, from zero to
requested.
Remarks
A batched name request is charged one token per ID it carries, the same as that many single requests. A batch larger than what is left is answered in part — the leading IDs, up to the tokens available — rather than refused whole: the client asks again for the rest, and a partial answer is what the same IDs sent one by one would have got.