vkottler / vtelem

A real-time telemetry library for Python.
MIT License
4 stars 0 forks source link

Refactor `EnumRegistry` and `TypeRegistry` to be `Serializable` #27

Open vkottler opened 3 years ago

vkottler commented 3 years ago

See: https://github.com/vkottler/vtelem/issues/14#issuecomment-932899914

We're partially done with this, but currently a new EnumRegistry implementation has been created (and also has a schema, message type, documentation). We need to actually replace the existing implementation, but what's preventing that is also un-tangling the TypeRegistry class and making that serializable.

We might need to make the primitive type system Serializable.

vkottler commented 3 years ago

We just need to do something like make a BasePrimitive wrapper that is serializable (SerializablePrimitive ?).

vkottler commented 3 years ago

The SerializablePrimitive class now exists (with schema + documentation).

vkottler commented 3 years ago

The next step is to now re-create the idea of the "type registry" so that it can ingest both primitives and enums.

It should probably treat them totally separately, but give each a monotonically-increasing integer value where implementations keep track of which indices are part of "primitives" and which "enums" (we may need more entries following this pattern later!).

It should offer an interface to determine if a given integer identifier is an enum or a primitive.

This registry shouldn't store an EnumRegistry directly, but it should allow loading of an enum registry (which will clobber the original enum mappings unfortunately).

If we allow clobbering of an enum registry, we may want to keep a reference to that registry around so we can translate its types into the global type-regisry's values at runtime (if needed).