This allows to:
1. Have a preset logger that is already correctly matching the environment (console vs Unity).
2. Removes the need for explicit `SpacetimeDBClient.CreateInstance(...)` which is particularly awkward to use and easy to forget with singleton as it doesn't return a result as a factory method name could suggest. Instead, `SpacetimeDBClient.instance` is available on first use.
3. Slightly simplifies dependencies between classes, e.g. `ClientCache` doesn't need a circular dependency on `SpacetimeDBClient`, making future maintenance and changes a bit easier.
Re: https://github.com/clockworklabs/SpacetimeDB/pull/840
This commit updates the C# SDK to no longer use the `row_pk` field
of the Protobuf client API,
as that field has been removed. (Will have been removed, as of merging.)
Where a table cache was previously keyed on `byte[] rowPk`,
it is now keyed on `byte[] rowBytes`,
where `rowBytes` is the BSATN-encoded bytes of the row.
This means we effectively store two copies of each row in the client cache:
the BSATN serialized format, and the decoded domain type.
An alternate implementation would be to make the table caches be sets of domain types,
discarding the BSATN bytes.
We find this undesirable for several reasons:
- Hashing and equality-comparing `byte[]` is almost certainly more efficient
than doing the same for domain types.
- Even if hashing and equality-comparing domain types were efficient,
we would still have to update codegen to emit hashing and equality methods
for all types in the module_bindings.
This implementation requires no changes to the module_bindings.
- We already have the BSATN bytes sitting around,
as they're necessarily part of the message we recieve from the server.
This change does no additional serialization or deserialization.
In essence, we're trading memory for time and simplicity.
Keeping the BSATN bytes live approximately doubles the table cache's memory usage,
but simplifies the implementation greatly,
and (we suspect) speeds up table cache insertions, deletions and lookups.