Vixen
02b45cc4
csharp
public sealed class MapGrain

One map's shards, hosted. Doc 27 § Placement, § Grains.

Read the guide page for this →

Remarks

The adapter over MapCoordinator: it turns the coordinator's decisions into grain calls and placement-backend calls, and supplies the property the coordinator cannot give itself — that it is never re-entered.

⚠ Two players zoning in at the same instant are two turns of this grain. That is what makes doc 27's twenty-shards failure a scheduling guarantee rather than something the fleet heuristics have to be clever about: the fleet cannot decide twice, in parallel, that it is short of capacity, because there is no parallel.

⚠ Spawning is fire-and-forget from the caller's point of view, and has to be. StartAsync is seconds; a player waiting on it would be a player watching a connection time out. So the placement answer is Starting and the client asks again — which is also exactly what it will do when the fleet is at its ceiling and nothing is coming.

Methods (9)

  • public MapGrain(OrchestratorOptions cluster, ILogger<MapGrain> log)

    Stands one up.

  • public override Task OnActivateAsync(CancellationToken cancellationToken)

    This method is called at the end of the process of activating a grain. It is called before any messages have been dispatched to the grain. For grains with declared persistent state, this method is called after the State property has been populated.

  • public Task<PlaceResult> Place(PlaceRequest request)

    Puts a player somewhere, or says a shard is on its way.

  • public Task<ShardReport[]> Shards()

    Every shard of this map, in any state.

  • public Task ShardChanged(ShardReport report)

    Told by a shard when its state changes, so the map does not have to poll.

  • public Task PlayerLeft(PlayerKey player, ShardId shard)

    Told when a player leaves a shard, so the affinity counts stay honest.

  • public Task<string> Tick(DateTimeOffset now)

    One turn of the spawn and merge heuristics.

  • public static ShardKey ParseKey(string key)

    Reads a map grain's key back into the shard key it was made from.

  • public override string ToString()

    Returns a string that represents the current object.