Stateless vs stateful Graft calls
Concepts
| Mode | Meaning |
|---|---|
| Static method | Type-level call; no remote object handle |
| Instance method | Bound to remote object identity across calls |
stateless = true | Generated/runtime hint for independently routable operations |
stateless = false | Allows stateful remote object semantics |
stateless does not remove serialization or network failure modes for remote calls.
Examples
// Stateless static call — preferred for remote routingGraftConfig.Host = "ws://localhost/ws";GraftConfig.Stateless = true;var total = PriceService.Calculate(10, 5);// Stateful instance — object identity may not survive Gateway restartvar svc = new PriceService();var value = svc.Calculate(10, 5);
- Prefer static + stateless for idempotent reads and independent operations behind load balancers.
- Use instances when the domain model requires constructor inputs and follow-up calls on the same object—and accept affinity requirements.
See Static and instance context.