Documentation ¶
Index ¶
- Constants
- Variables
- type ActionCapability
- type BaseCapability
- type CapabilityConfiguration
- type CapabilityInfo
- func MustNewCapabilityInfo(id string, capabilityType CapabilityType, description string) CapabilityInfo
- func MustNewRemoteCapabilityInfo(id string, capabilityType CapabilityType, description string, don *DON) CapabilityInfo
- func NewCapabilityInfo(id string, capabilityType CapabilityType, description string) (CapabilityInfo, error)
- func NewRemoteCapabilityInfo(id string, capabilityType CapabilityType, description string, don *DON) (CapabilityInfo, error)
- type CapabilityRequest
- type CapabilityResponse
- type CapabilityType
- type ConsensusCapability
- type DON
- type Executable
- type ExecutableCapability
- type Node
- type RegisterToWorkflowRequest
- type RegistrationMetadata
- type RemoteTargetConfig
- type RemoteTriggerConfig
- type RequestMetadata
- type TargetCapability
- type TriggerCapability
- type TriggerEvent
- type TriggerExecutable
- type TriggerRegistrationRequest
- type TriggerResponse
- type UnregisterFromWorkflowRequest
- type Validatable
- type Validator
- func (v *Validator[Config, Inputs, Outputs]) ConfigSchema() (string, error)
- func (v *Validator[Config, Inputs, Outputs]) InputsSchema() (string, error)
- func (v *Validator[Config, Inputs, Outputs]) OutputsSchema() (string, error)
- func (v *Validator[Config, Inputs, Outputs]) Schema() (string, error)
- func (v *Validator[Config, Inputs, Outputs]) ValidateConfig(config *values.Map) (*Config, error)
- func (v *Validator[Config, Inputs, Outputs]) ValidateInputs(inputs *values.Map) (*Inputs, error)
- func (v *Validator[Config, Inputs, Outputs]) ValidateOutputs(outputs *values.Map) (*Outputs, error)
- type ValidatorArgs
Constants ¶
const ( DefaultRegistrationRefresh = 30 * time.Second DefaultRegistrationExpiry = 2 * time.Minute DefaultMessageExpiry = 2 * time.Minute DefaultBatchSize = 100 DefaultBatchCollectionPeriod = 100 * time.Millisecond )
Variables ¶
var ( PromExecutionTimeMS = promauto.NewHistogramVec( prometheus.HistogramOpts{ Name: "capability_execution_time_ms", Help: "Metric representing the execution time in milliseconds", }, []string{"keystone_type", "id"}, ) PromTaskRunSuccessCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "capability_runs_count", Help: "Metric representing the number of runs completed successfully", }, []string{"keystone_type", "id"}, ) PromTaskRunFaultCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "capability_runs_fault_count", Help: "Metric representing the number of runs with an application fault", }, []string{"keystone_type", "id"}, ) PromTaskRunInvalidCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "capability_runs_invalid_count", Help: "Metric representing the number of runs with an application fault", }, []string{"keystone_type", "id"}, ) prometheus.CounterOpts{ Name: "capability_runs_unauthorized_count", Help: "Metric representing the number of runs with an application fault", }, []string{"keystone_type", "id"}, ) PromTaskRunNoResourceCount = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "capability_runs_no_resource_count", Help: "Metric representing the number of runs with an application fault", }, []string{"keystone_type", "id"}, ) )
var ErrStopExecution = &errStopExecution{}
Functions ¶
This section is empty.
Types ¶
type ActionCapability ¶
type ActionCapability interface { ExecutableCapability }
ActionCapability interface needs to be implemented by all action capabilities.
type BaseCapability ¶
type BaseCapability interface {
Info(ctx context.Context) (CapabilityInfo, error)
}
BaseCapability interface needs to be implemented by all capability types. Capability interfaces are intentionally duplicated to allow for an easy change or extension in the future.
type CapabilityConfiguration ¶
type CapabilityConfiguration struct { DefaultConfig *values.Map RemoteTriggerConfig *RemoteTriggerConfig RemoteTargetConfig *RemoteTargetConfig }
type CapabilityInfo ¶
type CapabilityInfo struct { // The capability ID is a fully qualified identifier for the capability. // // It takes the form of `{name}:{label1_key}_{labe1_value}:{label2_key}_{label2_value}@{version}` // // The labels within the ID are ordered alphanumerically. ID string CapabilityType CapabilityType Description string DON *DON IsLocal bool }
CapabilityInfo is a struct for the info of a capability.
func MustNewCapabilityInfo ¶
func MustNewCapabilityInfo( id string, capabilityType CapabilityType, description string, ) CapabilityInfo
MustNewCapabilityInfo returns a new CapabilityInfo, `panic`ing if we could not instantiate a CapabilityInfo.
func MustNewRemoteCapabilityInfo ¶
func MustNewRemoteCapabilityInfo( id string, capabilityType CapabilityType, description string, don *DON, ) CapabilityInfo
MustNewRemoteCapabilityInfo returns a new CapabilityInfo, `panic`ing if we could not instantiate a CapabilityInfo.
func NewCapabilityInfo ¶
func NewCapabilityInfo( id string, capabilityType CapabilityType, description string, ) (CapabilityInfo, error)
NewCapabilityInfo returns a new CapabilityInfo.
func NewRemoteCapabilityInfo ¶
func NewRemoteCapabilityInfo( id string, capabilityType CapabilityType, description string, don *DON, ) (CapabilityInfo, error)
NewRemoteCapabilityInfo returns a new CapabilityInfo for remote capabilities. This is largely intended for internal use by the registry syncer. Capability developers should use `NewCapabilityInfo` instead as this omits the requirement to pass in the DON Info.
func (CapabilityInfo) Info ¶
func (c CapabilityInfo) Info(ctx context.Context) (CapabilityInfo, error)
Info returns the info of the capability.
func (CapabilityInfo) Version ¶
func (c CapabilityInfo) Version() string
Parse out the version from the ID.
type CapabilityRequest ¶
type CapabilityRequest struct { Metadata RequestMetadata Config *values.Map Inputs *values.Map }
CapabilityRequest is a struct for the Execute request of a capability.
type CapabilityResponse ¶
CapabilityResponse is a struct for the Execute response of a capability.
type CapabilityType ¶
type CapabilityType string
CapabilityType is an enum for the type of capability.
const ( CapabilityTypeUnknown CapabilityType = "unknown" CapabilityTypeTrigger CapabilityType = "trigger" CapabilityTypeAction CapabilityType = "action" CapabilityTypeConsensus CapabilityType = "consensus" CapabilityTypeTarget CapabilityType = "target" )
CapabilityType enum values.
func (CapabilityType) IsValid ¶
func (c CapabilityType) IsValid() error
IsValid checks if the capability type is valid.
type ConsensusCapability ¶
type ConsensusCapability interface { ExecutableCapability }
ConsensusCapability interface needs to be implemented by all consensus capabilities.
type DON ¶
type DON struct { ID uint32 ConfigVersion uint32 Members []p2ptypes.PeerID F uint8 IsPublic bool AcceptsWorkflows bool }
DON represents a network of connected nodes.
For an example of an empty DON check, see the following link: https://github.com/goplugin/pluginv3.0/blob/develop/core/capabilities/transmission/local_target_capability.go#L31
type Executable ¶
type Executable interface { RegisterToWorkflow(ctx context.Context, request RegisterToWorkflowRequest) error UnregisterFromWorkflow(ctx context.Context, request UnregisterFromWorkflowRequest) error Execute(ctx context.Context, request CapabilityRequest) (CapabilityResponse, error) }
Executable is an interface for executing a capability.
type ExecutableCapability ¶
type ExecutableCapability interface { BaseCapability Executable }
ExecutableCapability is the interface implemented by action, consensus and target capabilities. This interface is useful when trying to capture capabilities of varying types.
type Node ¶
Node contains the node's peer ID and the DONs it is part of.
Note the following relationships between the workflow and capability DONs and this node.
There is a 1:0..1 relationship between this node and a workflow DON. This means that this node can be part at most one workflow DON at a time. As a side note, a workflow DON can have multiple nodes.
There is a 1:N relationship between this node and capability DONs, where N is the number of capability DONs. This means that this node can be part of multiple capability DONs at a time.
Although WorkflowDON is a value rather than a pointer, a node can be part of no workflow DON but 0 or more capability DONs. You can assert this by checking for zero values in the WorkflowDON field. See https://github.com/goplugin/pluginv3.0/blob/develop/core/capabilities/transmission/local_target_capability.go#L31 for an example.
type RegisterToWorkflowRequest ¶
type RegisterToWorkflowRequest struct { Metadata RegistrationMetadata Config *values.Map }
type RegistrationMetadata ¶
type RemoteTargetConfig ¶
type RemoteTargetConfig struct {
RequestHashExcludedAttributes []string
}
type RemoteTriggerConfig ¶
type RemoteTriggerConfig struct { RegistrationRefresh time.Duration RegistrationExpiry time.Duration MinResponsesToAggregate uint32 MessageExpiry time.Duration MaxBatchSize uint32 BatchCollectionPeriod time.Duration }
func (*RemoteTriggerConfig) ApplyDefaults ¶
func (c *RemoteTriggerConfig) ApplyDefaults()
NOTE: consider splitting this config into values stored in Registry (KS-118) and values defined locally by Capability owners.
type RequestMetadata ¶
type TargetCapability ¶
type TargetCapability interface { ExecutableCapability }
TargetsCapability interface needs to be implemented by all target capabilities.
type TriggerCapability ¶
type TriggerCapability interface { BaseCapability TriggerExecutable }
TriggerCapability interface needs to be implemented by all trigger capabilities.
type TriggerEvent ¶
type TriggerExecutable ¶
type TriggerExecutable interface { RegisterTrigger(ctx context.Context, request TriggerRegistrationRequest) (<-chan TriggerResponse, error) UnregisterTrigger(ctx context.Context, request TriggerRegistrationRequest) error }
type TriggerRegistrationRequest ¶
type TriggerRegistrationRequest struct { // TriggerID uniquely identifies the trigger by concatenating // the workflow ID and the trigger's index in the spec. TriggerID string Metadata RequestMetadata Config *values.Map }
type TriggerResponse ¶
type TriggerResponse struct { Event TriggerEvent Err error }
type UnregisterFromWorkflowRequest ¶
type UnregisterFromWorkflowRequest struct { Metadata RegistrationMetadata Config *values.Map }
type Validatable ¶
type Validator ¶
type Validator[Config any, Inputs any, Outputs any] struct { ValidatorArgs // contains filtered or unexported fields }
A Validator can validate the config, inputs, and outputs of a capability.
The library generates a JSON schema for each of these types to both describe the types in a language-agnostic way and to validate the API boundary of the capability.
To see how to annotate your structs with JSON schema tags, take a look at the jsonschema package.
func NewValidator ¶
func NewValidator[Config any, Inputs any, Outputs any](args ValidatorArgs) Validator[Config, Inputs, Outputs]
func (*Validator[Config, Inputs, Outputs]) ConfigSchema ¶
func (*Validator[Config, Inputs, Outputs]) InputsSchema ¶
func (*Validator[Config, Inputs, Outputs]) OutputsSchema ¶
func (*Validator[Config, Inputs, Outputs]) Schema ¶
Schema returns the a JSON schema that combines the config, inputs, and outputs into a single schema.
This fully describes the capability's API boundary.
func (*Validator[Config, Inputs, Outputs]) ValidateConfig ¶
func (*Validator[Config, Inputs, Outputs]) ValidateInputs ¶
type ValidatorArgs ¶
type ValidatorArgs struct { Info CapabilityInfo // You can customize each one of the reflectors // or leave them nil to use the default reflector. // // You can also override the default reflector by setting // the DefaultReflector field. DefaultReflector *jsonschema.Reflector SchemaReflector *jsonschema.Reflector ConfigReflector *jsonschema.Reflector InputsReflector *jsonschema.Reflector OutputsReflector *jsonschema.Reflector }