warriordog/ActivityPubSharp

Prototype lazy type graphs

Closed this issue · 1 comments

This is an idea for an improvement + optimization for the type graph system. It introduces some complexity, but has some key benefits:

  1. This finally clears the way to #134.
  2. Performance improvement - we only convert entities that are actually used.
  3. Removes dependency on ASTypeInfoCache

There may also be an opportunity to reduce the use of pivots by developing an EntityFactory or similar. That could be injected into TypeGraphReader and used to construct the appropriate entity types in a more-efficient way.

Proposed design (WIP):

  • Create new internal class TypeGraphReader:
    • Contains all the entity conversion logic from TypeMapConverter.
    • Works on JsonElement directly.
  • Create new internal class JsonTypeMap (name TBD):
    • Requires a JsonElement and the TypeGraphReader.
    • Expose functions to read entities, types, context, and metdata.
  • Update TypeMap:
    • Add internal constructor that accepts and wraps a JsonTypeMap.
    • "get" methods Fall back on JsonTypeMap if available.
  • Update TypeMapConverter:
    • Construct a singleton TypeGraphReader.
    • Remove entity conversion and construct a JsonTypeMap instead.

Updated design to account for ASP.NET Core - Dependency Injection is not available in middleware. TypeMapConverter must have a no-args constructor.