Documentation
¶
Index ¶
- Constants
- Variables
- func InvokeActionEvaluation(contextId string, action Action, input []byte) ([]byte, error)
- func MarshalVal(schema Schema, val cty.Value) ([]byte, error)
- func UnmarshalVal(schema Schema, data []byte) (cty.Value, error)
- type Action
- type ActionEvalData
- type AttrSchema
- type BlockSchema
- type Function
- type GlobalConfig
- type InitData
- type ObjectSchema
- type Provider
- type ProviderConfig
- type ProviderPlugin
- type ProviderRPCClient
- func (p *ProviderRPCClient) ActionConfigurationSchema(name string) (ObjectSchema, error)
- func (p *ProviderRPCClient) ActionEvaluate(contextId string, name string, input []byte) ([]byte, error)
- func (p *ProviderRPCClient) ActionNames() ([]string, error)
- func (p *ProviderRPCClient) ActionOutputType(name string) (Type, error)
- func (p *ProviderRPCClient) CreateSubscription(contextId string, input []byte) ([]byte, error)
- func (p *ProviderRPCClient) DeleteSubscription(contextId string, subscriptionId string) error
- func (p *ProviderRPCClient) Init(runnerProvider RunnerProvider) (ProviderConfig, error)
- func (p *ProviderRPCClient) InitSchema() (ObjectSchema, error)
- func (p *ProviderRPCClient) MapPayloadToTrigger(data []byte) (string, error)
- func (p *ProviderRPCClient) ReadSubscription(contextId string, subscriptionId string) ([]byte, error)
- func (p *ProviderRPCClient) TriggerConfigurationSchema(name string) (ObjectSchema, error)
- func (p *ProviderRPCClient) TriggerNames() ([]string, error)
- func (p *ProviderRPCClient) TriggerOutputType(name string) (Type, error)
- func (p *ProviderRPCClient) UpdateSubscription(contextId string, subscriptionId string, input []byte) ([]byte, error)
- type ProviderRPCServer
- func (p *ProviderRPCServer) ActionConfigurationSchema(name string, reply *ObjectSchema) error
- func (p *ProviderRPCServer) ActionEvaluate(payload ActionEvalData, reply *[]byte) error
- func (p *ProviderRPCServer) ActionNames(_ any, reply *[]string) error
- func (p *ProviderRPCServer) ActionOutputType(name string, reply *Type) error
- func (p *ProviderRPCServer) CreateSubscription(data SubscriptionData, reply *[]byte) error
- func (p *ProviderRPCServer) DeleteSubscription(data SubscriptionData) error
- func (p *ProviderRPCServer) Init(runnerProvider RunnerProvider, reply *ProviderConfig) error
- func (p *ProviderRPCServer) InitSchema(_ any, reply *ObjectSchema) error
- func (p *ProviderRPCServer) MapPayloadToTrigger(data []byte, reply *string) error
- func (p *ProviderRPCServer) ReadSubscription(data SubscriptionData, reply *[]byte) error
- func (p *ProviderRPCServer) TriggerConfigurationSchema(name string, reply *ObjectSchema) error
- func (p *ProviderRPCServer) TriggerNames(_ any, reply *[]string) error
- func (p *ProviderRPCServer) TriggerOutputType(name string, reply *Type) error
- func (p *ProviderRPCServer) UpdateSubscription(data SubscriptionData, reply *[]byte) error
- type RunnerProvider
- type Schema
- type SubscriptionData
- type Trigger
- type Type
Constants ¶
const ( NUMBER_TYPE = "number" BOOLEAN_TYPE = "bool" STRING_TYPE = "string" OBJECT_TYPE = "object" MAP_TYPE = "map" LIST_TYPE = "list" DYNAMIC_TYPE = "dynamic" INVALID_TYPE = "invalid" TYPE_NAME_KEY = "type_name" TYPE_NESTED_VALUES_KEY = "nested_values" TYPE_INTERNAL_TYPE_KEY = "internal_type" )
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 2,
MagicCookieKey: "Switchboard",
MagicCookieValue: "Plugin",
}
Functions ¶
func InvokeActionEvaluation ¶
Types ¶
type ActionEvalData ¶ added in v0.0.5
type AttrSchema ¶
AttrSchema represents a key/val coming from the provided data structure
func OptionalAttrSchema ¶
func OptionalAttrSchema(name string, valType Type) *AttrSchema
func RequiredAttrSchema ¶
func RequiredAttrSchema(name string, valType Type) *AttrSchema
func (*AttrSchema) Decode ¶
func (b *AttrSchema) Decode() hcldec.Spec
type BlockSchema ¶
BlockSchema maps to block types from the Config. Blocks with labels are not supported, meaning only one block type per provided Config is permitted
func OptionalBlockSchema ¶
func OptionalBlockSchema(name string, nested Schema) *BlockSchema
func (*BlockSchema) Decode ¶
func (b *BlockSchema) Decode() hcldec.Spec
type Function ¶
type Function interface { // ConfigurationSchema returns an ObjectSpec that returns all required/optional blocks and attributes // in an Action or Trigger. This should include all general configuration settings, as well as all details // pertinent to an individual interaction (api call, event publish, etc.) with the integration ConfigurationSchema() (ObjectSchema, error) // OutputType provides a schema structure for the result of an Action or Trigger. This is an essential component // of using output from one action in a workflow as the Input of another, as well as pre-deployment // configuration validation. Note, this does not return an ObjectSchema because that type is primarily // used for helping the calling application know how the hcl Config data should look. OutputType() (Type, error) }
type GlobalConfig ¶ added in v0.0.5
type GlobalConfig struct { //PublicUri tells each provider where they should register //triggers that are http based PublicIngestUri string //PrivateUri is used by providers that have event subscriptions that are received directly by the provider, //such as event-queue triggers or polling-style event listeners. This PrivateIngestUri string }
GlobalConfig contains details related to the core switchboard instance that each provider may use as they see fit in their implementations
type InitData ¶ added in v0.0.5
type InitData struct { GlobalConfig GlobalConfig UserConfig []byte }
type ObjectSchema ¶
ObjectSchema is primarily used as root of all schemas in switchboard. This enforces a key/value style of Config for anything using this. Many Provider interface methods will return this to enforce a certain style of how providers expect user Config data to look.
func (*ObjectSchema) Decode ¶
func (s *ObjectSchema) Decode() hcldec.Spec
type Provider ¶
type Provider interface { //Init is called shortly after loading a plugin, and gives the provider access to certain //data owned by the runner // //It hands the provider an instance of the ContextProvider interface, which will //be implemented by the runner, and various methods should be called to get context/config //information from the runner. Init(runnerProvider RunnerProvider) (ProviderConfig, error) //InitSchema is used by the CLI to validate user provided Config, and is also used in Init //to unmarshal the string into a cty.Value InitSchema() (ObjectSchema, error) //MapPayloadToTrigger maps an incoming event to a trigger. This is relevant //for providers who send many events to one endpoint, and will not be called //if one event is mapped to one trigger MapPayloadToTrigger([]byte) (string, error) //ActionNames returns a list of available actions from a provider ActionNames() ([]string, error) TriggerNames() ([]string, error) //ActionEvaluate is the implementation of a particular action as defined by the provider. //It is called by its name as listed in ActionNames. The input param must conform to the schema provided by ActionConfigurationSchema ActionEvaluate(contextId string, name string, input []byte) ([]byte, error) //ActionConfigurationSchema returns a data structure representing the expected schema //in the user-provided hcl configuration file for a particular action ActionConfigurationSchema(name string) (ObjectSchema, error) //ActionOutputType returns a data structure representing the result-type of a particular //action on success. This is used for both converting data to a dynamic cty.Value, and //for validating correct user-defined configuration ActionOutputType(name string) (Type, error) //TriggerConfigurationSchema is similar to ActionConfigurationSchema, but for triggers TriggerConfigurationSchema(name string) (ObjectSchema, error) //TriggerOutputType is similar to ActionOutputType, but for triggers TriggerOutputType(name string) (Type, error) //CreateSubscription subscribes to the provider for one or all triggers. Some providers //register a subscription for each trigger. Others subscribe for all in one. input param //may be a list of triggers, or a single trigger, as they conform to the configuration schema. //It returns a representation of the resulting state of the subscription CreateSubscription(contextId string, input []byte) ([]byte, error) //ReadSubscription will get the current state value of the trigger from the integration provider ReadSubscription(contextId string, subscriptionId string) ([]byte, error) //UpdateSubscription will update the trigger and return the new state value to the runner UpdateSubscription(contextId string, subscriptionId string, input []byte) ([]byte, error) //DeleteSubscription with remove the trigger and event subscription to the vendor DeleteSubscription(contextId string, subscriptionId string) error }
Provider is the main interface that must be implemented by every integration provider in order to work with the Switchboard runner service. In addition to provider specific methods, the provider also includes proxy methods to call on specific Action or Trigger implementations (this way, we don't have to register every Action and Trigger as a plugin)
Every method returns an error as the last return type so that we can gracefully deal with any RPC related errors in the go-plugin client implementation of this interface.
func NewProviderRPCClient ¶
func NewProviderRPCClient() Provider
type ProviderConfig ¶ added in v0.0.5
type ProviderConfig struct {
SubscriptionsRegisteredTogether bool
}
ProviderConfig is some static information the runner can use to decipher how to process certain types of provider setups.
type ProviderPlugin ¶
type ProviderPlugin struct {
Impl Provider
}
func (*ProviderPlugin) Client ¶
func (p *ProviderPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
func (*ProviderPlugin) Server ¶
func (p *ProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error)
type ProviderRPCClient ¶
type ProviderRPCClient struct {
// contains filtered or unexported fields
}
func (*ProviderRPCClient) ActionConfigurationSchema ¶
func (p *ProviderRPCClient) ActionConfigurationSchema(name string) (ObjectSchema, error)
func (*ProviderRPCClient) ActionEvaluate ¶
func (*ProviderRPCClient) ActionNames ¶
func (p *ProviderRPCClient) ActionNames() ([]string, error)
func (*ProviderRPCClient) ActionOutputType ¶
func (p *ProviderRPCClient) ActionOutputType(name string) (Type, error)
func (*ProviderRPCClient) CreateSubscription ¶ added in v0.0.5
func (p *ProviderRPCClient) CreateSubscription(contextId string, input []byte) ([]byte, error)
func (*ProviderRPCClient) DeleteSubscription ¶ added in v0.0.5
func (p *ProviderRPCClient) DeleteSubscription(contextId string, subscriptionId string) error
func (*ProviderRPCClient) Init ¶
func (p *ProviderRPCClient) Init(runnerProvider RunnerProvider) (ProviderConfig, error)
func (*ProviderRPCClient) InitSchema ¶
func (p *ProviderRPCClient) InitSchema() (ObjectSchema, error)
func (*ProviderRPCClient) MapPayloadToTrigger ¶ added in v0.0.5
func (p *ProviderRPCClient) MapPayloadToTrigger(data []byte) (string, error)
func (*ProviderRPCClient) ReadSubscription ¶ added in v0.0.5
func (p *ProviderRPCClient) ReadSubscription(contextId string, subscriptionId string) ([]byte, error)
func (*ProviderRPCClient) TriggerConfigurationSchema ¶ added in v0.0.5
func (p *ProviderRPCClient) TriggerConfigurationSchema(name string) (ObjectSchema, error)
func (*ProviderRPCClient) TriggerNames ¶ added in v0.0.5
func (p *ProviderRPCClient) TriggerNames() ([]string, error)
func (*ProviderRPCClient) TriggerOutputType ¶ added in v0.0.5
func (p *ProviderRPCClient) TriggerOutputType(name string) (Type, error)
func (*ProviderRPCClient) UpdateSubscription ¶ added in v0.0.5
type ProviderRPCServer ¶
type ProviderRPCServer struct {
Impl Provider
}
func (*ProviderRPCServer) ActionConfigurationSchema ¶
func (p *ProviderRPCServer) ActionConfigurationSchema(name string, reply *ObjectSchema) error
func (*ProviderRPCServer) ActionEvaluate ¶
func (p *ProviderRPCServer) ActionEvaluate(payload ActionEvalData, reply *[]byte) error
func (*ProviderRPCServer) ActionNames ¶
func (p *ProviderRPCServer) ActionNames(_ any, reply *[]string) error
func (*ProviderRPCServer) ActionOutputType ¶
func (p *ProviderRPCServer) ActionOutputType(name string, reply *Type) error
func (*ProviderRPCServer) CreateSubscription ¶ added in v0.0.5
func (p *ProviderRPCServer) CreateSubscription(data SubscriptionData, reply *[]byte) error
func (*ProviderRPCServer) DeleteSubscription ¶ added in v0.0.5
func (p *ProviderRPCServer) DeleteSubscription(data SubscriptionData) error
func (*ProviderRPCServer) Init ¶
func (p *ProviderRPCServer) Init(runnerProvider RunnerProvider, reply *ProviderConfig) error
func (*ProviderRPCServer) InitSchema ¶
func (p *ProviderRPCServer) InitSchema(_ any, reply *ObjectSchema) error
func (*ProviderRPCServer) MapPayloadToTrigger ¶ added in v0.0.5
func (p *ProviderRPCServer) MapPayloadToTrigger(data []byte, reply *string) error
func (*ProviderRPCServer) ReadSubscription ¶ added in v0.0.5
func (p *ProviderRPCServer) ReadSubscription(data SubscriptionData, reply *[]byte) error
func (*ProviderRPCServer) TriggerConfigurationSchema ¶ added in v0.0.5
func (p *ProviderRPCServer) TriggerConfigurationSchema(name string, reply *ObjectSchema) error
func (*ProviderRPCServer) TriggerNames ¶ added in v0.0.5
func (p *ProviderRPCServer) TriggerNames(_ any, reply *[]string) error
func (*ProviderRPCServer) TriggerOutputType ¶ added in v0.0.5
func (p *ProviderRPCServer) TriggerOutputType(name string, reply *Type) error
func (*ProviderRPCServer) UpdateSubscription ¶ added in v0.0.5
func (p *ProviderRPCServer) UpdateSubscription(data SubscriptionData, reply *[]byte) error
type RunnerProvider ¶ added in v0.0.5
type RunnerProvider interface { //UserConfig is a byte string that should conform to the Schema //as specified by Provider.InitSchema method. The contextId parameter //is a specific namespace for a provider (you can have multiple provider configurations //in switchboard). This also provides a future-compatible interface for embedded //integration setups where actions in one workflow may have a dynamic //configuration context UserConfig(contextId string) []byte GlobalConfig() GlobalConfig }
type Schema ¶
type Schema interface { //Decode transforms a Schema struct into a hcldec.Spec so that hcl Config data can be serialized //into a usable value and passed to the provider. This is primarily used in the runner application //where hcl is being parsed. Decode() hcldec.Spec }
Schema is an interface implemented by various serializable structs that are used by provider implementations to define the structure of hcl Config data as it is passed by the user. Schemas are pulled from the runner of CLI to tell the hcl decoder what the user Config should look like. All structs that implement this interface MUST use exportable/public properties. non-exportable/private properties will not work when sending data over the wire.
type SubscriptionData ¶ added in v0.0.5
type Trigger ¶
type Trigger interface { Function }
Trigger is an interface that maps all entry points for integrations. Triggers are registered with the integration all at once or individually, depending on the provider.
type Type ¶
type Type struct { //TypeName is a string representation of the underlying type TypeName string //NestedValues is used exclusively for an "object" type NestedValues *map[string]Type //InternalType is used to represent what type the value of a list or map value is. InternalType *Type }
Type is a serializable data structure that helps the CLI and runner understand what data structures in configuration should look like.
var Bool Type
Bool represents a primitive boolean type
var Dynamic Type
Dynamic represents a type that can be anything. This is not recommended as these values cannot be validated ahead of time in user configuration. Only use this value when the underlying type is uncertain and variable.
var Invalid Type
Invalid is used as an error value for types
var Number Type
Number represents a primitive numeric type
var String Type
String represents a primitive string type
func Map ¶
Map creates a map with unknown keys but known values as a Type object. Use this when the map keys are unknown/variable, but values are known