serialisation

package
v0.52.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// ErrorReasonCodeMissingScalar is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a missing scalar value.
	ErrorReasonCodeMissingScalar errors.ErrorReasonCode = "expanded_blueprint_serialise_missing_scalar"
	// ErrorReasonCodeMissingStringOrSubValue is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a missing string or substitution value.
	ErrorReasonCodeMissingStringOrSubValue errors.ErrorReasonCode = "expanded_blueprint_serialise_missing_string_or_sub_value"
	// ErrorReasonCodeMissingSubstitutionValue is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a missing substitution value.
	ErrorReasonCodeMissingSubstitutionValue errors.ErrorReasonCode = "expanded_blueprint_serialise_missing_substitution_value"
	// ErrorReasonCodeMissingSubPathItemValue is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a missing substitution path item value. (e.g. [0], .key or ["key"])
	ErrorReasonCodeMissingSubPathItemValue errors.ErrorReasonCode = "expanded_blueprint_serialise_missing_sub_path_item_value"
	// ErrorReasonCodeMissingMappingNodeValue is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a missing mapping node value.
	ErrorReasonCodeMissingMappingNodeValue errors.ErrorReasonCode = "expanded_blueprint_serialise_missing_mapping_node_value"
	// ErrorReasonCodeMappingNodeIsNil is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a required mapping node being nil.
	ErrorReasonCodeMappingNodeIsNil errors.ErrorReasonCode = "expanded_blueprint_serialise_mapping_node_is_nil"
	// ErrorReasonCodeStringOrSubsIsNil is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// the string or substitutions being nil.
	ErrorReasonCodeStringOrSubsIsNil errors.ErrorReasonCode = "expanded_blueprint_serialise_string_or_subs_is_nil"
	// ErrorReasonCodeMissingSubFuncArgValue is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a missing substitution function argument value.
	ErrorReasonCodeMissingSubFuncArgValue errors.ErrorReasonCode = "expanded_blueprint_serialise_missing_sub_func_arg_value"
	// ErrorReasonCodeScalarValueIsNil is provided when the reason
	// for an expanded blueprint spec serialisation error is due to
	// a required scalar value being nil.
	ErrorReasonCodeScalarValueIsNil errors.ErrorReasonCode = "expanded_blueprint_serialise_scalar_value_is_nil"
)

Variables

This section is empty.

Functions

func FromDataSourcePB

func FromDataSourcePB(dataSourcePB *schemapb.DataSource) (*schema.DataSource, error)

FromDataSourcePB converts a DataSource protobuf message to a schema.DataSource struct to be used with the blueprint framework.

func FromFieldsSourceMetaPB added in v0.52.0

func FromFieldsSourceMetaPB(fieldsPB map[string]*schemapb.SourceMeta) map[string]*source.Meta

FromFieldsSourceMetaPB converts a map of field positions from its protobuf representation.

func FromLinkSelectorPB

func FromLinkSelectorPB(linkSelectorPB *schemapb.LinkSelector) *schema.LinkSelector

FromLinkSelectorPB converts a LinkSelector protobuf message to a schema.LinkSelector struct to be used with the blueprint framework.

func FromMappingNodePB

func FromMappingNodePB(mappingNodePB *schemapb.MappingNode, optional bool) (*core.MappingNode, error)

FromMappingNodePB converts a MappingNode protobuf message to a core.MappingNode struct to be used with the blueprint framework.

func FromResourcePB

func FromResourcePB(resourcePB *schemapb.Resource) (*schema.Resource, error)

FromResourcePB converts a Resource protobuf message to a schema.Resource struct to be used with the blueprint framework.

func FromScalarValuePB

func FromScalarValuePB(scalarValue *schemapb.ScalarValue, optional bool) (*core.ScalarValue, error)

FromScalarValuePB converts a ScalarValue protobuf message to a core.ScalarValue struct to be used with the blueprint framework.

func FromSchemaPB

func FromSchemaPB(blueprintPB *schemapb.Blueprint) (*schema.Blueprint, error)

FromSchemaPB converts a Blueprint protobuf message to a schema.Blueprint struct to be used with the blueprint framework.

func FromSourceMetaPB added in v0.52.0

func FromSourceMetaPB(metaPB *schemapb.SourceMeta) *source.Meta

FromSourceMetaPB converts source metadata from its protobuf representation.

func ToDataSourcePB

func ToDataSourcePB(dataSource *schema.DataSource) (*schemapb.DataSource, error)

ToDataSourcePB converts a core data source type to a schemapb.DataSource that can be stored and transmitted as a protobuf message.

func ToFieldsSourceMetaPB added in v0.52.0

func ToFieldsSourceMetaPB(fields map[string]*source.Meta) map[string]*schemapb.SourceMeta

ToFieldsSourceMetaPB converts a map of field positions to its protobuf representation, returning nil for an empty map so that blueprints without position information do not carry an empty map across the wire.

func ToLinkSelectorPB

func ToLinkSelectorPB(linkSelector *schema.LinkSelector) *schemapb.LinkSelector

ToLinkSelectorPB converts a schema.LinkSelector to a schemapb.LinkSelector that can be stored and transmitted as a protobuf message.

func ToMappingNodePB

func ToMappingNodePB(mappingNode *core.MappingNode, optional bool) (*schemapb.MappingNode, error)

ToMappingNodePB converts a core.MappingNode to a schemapb.MappingNode that can be stored and transmitted as a protobuf message.

func ToResourcePB

func ToResourcePB(resource *schema.Resource) (*schemapb.Resource, error)

ToResourcePB converts a schema.Resource to a schemapb.Resource that can be stored and transmitted as a protobuf message.

func ToScalarValuePB

func ToScalarValuePB(scalarValue *core.ScalarValue, optional bool) (*schemapb.ScalarValue, error)

ToScalarValuePB converts a core.ScalarValue to a schemapb.ScalarValue that can be stored and transmitted as a protobuf message.

func ToSchemaPB

func ToSchemaPB(blueprint *schema.Blueprint) (*schemapb.Blueprint, error)

ToSchemaPB converts a core blueprint to a schemapb.Blueprint that can be stored and transmitted as a protobuf message.

func ToSourceMetaPB added in v0.52.0

func ToSourceMetaPB(meta *source.Meta) *schemapb.SourceMeta

ToSourceMetaPB converts source metadata to its protobuf representation.

Source metadata is absent for blueprints constructed in memory rather than parsed from a document, and for elements whose source format does not expose a position, so a nil input is expected in those cases.

Types

type ExpandedBlueprintSerialiser

type ExpandedBlueprintSerialiser interface {
	Marshal(blueprint *schema.Blueprint) ([]byte, error)
	Unmarshal(data []byte) (*schema.Blueprint, error)
}

ExpandedBlueprintSerialiser is an interface that represents a service that serialises and deserialises expanded blueprints. (An expanded blueprint is a representation with substitutions expanded into an AST-like structure.)

func NewProtobufSerialiser

func NewProtobufSerialiser() ExpandedBlueprintSerialiser

NewProtobufSerialiser creates an instance of an ExpandedBlueprintSerialiser that uses the Protocol Buffer format.

type ProtobufExpandedBlueprintSerialiser

type ProtobufExpandedBlueprintSerialiser struct{}

ProtobufExpandedBlueprintSerialiser is a service that serialises and deserialises expanded blueprints using the Protocol Buffer format. This is especially useful for serialising expanded blueprints for storage or transmission to distributed caches/data stores.

func (*ProtobufExpandedBlueprintSerialiser) Marshal

func (s *ProtobufExpandedBlueprintSerialiser) Marshal(blueprint *schema.Blueprint) ([]byte, error)

func (*ProtobufExpandedBlueprintSerialiser) Unmarshal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL