Skip to content

Convert as many interface{} on the marshaling types to primitive pointer types or dynamic types #1

@chanced

Description

@chanced

In an effort to move things along, I used interface{} for dynamic fields on the internal types used for (un)marshaling.

type completionField struct {
	Analyzer                   string      `json:"analyzer,omitempty"`
	SearchAnalyzer             string      `json:"search_analyzer,omitempty"`
	SearchQuoteAnalyzer        string      `json:"search_quote_analyzer,omitempty"`
	PreserveSeperators         interface{} `json:"preserve_separators,omitempty"`
	PreservePositionIncrements interface{} `json:"preserve_position_increments,omitempty"`
	MaxInputLength             interface{} `json:"max_input_length,omitempty"`
	Type                       FieldType   `json:"type"`
}

These need to be migrated to either primitive pointer types or dynamic types:

type completionField struct {
	Analyzer                   string        `json:"analyzer,omitempty"`
	SearchAnalyzer             string        `json:"search_analyzer,omitempty"`
	SearchQuoteAnalyzer        string        `json:"search_quote_analyzer,omitempty"`
	PreserveSeperators         *dynamic.Bool `json:"preserve_separators,omitempty"`
	PreservePositionIncrements *bool         `json:"preserve_position_increments,omitempty"`
	MaxInputLength             *int          `json:"max_input_length,omitempty"`
	Type                       FieldType     `json:"type"`
}

I'm just not sure which. Things I need to think through:

  • If I use primitives, I'll need to add something to the effect of Float64Ptr and CoerceInt64Ptr to the types in the dynamic package. Should I be concerned about the usability of this for the dynamic package? It wont be a pointer to the actual value.
  • If I use dynamic, that'll be a lot cleaner but I won't be able to cleanly coerce. This is a problem as some accessors currently coerce int values.

Doing so should improve performance of enc/dec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions