-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for multiple namespaces in one config #994
Comments
1 seems like the simplest option that mostly preserves the status quo I currently prefer 1 but may have missed something and curious about your opinions |
One thought i'd like to throw in the pot: eventually we should have something that allows devs to "download" a mud config of an existing world (ie With this in mind we'll have to find a way to support non-unique names for tables and systems. With option 1 we'd have to somehow generate a unique name for the table key, probably something like concatenating namespace and name. What I don't like about this approach is that it's harder to explain what the difference between key and name is, and what each are used for. My personal favorite is approach 2.2, or slight variation (let's call it 2.3, see below), because it maps the concept of namespaces and names well to the datastructure being used (namespaces have to be unique, names have to be unique within a namespace). Approach 2.3: export default mudConfig({
namespaces: {
"": {
tables: {
CounterTableN: "uint32",
},
systems: {
Increment: {
openAccess: true
}
}
},
"namespace": {
tables: {
CounterTableN: "uint32"
},
systems: {
Increment: {
openAccess: true
}
}
}
}
}); Potentially we could also allow a top level "tables" / "systems" key for the root namespace, and only nest in the One nice side effect of approach 2.3 is it's possible to use the table schema shortcuts also for namespaced tables. |
Very into the idea of 2.3, with:
|
Good points, especially about the downloading - didn't think of that. |
Update: new config has type support for multiple namespaces, but not enabled yet because of codegen limitations (tables can have the same name in different namespaces, which would lead to file name conflicts). Codegen support is being added in #2840 |
done in #2968 |
I talk about tables because I think what works for them will work for systems, tables are more prevalent in the config, and systems have no sync to worry about. But u can see them both in the examples.
The examples are slightly contrived to show what happens when key and name differ
Current state
mudConfig
tables havenamespace
andname
, which are used for on-chaintableId
tableId
which is composed ofnamespace
+name
. It's used for all on-chain stuffnamespace
is currently global (but #971 aims to change it)Record key and
name
are sometimes used interchangeably (like in store-cache), but they can currently be different, which can lead to problems.Solution 1
Keep table key and name separate and make the separation stronger
tableKey
, and table name asname
tableKey
, but some (like subscriptions) would still havename
around, since sync works with the whole world and not just what's in the confignamespace
overrides just work (sincenamespace
+name
has to be unique, notnamespace
+tableKey
, you won't get ambiguity even with an existing world)name
as beforeSolution 2
Unify table key and name
name
from table configname
andtableKey
can not differ, so have zod check thattableKey.length <= 16
name
, which is alsotableKey
namespace
overrides must be made to work , see 2.1 and 2.2name
as beforeSub-solution 2.1
Keep only 1 root namespace
namespace
overrides, you must make a separate config for a separatenamespace
mud.config
in one package (this is a separate issue, which would particularly affect cli and client)Sub-solution 2.2
Make
tables
config option grouped by namespacemud.config
in one packageThe text was updated successfully, but these errors were encountered: