Switch integration field types from strings to symbols
Summary
The following discussion from !90704 (comment 1006225775) should be addressed:
Something minor I noticed you may want to consider with the DSL in general: the
type
field is likely better implemented as a symbol than a string. While freezing strings reduces memory use, symbols are just ints at the VM level so are much faster to compare. A type check in particular sounds like it will primarily be used in comparisons.Strings on the other hand always require Ruby to walk it byte-by-byte when compared. A drawback is that symbols cannot be GC'ed since they are held in a special memory area in the Ruby VM (a hash table.) But if the set is small and immutable, this is likely worth it.
Here is a good article comparing the two approaches side by side: https://dmitrytsepelev.dev/why-has-ruby-symbols
Improvements
Convert all type:
attributes from strings to symbols, and enforce this in Integrations::Field
.
Maybe we could also consider decoupling the form "type" from the value type, and map them to each other:
-
type: :string
-><input type="text">
-
type: :text
-><textarea>
-
type: :boolean
-><input type="checkbox">
-
type: :secret
(or:encrypted
?) -><input type="password">
-
type: :select
(or:array
?) -><select>
Risks
The type is used by the frontend to determine how to render the fields.