block_transform

package
v0.51.6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStepConfigSet

func NewStepConfigSet(v *[]*StepConfig, bcs *block.Cursor) *sbset.SubBlockSet

NewStepConfigSet builds a new step config set container.

bcs should be located at the step config set sub-block.

func NewStepConfigSetSubBlockCtor

func NewStepConfigSetSubBlockCtor(r *[]*StepConfig) block.SubBlockCtor

NewStepConfigSetSubBlockCtor returns the sub-block constructor.

func NewTransformConfigBlock

func NewTransformConfigBlock() block.Block

NewTransformConfigBlock is a transform configuration block constructor.

func UnmarshalStepConfig

func UnmarshalStepConfig(data []byte, conf config.Config) error

UnmarshalStepConfig unmarshals a step config using either json or protobuf.

Types

type Config

type Config struct {

	// Steps contains the transformation steps.
	// Index 0 is applied first when encoding and vise-versa.
	Steps []*StepConfig `protobuf:"bytes,1,rep,name=steps,proto3" json:"steps,omitempty"`
	// contains filtered or unexported fields
}

Config configures block transformation.

func NewConfig

func NewConfig(steps []config.Config) (*Config, error)

NewConfig constructs a new config with a set of underlying steps.

func (*Config) ApplySubBlock

func (c *Config) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*Config) Clone

func (c *Config) Clone() *Config

Clone clones the block transform config.

func (*Config) CloneMessageVT

func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Config) CloneVT

func (m *Config) CloneVT() *Config

func (*Config) EqualMessageVT

func (this *Config) EqualMessageVT(thatMsg any) bool

func (*Config) EqualVT

func (this *Config) EqualVT(that *Config) bool

func (*Config) GetEmpty

func (c *Config) GetEmpty() bool

GetEmpty returns if the transform config is empty.

func (*Config) GetSteps

func (x *Config) GetSteps() []*StepConfig

func (*Config) GetSubBlockCtor

func (c *Config) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*Config) GetSubBlocks

func (c *Config) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*Config) MarshalBlock

func (c *Config) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*Config) MarshalJSON

func (x *Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config to JSON.

func (*Config) MarshalProtoJSON

func (x *Config) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config message to JSON.

func (*Config) MarshalProtoText

func (x *Config) MarshalProtoText() string

func (*Config) MarshalToSizedBufferVT

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SizeVT

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalBlock

func (c *Config) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*Config) UnmarshalJSON

func (x *Config) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config from JSON.

func (*Config) UnmarshalProtoJSON

func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config message from JSON.

func (*Config) UnmarshalVT

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate performs cursory validation of the config.

type Step

type Step interface {
	// EncodeBlock encodes the block according to the config.
	// May reuse the same byte slice if possible.
	EncodeBlock([]byte) ([]byte, error)
	// DecodeBlock decodes the block according to the config.
	// May reuse the same byte slice if possible.
	DecodeBlock([]byte) ([]byte, error)
}

Step implements a constructed transform step. Note: the step functions must be concurrency-safe.

type StepConfig

type StepConfig struct {

	// Id contains the configuration ID.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Config contains configuration data.
	// May be formatted with proto or json.
	Config []byte `protobuf:"bytes,2,opt,name=config,proto3" json:"config,omitempty"`
	// contains filtered or unexported fields
}

StepConfig configures a transformation step.

protobuf-go-lite:disable-json

func NewStepConfig

func NewStepConfig(conf config.Config) (*StepConfig, error)

NewStepConfig constructs the step config with a underlying config.

func (*StepConfig) CloneMessageVT

func (m *StepConfig) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*StepConfig) CloneVT

func (m *StepConfig) CloneVT() *StepConfig

func (*StepConfig) EqualMessageVT

func (this *StepConfig) EqualMessageVT(thatMsg any) bool

func (*StepConfig) EqualVT

func (this *StepConfig) EqualVT(that *StepConfig) bool

func (*StepConfig) GetConfig

func (x *StepConfig) GetConfig() []byte

func (*StepConfig) GetId

func (x *StepConfig) GetId() string

func (*StepConfig) IsNil

func (c *StepConfig) IsNil() bool

IsNil returns if the object is nil.

func (*StepConfig) MarshalBlock

func (c *StepConfig) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*StepConfig) MarshalJSON

func (c *StepConfig) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ControllerConfig to JSON.

func (*StepConfig) MarshalProtoJSON

func (c *StepConfig) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the ControllerConfig message to JSON.

func (*StepConfig) MarshalProtoText

func (x *StepConfig) MarshalProtoText() string

func (*StepConfig) MarshalToSizedBufferVT

func (m *StepConfig) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*StepConfig) MarshalToVT

func (m *StepConfig) MarshalToVT(dAtA []byte) (int, error)

func (*StepConfig) MarshalVT

func (m *StepConfig) MarshalVT() (dAtA []byte, err error)

func (*StepConfig) ProtoMessage

func (*StepConfig) ProtoMessage()

func (*StepConfig) Reset

func (x *StepConfig) Reset()

func (*StepConfig) SizeVT

func (m *StepConfig) SizeVT() (n int)

func (*StepConfig) String

func (x *StepConfig) String() string

func (*StepConfig) UnmarshalBlock

func (c *StepConfig) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*StepConfig) UnmarshalJSON

func (c *StepConfig) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the ControllerConfig from JSON.

func (*StepConfig) UnmarshalProtoJSON

func (c *StepConfig) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the StepConfig from a ProtoJSON state.

func (*StepConfig) UnmarshalVT

func (m *StepConfig) UnmarshalVT(dAtA []byte) error

func (*StepConfig) Validate

func (c *StepConfig) Validate() error

Validate performs cursory validation of the config.

type StepFactory

type StepFactory interface {
	// GetConfigID returns the unique config ID for the transform step.
	GetConfigID() string
	// ConstructConfig constructs an instance of the transform configuration.
	ConstructConfig() config.Config
	// ConstructMockConfig constructs an instance of the transform configuration for testing.
	ConstructMockConfig() []config.Config
	// Construct constructs the associated transform step given configuration.
	Construct(config.Config, controller.ConstructOpts) (Step, error)
}

StepFactory constructs transform steps.

type StepFactorySet

type StepFactorySet struct {
	// contains filtered or unexported fields
}

StepFactorySet is a statically compiled set of transformers.

func NewStepFactorySet

func NewStepFactorySet() *StepFactorySet

NewStepFactorySet constructs a new step factory set.

func (*StepFactorySet) AddStepFactory

func (s *StepFactorySet) AddStepFactory(f StepFactory)

AddStepFactory attaches a step factory.

func (*StepFactorySet) GetStepFactoryByConfigID

func (s *StepFactorySet) GetStepFactoryByConfigID(id string) StepFactory

GetStepFactoryByConfigID returns the factory matching the config id. Returns nil if not found.

func (*StepFactorySet) UnmarshalStepConfig

func (s *StepFactorySet) UnmarshalStepConfig(conf *StepConfig) (config.Config, StepFactory, error)

UnmarshalStepConfig unmarshals a StepConfig to a configuration.

Constructs and parses the configuration and returns the config and step factory.

type Transformer

type Transformer struct {
	// contains filtered or unexported fields
}

Transformer is constructed using a factory set and a configuration.

func NewTransformer

func NewTransformer(
	copts controller.ConstructOpts,
	fs *StepFactorySet,
	c *Config,
) (*Transformer, error)

NewTransformer constructs a new transformer from a factory set and a config.

func NewTransformerWithSteps

func NewTransformerWithSteps(steps []Step) *Transformer

NewTransformerWithSteps constructs a new transformer with the given steps.

func (*Transformer) DecodeBlock

func (t *Transformer) DecodeBlock(data []byte) ([]byte, error)

DecodeBlock decodes the block according to the config. May reuse the same byte slice if possible.

func (*Transformer) EncodeBlock

func (t *Transformer) EncodeBlock(data []byte) ([]byte, error)

EncodeBlock encodes the block according to the config. May reuse the same byte slice if possible.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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