Documentation
¶
Index ¶
- func NewStepConfigSet(v *[]*StepConfig, bcs *block.Cursor) *sbset.SubBlockSet
- func NewStepConfigSetSubBlockCtor(r *[]*StepConfig) block.SubBlockCtor
- func NewTransformConfigBlock() block.Block
- func UnmarshalStepConfig(data []byte, conf config.Config) error
- type Config
- func (c *Config) ApplySubBlock(id uint32, next block.SubBlock) error
- func (c *Config) Clone() *Config
- func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Config) CloneVT() *Config
- func (this *Config) EqualMessageVT(thatMsg any) bool
- func (this *Config) EqualVT(that *Config) bool
- func (c *Config) GetEmpty() bool
- func (x *Config) GetSteps() []*StepConfig
- func (c *Config) GetSubBlockCtor(id uint32) block.SubBlockCtor
- func (c *Config) GetSubBlocks() map[uint32]block.SubBlock
- func (c *Config) MarshalBlock() ([]byte, error)
- func (x *Config) MarshalJSON() ([]byte, error)
- func (x *Config) MarshalProtoJSON(s *json.MarshalState)
- func (x *Config) MarshalProtoText() string
- func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Config) MarshalToVT(dAtA []byte) (int, error)
- func (m *Config) MarshalVT() (dAtA []byte, err error)
- func (*Config) ProtoMessage()
- func (x *Config) Reset()
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (c *Config) UnmarshalBlock(data []byte) error
- func (x *Config) UnmarshalJSON(b []byte) error
- func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Config) UnmarshalVT(dAtA []byte) error
- func (c *Config) Validate() error
- type Step
- type StepConfig
- func (m *StepConfig) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *StepConfig) CloneVT() *StepConfig
- func (this *StepConfig) EqualMessageVT(thatMsg any) bool
- func (this *StepConfig) EqualVT(that *StepConfig) bool
- func (x *StepConfig) GetConfig() []byte
- func (x *StepConfig) GetId() string
- func (c *StepConfig) IsNil() bool
- func (c *StepConfig) MarshalBlock() ([]byte, error)
- func (c *StepConfig) MarshalJSON() ([]byte, error)
- func (c *StepConfig) MarshalProtoJSON(s *json.MarshalState)
- func (x *StepConfig) MarshalProtoText() string
- func (m *StepConfig) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *StepConfig) MarshalToVT(dAtA []byte) (int, error)
- func (m *StepConfig) MarshalVT() (dAtA []byte, err error)
- func (*StepConfig) ProtoMessage()
- func (x *StepConfig) Reset()
- func (m *StepConfig) SizeVT() (n int)
- func (x *StepConfig) String() string
- func (c *StepConfig) UnmarshalBlock(data []byte) error
- func (c *StepConfig) UnmarshalJSON(b []byte) error
- func (c *StepConfig) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *StepConfig) UnmarshalVT(dAtA []byte) error
- func (c *StepConfig) Validate() error
- type StepFactory
- type StepFactorySet
- type Transformer
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 ¶
NewTransformConfigBlock is a transform configuration block constructor.
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 (*Config) ApplySubBlock ¶
ApplySubBlock applies a sub-block change with a field id.
func (*Config) CloneMessageVT ¶
func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Config) EqualMessageVT ¶
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 ¶
GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.
func (*Config) MarshalBlock ¶
MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.
func (*Config) MarshalJSON ¶
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 (*Config) MarshalToSizedBufferVT ¶
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) UnmarshalBlock ¶
UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.
func (*Config) UnmarshalJSON ¶
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 ¶
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) 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.