Publish and consume typed JVM module services without string lookups at call sites.
The Grounds JVM module library uses typed service keys so modules can publish stable service
contracts and other modules can consume them without looking up raw strings.Use the service registry when modules in the same JVM need to share stable interfaces, such as a
matchmaking service, player service, config service, or NATS client. The registry is not a remote
service discovery system and it does not create classloader isolation.
Use qualified keys only when the same service contract has multiple implementations and consumers
must choose one explicitly.
import gg.grounds.modules.qualifiedServiceKeyinterface NatsClientobject NatsServiceKeys { val Public = qualifiedServiceKey<NatsClient>("grounds.nats.public") val Internal = qualifiedServiceKey<NatsClient>("grounds.nats.internal")}
Do not create qualified keys inline at call sites. Define them once in the module API that owns the
service contract, then reuse those constants everywhere.
The default registry rejects duplicate registrations for the same service key. require fails when
the requested service is missing.
Duplicate service
Registering the same key twice throws a duplicate-service error. If two implementations of the same
contract need to exist at once, use qualified keys.
Missing service
registry.require<MyService>() throws when MyService is not registered. Prefer require for
mandatory module dependencies so failures happen during startup instead of later gameplay.