Documentation ¶
Index ¶
- Constants
- func GetTemplateContent(value string) string
- func IsReference(value string) bool
- func IsString(value string) bool
- func IsTemplate(value string) bool
- func JoinPath(values ...string) (result string)
- func ResourcePath(resource string, paths ...string) string
- func SplitPath(path string) []string
- type Call
- type Condition
- type Dependencies
- type Endpoint
- type EndpointList
- type Enum
- type EnumValue
- type ErrLabelMismatch
- type ErrPathNotFound
- type ErrTypeMismatch
- type ErrUndeclaredSchema
- type ErrUndeclaredSchemaInProperty
- type ErrUndefinedSchema
- type ErrorHandle
- type Evaluable
- type Expression
- type Flow
- func (flow *Flow) GetForward() *Call
- func (flow *Flow) GetInput() *ParameterMap
- func (flow *Flow) GetMeta() *metadata.Meta
- func (flow *Flow) GetName() string
- func (flow *Flow) GetNodes() NodeList
- func (flow *Flow) GetOnError() *OnError
- func (flow *Flow) GetOutput() *ParameterMap
- func (flow *Flow) GetRewrite() []Rewrite
- func (flow *Flow) SetNodes(nodes NodeList)
- type FlowInterface
- type FlowList
- type FlowListInterface
- type Header
- type Message
- type Method
- type Node
- type NodeList
- type NodeType
- type OnError
- type OneOf
- type Options
- type ParameterMap
- type Property
- type PropertyList
- type PropertyReference
- type Proxy
- func (proxy *Proxy) GetForward() *Call
- func (proxy *Proxy) GetInput() *ParameterMap
- func (proxy *Proxy) GetMeta() *metadata.Meta
- func (proxy *Proxy) GetName() string
- func (proxy *Proxy) GetNodes() NodeList
- func (proxy *Proxy) GetOnError() *OnError
- func (proxy *Proxy) GetOutput() *ParameterMap
- func (proxy *Proxy) GetRewrite() []Rewrite
- func (proxy *Proxy) SetNodes(nodes NodeList)
- type ProxyList
- type Repeated
- type Rewrite
- type Scalar
- type Schemas
- type Service
- type ServiceDiscoveryClient
- type ServiceDiscoveryClients
- type ServiceList
- type Template
- func (template Template) Clone() Template
- func (template Template) Compare(expected Template) (err error)
- func (template Template) DefaultValue() interface{}
- func (template *Template) Define(expected Template)
- func (template Template) ShallowClone() Template
- func (template Template) Type() types.Type
Constants ¶
const ( // TemplateOpen tag TemplateOpen = "{{" // TemplateClose tag TemplateClose = "}}" // PathDelimiter represents the path reference delimiter PathDelimiter = "." // InputResource key InputResource = "input" // OutputResource key OutputResource = "output" // StackResource property StackResource = "stack" // ParamsResource property ParamsResource = "params" // RequestResource property RequestResource = "request" // HeaderResource property HeaderResource = "header" // ResponseResource property ResponseResource = "response" // ErrorResource property ErrorResource = "error" // DefaultInputResource represents the default input property on resource select DefaultInputResource = RequestResource // DefaultCallResource represents the default call property on resource select DefaultCallResource = ResponseResource )
const ReferenceDelimiter = ":"
ReferenceDelimiter represents the value resource reference delimiter.
Variables ¶
This section is empty.
Functions ¶
func GetTemplateContent ¶
GetTemplateContent trims the opening and closing tags from the given template value
func IsReference ¶
IsReference returns true if the given value is a reference value
func IsTemplate ¶
IsTemplate checks whether the given value is a template
func ResourcePath ¶
ResourcePath constructs a new path using the given resource and path.
Types ¶
type Call ¶
type Call struct { *metadata.Meta Service string `json:"service,omitempty"` Method string `json:"method,omitempty"` Request *ParameterMap `json:"request,omitempty"` Response *ParameterMap `json:"response,omitempty"` Descriptor *Method `json:"-"` }
Call represents a call which is executed during runtime
type Condition ¶
type Condition struct { *metadata.Meta RawExpression string `json:"raw_expression,omitempty"` Evaluable `json:"-"` Params *ParameterMap `json:"-"` }
Condition represents a condition which could be true or false
func (Condition) GetParameters ¶
func (c Condition) GetParameters() *ParameterMap
GetParameters returns the list of parameters
type Dependencies ¶
Dependencies represents a collection of node dependencies
func (Dependencies) Append ¶
func (dependencies Dependencies) Append(input Dependencies) Dependencies
Append appends the given input to the already existing dependencies and returns the result
type Endpoint ¶
type Endpoint struct { *metadata.Meta Flow string `json:"flow,omitempty"` Listener string `json:"listener,omitempty"` Options Options `json:"options,omitempty"` }
Endpoint exposes a flow. Endpoints are not parsed by Semaphore and have custom implementations in each caller. The name of the endpoint represents the flow which should be executed.
type EndpointList ¶
type EndpointList []*Endpoint
EndpointList represents a collection of endpoints
func (*EndpointList) Append ¶
func (endpoints *EndpointList) Append(list EndpointList)
Append merges the incoming manifest to the existing (left) manifest
func (EndpointList) Get ¶
func (endpoints EndpointList) Get(flow string) []*Endpoint
Get returns all endpoints for the given flow
type Enum ¶
type Enum struct { *metadata.Meta Name string `json:"name,omitempty" yaml:"name,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Keys map[string]*EnumValue `json:"keys,omitempty" yaml:"keys,omitempty"` Positions map[int32]*EnumValue `json:"positions,omitempty" yaml:"positions,omitempty"` }
Enum represents a enum configuration
type EnumValue ¶
type EnumValue struct { *metadata.Meta Key string `json:"key,omitempty"` Position int32 `json:"position,omitempty"` Description string `json:"description,omitempty"` }
EnumValue represents a enum configuration
type ErrLabelMismatch ¶
type ErrLabelMismatch struct { Label labels.Label Expected labels.Label Path string Expr Expression }
ErrLabelMismatch occurs when given label does not match with expected label
func (ErrLabelMismatch) Error ¶
func (e ErrLabelMismatch) Error() string
Error returns a description of the given error as a string
func (ErrLabelMismatch) Prettify ¶
func (e ErrLabelMismatch) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrPathNotFound ¶
type ErrPathNotFound struct {
Path string
}
ErrPathNotFound occurs when path cannot be resolved
func (ErrPathNotFound) Error ¶
func (e ErrPathNotFound) Error() string
Error returns a description of the given error as a string
func (ErrPathNotFound) Prettify ¶
func (e ErrPathNotFound) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrTypeMismatch ¶
type ErrTypeMismatch struct { Type interface{} Expected interface{} Path string Expr Expression }
ErrTypeMismatch occurs when given typs does not match with expected type
func (ErrTypeMismatch) Error ¶
func (e ErrTypeMismatch) Error() string
Error returns a description of the given error as a string
func (ErrTypeMismatch) Prettify ¶
func (e ErrTypeMismatch) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrUndeclaredSchema ¶
type ErrUndeclaredSchema struct { Name string Path string Expr Expression }
ErrUndeclaredSchema occurs when nested object does not have schema
func (ErrUndeclaredSchema) Error ¶
func (e ErrUndeclaredSchema) Error() string
Error returns a description of the given error as a string
func (ErrUndeclaredSchema) Prettify ¶
func (e ErrUndeclaredSchema) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrUndeclaredSchemaInProperty ¶
type ErrUndeclaredSchemaInProperty struct { Name string Path string Expr Expression }
ErrUndeclaredSchemaInProperty occurs when nested property does not have schema
func (ErrUndeclaredSchemaInProperty) Error ¶
func (e ErrUndeclaredSchemaInProperty) Error() string
Error returns a description of the given error as a string
func (ErrUndeclaredSchemaInProperty) Prettify ¶
func (e ErrUndeclaredSchemaInProperty) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrUndefinedSchema ¶
type ErrUndefinedSchema struct { Path string Expr Expression }
ErrUndefinedSchema occurs when schema is not found at path
func (ErrUndefinedSchema) Error ¶
func (e ErrUndefinedSchema) Error() string
Error returns a description of the given error as a string
func (ErrUndefinedSchema) Prettify ¶
func (e ErrUndefinedSchema) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrorHandle ¶
type ErrorHandle interface { GetResponse() *ParameterMap GetStatusCode() *Property GetMessage() *Property }
ErrorHandle represents a error handle object
type Expression ¶
type Expression interface {
Position() string
}
Expression provides information about expression.
type Flow ¶
type Flow struct { *metadata.Meta Name string `json:"name,omitempty"` Input *ParameterMap `json:"input,omitempty"` Nodes NodeList `json:"nodes,omitempty"` Output *ParameterMap `json:"output,omitempty"` OnError *OnError `json:"on_error,omitempty"` }
Flow defines a set of calls that should be called chronologically and produces an output message. Calls could reference other resources when constructing messages. All references are strictly typed and fetched from the configured schemas.
All flows should contain a unique name. Calls are nested inside of flows and contain two labels, a unique name within the flow and the service and method to be called. A dependency reference structure is generated within the flow which allows Semaphore to figure out which calls could be called parallel to improve performance.
func (*Flow) GetForward ¶
GetForward returns the proxy forward of the given flow
func (*Flow) GetInput ¶
func (flow *Flow) GetInput() *ParameterMap
GetInput returns the input of the given flow
func (*Flow) GetOnError ¶
GetOnError returns the error handling of the given flow
func (*Flow) GetOutput ¶
func (flow *Flow) GetOutput() *ParameterMap
GetOutput returns the output of the given flow
func (*Flow) GetRewrite ¶
GetRewrite returns the rewrite rules of the given flow
type FlowInterface ¶
type FlowInterface interface { GetMeta() *metadata.Meta GetName() string GetNodes() NodeList SetNodes(NodeList) GetInput() *ParameterMap GetOutput() *ParameterMap GetOnError() *OnError GetForward() *Call GetRewrite() []Rewrite }
FlowInterface represents a proxy or flow manager.
type FlowList ¶
type FlowList []*Flow
FlowList represents a collection of flows
type FlowListInterface ¶
type FlowListInterface []FlowInterface
FlowListInterface represents a collection of flow interfaces
func (*FlowListInterface) Append ¶
func (collection *FlowListInterface) Append(list FlowListInterface)
Append appends the given flow list to the collection
func (FlowListInterface) Get ¶
func (collection FlowListInterface) Get(name string) FlowInterface
Get attempts to find a flow matching the given name
type Message ¶
Message represents an object which keeps the original order of keys.
func (Message) SortedProperties ¶
func (message Message) SortedProperties() PropertyList
SortedProperties returns the available properties as a properties list ordered base on the properties position.
type Method ¶
type Method struct { *metadata.Meta Comment string `json:"comment,omitempty"` Name string `json:"name,omitempty"` Input string `json:"input,omitempty"` Output string `json:"output,omitempty"` Options Options `json:"options,omitempty"` }
Method represents a service method
type Node ¶
type Node struct { *metadata.Meta Type NodeType `json:"type,omitempty"` ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Intermediate *ParameterMap `json:"intermediate,omitempty"` Condition *Condition `json:"condition,omitempty"` DependsOn Dependencies `json:"depends_on,omitempty"` Call *Call `json:"call,omitempty"` Rollback *Call `json:"rollback,omitempty"` ExpectStatus []int `json:"expect_status,omitempty"` OnError *OnError `json:"on_error,omitempty"` }
Node represents a point inside a given flow where a request or rollback could be preformed. Nodes could be executed synchronously or asynchronously. All calls are referencing a service method, the service should match the alias defined inside the service. The request and response proto messages are used for type definitions. A call could contain the request headers, request body, rollback, and the execution type.
func (*Node) GetOnError ¶
GetOnError returns the error handling for the given node
type NodeType ¶
type NodeType string
NodeType represents the type of the given node. A type determines the purpose of the node but not the implementation.
var ( // NodeCall is assigned when the given node is used to call a external service NodeCall NodeType = "call" // NodeCondition is assigned when the given node is used to execute a // conditional expression. NodeCondition NodeType = "condition" // NodeIntermediate is assigned when the node is used as a coming in // between nodes. NodeIntermediate NodeType = "intermediate" )
type OnError ¶
type OnError struct { *metadata.Meta Response *ParameterMap `json:"response,omitempty"` // Question: does it make sense to use full property here or just a Template is enough? Status *Property `json:"status,omitempty"` Message *Property `json:"message,omitempty"` Params map[string]*Property `json:"params,omitempty"` }
OnError represents the variables that have to be returned if a unexpected error is returned
func (*OnError) GetMessage ¶
GetMessage returns the message property
func (*OnError) GetResponse ¶
func (err *OnError) GetResponse() *ParameterMap
GetResponse returns the error response
func (*OnError) GetStatusCode ¶
GetStatusCode returns the status code property
type OneOf ¶
type OneOf []Template
OneOf is a mixed type to let the schema validate values against exactly one of the templates. Example:
OneOf{ {Scalar: &Scalar{Type: types.String}}, {Scalar: &Scalar{Type: types.Int32}}, {Message: &Message{...}}, }
A given value must be one of these types: string, int32 or the message.
type ParameterMap ¶
type ParameterMap struct { *metadata.Meta DependsOn Dependencies `json:"depends_on,omitempty"` Schema string `json:"schema,omitempty"` Params map[string]*Property `json:"params,omitempty"` Options Options `json:"options,omitempty"` Header Header `json:"header,omitempty"` Property *Property `json:"property,omitempty"` Stack map[string]*Property `json:"stack,omitempty"` }
ParameterMap is the initial map of parameter names (keys) and their (templated) values (values)
func (*ParameterMap) Clone ¶
func (parameters *ParameterMap) Clone() *ParameterMap
Clone clones the given parameter map
type Property ¶
type Property struct { *metadata.Meta Name string `json:"name,omitempty" yaml:"name,omitempty"` // Name represents the name of the given property Path string `json:"path,omitempty" yaml:"path,omitempty"` // Path represents the full path to the given property Description string `json:"description,omitempty" yaml:"description,omitempty"` // Description holds the description of the given property used to describe its use Position int32 `json:"position,omitempty" yaml:"position,omitempty"` // Position of the given property (in array/object) Options Options `json:"options,omitempty" yaml:"options,omitempty"` // Options holds variable options used inside single modules or components Expr Expression `json:"expression,omitempty"` // Expr represents the position on where the given property is defined Raw string `json:"raw,omitempty"` // Raw holds the raw template string used to define the given property Label labels.Label `json:"label,omitempty" yaml:"label,omitempty"` // Label label describes the usage of a given property ex: optional Template `json:"template" yaml:"template"` }
Property represents a value property.
func ParseTemplateProperty ¶
func ParseTemplateProperty(path string, name string, value string, parsedTemplate Template) *Property
ParseTemplateProperty returns the correct property for the given (parsed)template.
func (*Property) DefaultValue ¶
func (property *Property) DefaultValue() interface{}
DefaultValue returns the default value for a given property.
func (*Property) ShallowClone ¶
ShallowClone clones the given property but ignores the defined template and/or nested properties. This method is often used in cases where comparisons between the flow and schema are made and any defined properties are seen as defined values.
type PropertyList ¶
type PropertyList []*Property
PropertyList represents a list of properties
func (PropertyList) Get ¶
func (list PropertyList) Get(key string) *Property
Get attempts to return a property inside the given list with the given name
func (PropertyList) Len ¶
func (list PropertyList) Len() int
func (PropertyList) Less ¶
func (list PropertyList) Less(i, j int) bool
func (PropertyList) Swap ¶
func (list PropertyList) Swap(i, j int)
type PropertyReference ¶
type PropertyReference struct { *metadata.Meta Resource string `json:"resource,omitempty"` Path string `json:"path,omitempty"` Property *Property `json:"-"` }
PropertyReference represents a mustach template reference
func ParsePropertyReference ¶
func ParsePropertyReference(value string) *PropertyReference
ParsePropertyReference parses the given value to a property reference.
func (*PropertyReference) Clone ¶
func (reference *PropertyReference) Clone() *PropertyReference
Clone clones the given property reference
func (*PropertyReference) String ¶
func (reference *PropertyReference) String() string
type Proxy ¶
type Proxy struct { *metadata.Meta Input *ParameterMap `json:"input,omitempty"` Name string `json:"name,omitempty"` Nodes NodeList `json:"nodes,omitempty"` Forward *Call `json:"forward,omitempty"` Rewrite []Rewrite `json:"rewrite,omitempty"` OnError *OnError `json:"on_error,omitempty"` }
Proxy streams the incoming request to the given service. Proxies could define calls that are executed before the request body is forwarded. A proxy forward could ideally be used for file uploads or large messages which could not be stored in memory.
func (*Proxy) GetForward ¶
GetForward returns the proxy forward of the given flow
func (*Proxy) GetInput ¶
func (proxy *Proxy) GetInput() *ParameterMap
GetInput returns the input of the given flow
func (*Proxy) GetOnError ¶
GetOnError returns the error handling of the given flow
func (*Proxy) GetOutput ¶
func (proxy *Proxy) GetOutput() *ParameterMap
GetOutput returns the output of the given flow
func (*Proxy) GetRewrite ¶
GetRewrite returns the rewrite rules of the given flow
type ProxyList ¶
type ProxyList []*Proxy
ProxyList represents a collection of proxies
type Repeated ¶
type Repeated []Template
Repeated represents an array type of fixed size.
type Scalar ¶
type Scalar struct { Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` Type types.Type `json:"type,omitempty" yaml:"type,omitempty"` }
Scalar value.
func (*Scalar) Clean ¶
func (scalar *Scalar) Clean()
Clean fixes the type casting issue of unmarshal
func (*Scalar) Compare ¶
Compare the given scalar against the expected and return the first met difference as an error.
func (*Scalar) UnmarshalJSON ¶
UnmarshalJSON corrects the 64bit data types in accordance with golang
type Schemas ¶
Schemas represents a map string collection of properties
type Service ¶
type Service struct { *metadata.Meta Comment string `json:"comment,omitempty"` Package string `json:"package,omitempty"` FullyQualifiedName string `json:"fully_qualified_name,omitempty"` Name string `json:"name,omitempty"` Transport string `json:"transport,omitempty"` RequestCodec string `json:"request_codec,omitempty"` ResponseCodec string `json:"response_codec,omitempty"` Host string `json:"host,omitempty"` Methods []*Method `json:"methods,omitempty"` Options Options `json:"options,omitempty"` Resolver string `json:"resolver,omitempty"` }
Service represents a service which exposes a set of methods
type ServiceDiscoveryClient ¶
type ServiceDiscoveryClients ¶
type ServiceDiscoveryClients map[string]ServiceDiscoveryClient
type ServiceList ¶
type ServiceList []*Service
ServiceList represents a collection of services
func (*ServiceList) Append ¶
func (services *ServiceList) Append(list ServiceList)
Append appends the given services to the current services collection
func (ServiceList) Get ¶
func (services ServiceList) Get(name string) *Service
Get attempts to find and return a flow with the given name
type Template ¶
type Template struct { *metadata.Meta Reference *PropertyReference `json:"reference,omitempty"` // Reference represents a property reference made inside the given property // Only one of the following fields should be set Scalar *Scalar `json:"scalar,omitempty" yaml:"scalar,omitempty"` Enum *Enum `json:"enum,omitempty" yaml:"enum,omitempty"` Repeated Repeated `json:"repeated,omitempty" yaml:"repeated,omitempty"` Message Message `json:"message,omitempty" yaml:"message,omitempty"` OneOf OneOf `json:"oneOf,omitempty" yaml:"oneOf,omitempty"` }
Template contains property schema. This is a union type (Only one field must be set).
func ParseTemplate ¶
ParseTemplate parses the given value template, note that path is only used for debugging.
func ParseTemplateContent ¶
ParseTemplateContent parses the given template function.
func ParseTemplateReference ¶
ParseTemplateReference parses the given value as a template reference.
func (Template) Compare ¶
Compare given template against the provided one returning the first mismatch.
func (Template) DefaultValue ¶
func (template Template) DefaultValue() interface{}
Return the default value for the template (type), assuming the current type has a default.
func (Template) ShallowClone ¶
ShallowClone clones the given template but ignores any nested templates