Documentation
¶
Index ¶
- Constants
- Variables
- func AddFactories(b bus.Bus, sr *static.Resolver)
- func ApplyOpCheck(ctx context.Context, handle forge_target.ExecControllerHandle, ...) error
- func ApplyOpCheckExists(ctx context.Context, handle forge_target.ExecControllerHandle, ...) error
- func ApplyOpDelete(ctx context.Context, handle forge_target.ExecControllerHandle, ...) error
- func ApplyOpGet(ctx context.Context, handle forge_target.ExecControllerHandle, ...) error
- func ApplyOpGetExists(ctx context.Context, handle forge_target.ExecControllerHandle, ...) error
- func ApplyOpSet(ctx context.Context, handle forge_target.ExecControllerHandle, ...) error
- func NewConfigInputBlock() block.Block
- type 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) EqualsConfig(other config.Config) bool
- func (c *Config) GetConfigID() string
- func (x *Config) GetConfigInput() string
- func (x *Config) GetIgnoreErrors() bool
- func (x *Config) GetOps() []*Op
- func (c *Config) IsEmpty() bool
- 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 ConfigInput
- func (m *ConfigInput) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *ConfigInput) CloneVT() *ConfigInput
- func (this *ConfigInput) EqualMessageVT(thatMsg any) bool
- func (this *ConfigInput) EqualVT(that *ConfigInput) bool
- func (x *ConfigInput) GetOps() []*Op
- func (b *ConfigInput) MarshalBlock() ([]byte, error)
- func (x *ConfigInput) MarshalJSON() ([]byte, error)
- func (x *ConfigInput) MarshalProtoJSON(s *json.MarshalState)
- func (x *ConfigInput) MarshalProtoText() string
- func (m *ConfigInput) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *ConfigInput) MarshalToVT(dAtA []byte) (int, error)
- func (m *ConfigInput) MarshalVT() (dAtA []byte, err error)
- func (*ConfigInput) ProtoMessage()
- func (x *ConfigInput) Reset()
- func (m *ConfigInput) SizeVT() (n int)
- func (x *ConfigInput) String() string
- func (b *ConfigInput) UnmarshalBlock(data []byte) error
- func (x *ConfigInput) UnmarshalJSON(b []byte) error
- func (x *ConfigInput) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *ConfigInput) UnmarshalVT(dAtA []byte) error
- type Controller
- func (c *Controller) Close() error
- func (c *Controller) Execute(ctx context.Context) error
- func (c *Controller) GetControllerInfo() *controller.Info
- func (c *Controller) HandleDirective(ctx context.Context, inst directive.Instance) ([]directive.Resolver, error)
- func (c *Controller) InitForgeExecController(ctx context.Context, inputVals forge_target.InputMap, ...) error
- type Factory
- func (t *Factory) Construct(ctx context.Context, conf config.Config, opts controller.ConstructOpts) (controller.Controller, error)
- func (t *Factory) ConstructConfig() config.Config
- func (t *Factory) GetConfigID() string
- func (t *Factory) GetControllerID() string
- func (t *Factory) GetVersion() controller.Version
- type Op
- func (m *Op) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Op) CloneVT() *Op
- func (this *Op) EqualMessageVT(thatMsg any) bool
- func (this *Op) EqualVT(that *Op) bool
- func (x *Op) GetKey() string
- func (x *Op) GetKeyInput() string
- func (x *Op) GetOpType() OpType
- func (x *Op) GetOps() []*Op
- func (x *Op) GetOutput() string
- func (x *Op) GetValue() *value.Value
- func (x *Op) GetValueInput() string
- func (x *Op) GetValueString() string
- func (o *Op) IsEmpty() bool
- func (x *Op) MarshalJSON() ([]byte, error)
- func (x *Op) MarshalProtoJSON(s *json.MarshalState)
- func (x *Op) MarshalProtoText() string
- func (m *Op) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Op) MarshalToVT(dAtA []byte) (int, error)
- func (m *Op) MarshalVT() (dAtA []byte, err error)
- func (*Op) ProtoMessage()
- func (x *Op) Reset()
- func (m *Op) SizeVT() (n int)
- func (x *Op) String() string
- func (x *Op) UnmarshalJSON(b []byte) error
- func (x *Op) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Op) UnmarshalVT(dAtA []byte) error
- func (o *Op) Validate() error
- type OpQueue
- type OpType
- func (x OpType) Enum() *OpType
- func (x OpType) MarshalJSON() ([]byte, error)
- func (x OpType) MarshalProtoJSON(s *json.MarshalState)
- func (x OpType) MarshalProtoText() string
- func (x OpType) MarshalText() ([]byte, error)
- func (x OpType) String() string
- func (x *OpType) UnmarshalJSON(b []byte) error
- func (x *OpType) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (x *OpType) UnmarshalText(b []byte) error
- type PendingOp
Constants ¶
const ConfigID = ControllerID
ConfigID is the string used to identify this config object.
const ControllerID = "forge/lib/kvtx"
ControllerID is the ID of the controller.
Variables ¶
var ( OpType_name = map[int32]string{ 0: "OpType_NONE", 1: "OpType_GET", 2: "OpType_GET_EXISTS", 3: "OpType_CHECK", 4: "OpType_CHECK_BLOB", 5: "OpType_CHECK_EXISTS", 6: "OpType_CHECK_NOT_EXISTS", 7: "OpType_SET", 8: "OpType_SET_BLOB", 9: "OpType_DELETE", } OpType_value = map[string]int32{ "OpType_NONE": 0, "OpType_GET": 1, "OpType_GET_EXISTS": 2, "OpType_CHECK": 3, "OpType_CHECK_BLOB": 4, "OpType_CHECK_EXISTS": 5, "OpType_CHECK_NOT_EXISTS": 6, "OpType_SET": 7, "OpType_SET_BLOB": 8, "OpType_DELETE": 9, } )
Enum value maps for OpType.
var ( // ErrEmptyKey is returned if the key was not specified in the op ErrEmptyKey = errors.New("key was not specified for operation") // ErrUnknownOpType is returned if the operation type was unknown. ErrUnknownOpType = errors.New("operation type was unknown") // ErrValueMismatch is returned if the values did not match. ErrValueMismatch = errors.New("values did not match") )
var Version = controller.MustParseVersion("0.0.1")
Version is the version of the controller implementation.
Functions ¶
func AddFactories ¶
AddFactories adds factories to an existing static resolver.
func ApplyOpCheck ¶
func ApplyOpCheck( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, key []byte, value *forge_value.Value, valueIsBlob bool, outputName string, ) error
ApplyOpCheck applies a CHECK operation against a store.
func ApplyOpCheckExists ¶
func ApplyOpCheckExists( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, key []byte, shouldExist bool, ) error
ApplyOpCheckExists ensures a key does or does not exist.
func ApplyOpDelete ¶
func ApplyOpDelete( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, key []byte, outputName string, ) error
ApplyOpDelete applies a DELETE operation against a store.
func ApplyOpGet ¶
func ApplyOpGet( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, key []byte, outputName string, ) error
ApplyOpGet applies a GET operation against a store.
func ApplyOpGetExists ¶
func ApplyOpGetExists( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, key []byte, outputName string, ) error
ApplyOpGetExists applies a EXISTS operation against a store.
func ApplyOpSet ¶
func ApplyOpSet( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, key []byte, value *forge_value.Value, valueIsBlob bool, outputName string, ) error
ApplyOpSet applies a SET operation against a store. sets a reference to the location.
func NewConfigInputBlock ¶
NewConfigInputBlock constructs a new ConfigInput block.
Types ¶
type Config ¶
type Config struct {
// Ops is the list of operations to apply.
Ops []*Op `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops,omitempty"`
// ConfigInput is the name of an Input to load additional ops from.
// The referenced block should contain a ConfigInput object.
ConfigInput string `protobuf:"bytes,2,opt,name=config_input,json=configInput,proto3" json:"configInput,omitempty"`
// IgnoreErrors warns on errors and continues w/o failing.
IgnoreErrors bool `protobuf:"varint,3,opt,name=ignore_errors,json=ignoreErrors,proto3" json:"ignoreErrors,omitempty"`
// contains filtered or unexported fields
}
Config is the configuration for the Forge KVTX exec controller. Implements get, set, delete, keys against a k/v block graph. Operations are sequential, failed ops cancel the entire sequence.
Inputs:
- store: reference to a kvtx_block.KeyValueStore.
- ... config_input as configured below (optional).
- ... any operation inputs configured below
Outputs:
- store: output (modified) KeyValueStore.
- ... any operation outputs configured below.
func (*Config) CloneMessageVT ¶
func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Config) EqualMessageVT ¶
func (*Config) EqualsConfig ¶
EqualsConfig checks if the other config is equal.
func (*Config) GetConfigID ¶
GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.
func (*Config) GetConfigInput ¶
func (*Config) GetIgnoreErrors ¶
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 ConfigInput ¶
type ConfigInput struct {
// Ops is the list of operations to apply.
Ops []*Op `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops,omitempty"`
// contains filtered or unexported fields
}
ConfigInput is a block containing additional ops from an Input.
func FetchConfigInput ¶
func FetchConfigInput( ctx context.Context, handle forge_target.ExecControllerHandle, val *forge_value.Value, ) (*ConfigInput, error)
FetchConfigInput fetches the ConfigInput block from the Value.
func UnmarshalConfigInput ¶
UnmarshalConfigInput unmarshals a config input block from the cursor.
func (*ConfigInput) CloneMessageVT ¶
func (m *ConfigInput) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*ConfigInput) CloneVT ¶
func (m *ConfigInput) CloneVT() *ConfigInput
func (*ConfigInput) EqualMessageVT ¶
func (this *ConfigInput) EqualMessageVT(thatMsg any) bool
func (*ConfigInput) EqualVT ¶
func (this *ConfigInput) EqualVT(that *ConfigInput) bool
func (*ConfigInput) GetOps ¶
func (x *ConfigInput) GetOps() []*Op
func (*ConfigInput) MarshalBlock ¶
func (b *ConfigInput) MarshalBlock() ([]byte, error)
MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.
func (*ConfigInput) MarshalJSON ¶
func (x *ConfigInput) MarshalJSON() ([]byte, error)
MarshalJSON marshals the ConfigInput to JSON.
func (*ConfigInput) MarshalProtoJSON ¶
func (x *ConfigInput) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the ConfigInput message to JSON.
func (*ConfigInput) MarshalProtoText ¶
func (x *ConfigInput) MarshalProtoText() string
func (*ConfigInput) MarshalToSizedBufferVT ¶
func (m *ConfigInput) MarshalToSizedBufferVT(dAtA []byte) (int, error)
func (*ConfigInput) MarshalToVT ¶
func (m *ConfigInput) MarshalToVT(dAtA []byte) (int, error)
func (*ConfigInput) MarshalVT ¶
func (m *ConfigInput) MarshalVT() (dAtA []byte, err error)
func (*ConfigInput) ProtoMessage ¶
func (*ConfigInput) ProtoMessage()
func (*ConfigInput) Reset ¶
func (x *ConfigInput) Reset()
func (*ConfigInput) SizeVT ¶
func (m *ConfigInput) SizeVT() (n int)
func (*ConfigInput) String ¶
func (x *ConfigInput) String() string
func (*ConfigInput) UnmarshalBlock ¶
func (b *ConfigInput) UnmarshalBlock(data []byte) error
UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.
func (*ConfigInput) UnmarshalJSON ¶
func (x *ConfigInput) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the ConfigInput from JSON.
func (*ConfigInput) UnmarshalProtoJSON ¶
func (x *ConfigInput) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the ConfigInput message from JSON.
func (*ConfigInput) UnmarshalVT ¶
func (m *ConfigInput) UnmarshalVT(dAtA []byte) error
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller implements the kvtx operations controller.
func NewController ¶
NewController constructs a new kvtx ops execution controller.
func (*Controller) Close ¶
func (c *Controller) Close() error
Close releases any resources used by the controller. Error indicates any issue encountered releasing.
func (*Controller) Execute ¶
func (c *Controller) Execute(ctx context.Context) error
Execute executes the controller goroutine. Returning nil ends execution. Returning an error triggers a retry with backoff.
func (*Controller) GetControllerInfo ¶
func (c *Controller) GetControllerInfo() *controller.Info
GetControllerInfo returns information about the controller.
func (*Controller) HandleDirective ¶
func (c *Controller) HandleDirective(ctx context.Context, inst directive.Instance) ([]directive.Resolver, error)
HandleDirective asks if the handler can resolve the directive.
func (*Controller) InitForgeExecController ¶
func (c *Controller) InitForgeExecController( ctx context.Context, inputVals forge_target.InputMap, handle forge_target.ExecControllerHandle, ) error
InitForgeExecController initializes the Forge execution controller. This is called before Execute(). Any error returned cancels execution of the controller.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory constructs a kvtx controller.
func (*Factory) Construct ¶
func (t *Factory) Construct( ctx context.Context, conf config.Config, opts controller.ConstructOpts, ) (controller.Controller, error)
Construct constructs the associated controller given configuration.
func (*Factory) ConstructConfig ¶
ConstructConfig constructs an instance of the controller configuration.
func (*Factory) GetConfigID ¶
GetConfigID returns the configuration ID for the controller.
func (*Factory) GetControllerID ¶
GetControllerID returns the unique ID for the controller.
func (*Factory) GetVersion ¶
func (t *Factory) GetVersion() controller.Version
GetVersion returns the version of this controller.
type Op ¶
type Op struct {
// OpType is the operation type to apply.
OpType OpType `protobuf:"varint,1,opt,name=op_type,json=opType,proto3" json:"opType,omitempty"`
// KeyInput is the name of the Input to use for the Key.
// The raw block data will be used as the key.
KeyInput string `protobuf:"bytes,2,opt,name=key_input,json=keyInput,proto3" json:"keyInput,omitempty"`
// Key is the in-line configured key to use.
// Converted to []byte without nil terminator.
// If set, overrides input_key.
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
// ValueInput is the name of the Input to use for the Value argument.
//
// - CHECK: contains the value to check against the GET value.
// - SET: contains the value to store.
//
// If SET, stores the block reference into the tree.
// If SET_BLOB, stores the block reference into the tree, marking it as a Blob
// If CHECK, compares the given block reference with the stored.
// Note: overridden by inline value if set and not empty.
// Note: overridden by value_string if set and not empty.
ValueInput string `protobuf:"bytes,6,opt,name=value_input,json=valueInput,proto3" json:"valueInput,omitempty"`
// Value is the in-line value argument.
//
// See input field for additional notes.
Value *value.Value `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"`
// ValueString is an in-line string specification of the value.
// Note: overridden by inline value if set and not empty.
ValueString string `protobuf:"bytes,8,opt,name=value_string,json=valueString,proto3" json:"valueString,omitempty"`
// Output is the name of the output to use for the Value.
//
// - GET: contains the value retrieved from the store.
// - CHECK: same as GET, contains the retrieved value.
// - SET: contains the value added to the store.
// - DELETE: contains the value just before deleting.
//
// Note: contains the single most recently set value only.
// Note: stores the block reference as the output Value.
Output string `protobuf:"bytes,9,opt,name=output,proto3" json:"output,omitempty"`
// Ops is the list of sub-operations to apply.
// The sub-operations inherit the parent config.
Ops []*Op `protobuf:"bytes,10,rep,name=ops,proto3" json:"ops,omitempty"`
// contains filtered or unexported fields
}
Op is an operation definition.
func (*Op) CloneMessageVT ¶
func (m *Op) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Op) EqualMessageVT ¶
func (*Op) GetKeyInput ¶
func (*Op) GetValueInput ¶
func (*Op) GetValueString ¶
func (*Op) MarshalJSON ¶
MarshalJSON marshals the Op to JSON.
func (*Op) MarshalProtoJSON ¶
func (x *Op) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Op message to JSON.
func (*Op) MarshalProtoText ¶
func (*Op) ProtoMessage ¶
func (*Op) ProtoMessage()
func (*Op) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Op from JSON.
func (*Op) UnmarshalProtoJSON ¶
func (x *Op) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Op message from JSON.
func (*Op) UnmarshalVT ¶
type OpQueue ¶
type OpQueue struct {
// contains filtered or unexported fields
}
OpQueue prefetches input values for a set of ops.
func NewOpQueue ¶
func NewOpQueue( ctx context.Context, inputVals forge_target.InputMap, handle forge_target.ExecControllerHandle, ) *OpQueue
NewOpQueue constructs a new op queue.
func (*OpQueue) AddOps ¶
AddOps adds a list of ops to the queue. Resolves the input values or returns an error.
func (*OpQueue) AddPendingOp ¶
AddPendingOp queues a pending op.
func (*OpQueue) GetPendingOps ¶
GetPendingOps returns the slice of pending ops.
type OpType ¶
type OpType int32
OpType is the list of operation codes for kvtx.
const ( // OpType_NONE indicates this Op just sets values for nested ops. OpType_OpType_NONE OpType = 0 // OpType_GET retrieves a BlockRef from the store and copies to output. OpType_OpType_GET OpType = 1 // OpType_GET_EXISTS checks if the key exists and writes a msgpack boolean block to output. OpType_OpType_GET_EXISTS OpType = 2 // OpType_CHECK performs a GET operation and checks the value against the input. // The input must be a non-empty Cursor. // Compares the block reference stored with the given block ref. OpType_OpType_CHECK OpType = 3 // OpType_CHECK_BLOB performs a GET operation and checks the raw value against the input. // The input must be a non-empty Blob. // Compares the blob contents with the input blob contents. OpType_OpType_CHECK_BLOB OpType = 4 // OpType_CHECK_EXISTS checks if the given key exists. OpType_OpType_CHECK_EXISTS OpType = 5 // OpType_CHECK_NOT_EXISTS ensures the given key does not exist. OpType_OpType_CHECK_NOT_EXISTS OpType = 6 // OpType_SET sets a BlockRef to the block referenced by the Value. // Note: does not handle Blob values, sets as a reference only. OpType_OpType_SET OpType = 7 // OpType_SET_BLOB treats the input BlockRef as a Blob and stores it. // The GET operation will return the Blob contents. OpType_OpType_SET_BLOB OpType = 8 // OpType_DELETE deletes a key from the store. // The old value is written to the output, if set. OpType_OpType_DELETE OpType = 9 )
func (OpType) MarshalJSON ¶
MarshalJSON marshals the OpType to JSON.
func (OpType) MarshalProtoJSON ¶
func (x OpType) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the OpType to JSON.
func (OpType) MarshalProtoText ¶
func (OpType) MarshalText ¶
MarshalText marshals the OpType to text.
func (*OpType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the OpType from JSON.
func (*OpType) UnmarshalProtoJSON ¶
func (x *OpType) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the OpType from JSON.
func (*OpType) UnmarshalText ¶
UnmarshalText unmarshals the OpType from text.
type PendingOp ¶
type PendingOp struct {
// contains filtered or unexported fields
}
PendingOp contains a pending operation with arguments.
func NewPendingOp ¶
func NewPendingOp( opType OpType, key []byte, value *forge_value.Value, valueIsBlob bool, outputName string, ) *PendingOp
NewPendingOp constructs a new pending op. value or outputName can be empty depending on the operation.
func (*PendingOp) Apply ¶
func (o *PendingOp) Apply( ctx context.Context, handle forge_target.ExecControllerHandle, btx kvtx.BlockTx, ) error
Apply applies the operation to the store.