Documentation ¶
Index ¶
- func DefaultOnError(err *specs.OnError)
- func DependenciesExcept(dependencies specs.Dependencies, resource string) specs.Dependencies
- func DependsOn(dependency *specs.Node, nodes ...*specs.Node)
- func DiscoveryClientsResolver(path string) providers.ServiceDiscoveryClientsResolver
- func EndpointsResolver(path string) providers.EndpointsResolver
- func FlowsResolver(path string) providers.FlowsResolver
- func JoinPath(values ...string) (result string)
- func MergeOnError(left *specs.OnError, right *specs.OnError)
- func ParseDiscoveryClients(ctx *broker.Context, manifest Manifest) (specs.ServiceDiscoveryClients, error)
- func ParseEndpoints(ctx *broker.Context, manifest Manifest) (specs.EndpointList, error)
- func ParseFlows(ctx *broker.Context, manifest Manifest) (errObject *specs.ParameterMap, _ specs.FlowListInterface, _ error)
- func ParseIntermediateBefore(ctx *broker.Context, before *Before) (dependencies specs.Dependencies, references []Resources, resources []Resource)
- func ParseIntermediateCall(ctx *broker.Context, call *Call) (*specs.Call, error)
- func ParseIntermediateCallParameterMap(ctx *broker.Context, params *Call) (*specs.ParameterMap, error)
- func ParseIntermediateCondition(ctx *broker.Context, dependencies specs.Dependencies, condition Condition) (specs.NodeList, error)
- func ParseIntermediateDefinitionOptions(options *BlockOptions) specs.Options
- func ParseIntermediateEndpoint(ctx *broker.Context, endpoint Endpoint) *specs.Endpoint
- func ParseIntermediateFlow(ctx *broker.Context, flow Flow) (*specs.Flow, error)
- func ParseIntermediateHeader(ctx *broker.Context, header *Header) (specs.Header, error)
- func ParseIntermediateInputParameterMap(ctx *broker.Context, params *InputParameterMap) (*specs.ParameterMap, error)
- func ParseIntermediateMethods(ctx *broker.Context, methods []Method) ([]*specs.Method, error)
- func ParseIntermediateNestedParameterMap(ctx *broker.Context, params NestedParameterMap, path string) (*specs.Property, error)
- func ParseIntermediateNode(ctx *broker.Context, dependencies specs.Dependencies, node Resource) (*specs.Node, error)
- func ParseIntermediateOnError(ctx *broker.Context, onError *OnError) (*specs.OnError, error)
- func ParseIntermediateParameterMap(ctx *broker.Context, params *ParameterMap) (*specs.ParameterMap, error)
- func ParseIntermediateParameters(ctx *broker.Context, options hcl.Body) (map[string]*specs.Property, error)
- func ParseIntermediateProperty(ctx *broker.Context, path string, property *hcl.Attribute, value cty.Value) (*specs.Property, error)
- func ParseIntermediateProxy(ctx *broker.Context, proxy Proxy) (*specs.Proxy, error)
- func ParseIntermediateProxyForward(ctx *broker.Context, proxy ProxyForward) (*specs.Call, error)
- func ParseIntermediateRepeatedParameterMap(ctx *broker.Context, params RepeatedParameterMap, path string) (*specs.Property, error)
- func ParseIntermediateResources(ctx *broker.Context, dependencies specs.Dependencies, resources Resources) (specs.NodeList, error)
- func ParseIntermediateRewriteRules(ctx *broker.Context, rewrite []ProxyRewrite) ([]specs.Rewrite, error)
- func ParseIntermediateService(parent *broker.Context, manifest Service) (*specs.Service, error)
- func ParseIntermediateSpecOptions(options hcl.Body) specs.Options
- func ParseServices(ctx *broker.Context, manifest Manifest) (specs.ServiceList, error)
- func ResolveErrors(flows specs.FlowListInterface, err *specs.ParameterMap)
- func ServicesResolver(path string) providers.ServicesResolver
- func SetScalar(ctx *broker.Context, tmpl *specs.Template, value cty.Value) error
- type BaseParameterMap
- type Before
- type BlockOptions
- type Call
- type Condition
- type Discovery
- type Endpoint
- type ErrPathNotFound
- type ErrUnkownPropertyType
- type Expression
- type Flow
- type GRPC
- type GraphQL
- type HTTP
- type Header
- type InputParameterMap
- type InputRepeatedParameterMap
- type Manifest
- type Method
- type NestedParameterMap
- type OnError
- type Options
- type ParameterMap
- type Prometheus
- type Proxy
- type ProxyForward
- type ProxyInput
- type ProxyRewrite
- type RepeatedParameterMap
- type Resource
- type ResourceBlock
- type Resources
- type Service
- type ServiceSelector
- type Services
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOnError ¶
DefaultOnError sets the default values for not defined properties
func DependenciesExcept ¶
func DependenciesExcept(dependencies specs.Dependencies, resource string) specs.Dependencies
DependenciesExcept copies the given dependencies except the given resource
func DiscoveryClientsResolver ¶
func DiscoveryClientsResolver(path string) providers.ServiceDiscoveryClientsResolver
DiscoveryClientsResolver parses configuration.
func EndpointsResolver ¶
func EndpointsResolver(path string) providers.EndpointsResolver
EndpointsResolver constructs a resource resolver for the given path
func FlowsResolver ¶
func FlowsResolver(path string) providers.FlowsResolver
FlowsResolver constructs a resource resolver for the given path
func MergeOnError ¶
MergeOnError merges the right on error specs into the left on error
func ParseDiscoveryClients ¶
func ParseEndpoints ¶
ParseEndpoints parses the given intermediate manifest to a endpoints manifest
func ParseFlows ¶
func ParseFlows(ctx *broker.Context, manifest Manifest) (errObject *specs.ParameterMap, _ specs.FlowListInterface, _ error)
ParseFlows parses the given intermediate manifest to a flows manifest
func ParseIntermediateBefore ¶
func ParseIntermediateBefore(ctx *broker.Context, before *Before) (dependencies specs.Dependencies, references []Resources, resources []Resource)
ParseIntermediateBefore parses the given before into a collection of dependencies
func ParseIntermediateCall ¶
ParseIntermediateCall parses the given intermediate call to a spec call
func ParseIntermediateCallParameterMap ¶
func ParseIntermediateCallParameterMap(ctx *broker.Context, params *Call) (*specs.ParameterMap, error)
ParseIntermediateCallParameterMap parses the given intermediate parameter map to a spec parameter map
func ParseIntermediateCondition ¶
func ParseIntermediateCondition(ctx *broker.Context, dependencies specs.Dependencies, condition Condition) (specs.NodeList, error)
ParseIntermediateCondition parses the given intermediate condition and returns the compiled nodes
func ParseIntermediateDefinitionOptions ¶
func ParseIntermediateDefinitionOptions(options *BlockOptions) specs.Options
ParseIntermediateDefinitionOptions parses the given intermediate options to a definitions options
func ParseIntermediateEndpoint ¶
ParseIntermediateEndpoint parses the given intermediate endpoint to a specs endpoint
func ParseIntermediateFlow ¶
ParseIntermediateFlow parses the given intermediate flow to a specs flow
func ParseIntermediateHeader ¶
ParseIntermediateHeader parses the given intermediate header to a spec header
func ParseIntermediateInputParameterMap ¶
func ParseIntermediateInputParameterMap(ctx *broker.Context, params *InputParameterMap) (*specs.ParameterMap, error)
ParseIntermediateInputParameterMap parses the given input parameter map
func ParseIntermediateMethods ¶
ParseIntermediateMethods parses the given methods for the given service
func ParseIntermediateNestedParameterMap ¶
func ParseIntermediateNestedParameterMap(ctx *broker.Context, params NestedParameterMap, path string) (*specs.Property, error)
ParseIntermediateNestedParameterMap parses the given intermediate parameter map to a spec parameter map
func ParseIntermediateNode ¶
func ParseIntermediateNode(ctx *broker.Context, dependencies specs.Dependencies, node Resource) (*specs.Node, error)
ParseIntermediateNode parses the given intermediate call to a spec call
func ParseIntermediateOnError ¶
ParseIntermediateOnError returns a specs on error
func ParseIntermediateParameterMap ¶
func ParseIntermediateParameterMap(ctx *broker.Context, params *ParameterMap) (*specs.ParameterMap, error)
ParseIntermediateParameterMap parses the given intermediate parameter map to a spec parameter map
func ParseIntermediateParameters ¶
func ParseIntermediateParameters(ctx *broker.Context, options hcl.Body) (map[string]*specs.Property, error)
ParseIntermediateParameters parses the given intermediate parameters
func ParseIntermediateProperty ¶
func ParseIntermediateProperty(ctx *broker.Context, path string, property *hcl.Attribute, value cty.Value) (*specs.Property, error)
ParseIntermediateProperty parses the given intermediate property to a spec property
func ParseIntermediateProxy ¶
ParseIntermediateProxy parses the given intermediate proxy to a specs proxy
func ParseIntermediateProxyForward ¶
ParseIntermediateProxyForward parses the given intermediate proxy forward to a specs proxy forward
func ParseIntermediateRepeatedParameterMap ¶
func ParseIntermediateRepeatedParameterMap(ctx *broker.Context, params RepeatedParameterMap, path string) (*specs.Property, error)
ParseIntermediateRepeatedParameterMap parses the given intermediate repeated parameter map to a spec repeated parameter map
func ParseIntermediateResources ¶
func ParseIntermediateResources(ctx *broker.Context, dependencies specs.Dependencies, resources Resources) (specs.NodeList, error)
ParseIntermediateResources parses the given resources to nodes
func ParseIntermediateService ¶
ParseIntermediateService parses the given intermediate service to a specs service
func ParseIntermediateSpecOptions ¶
ParseIntermediateSpecOptions parses the given intermediate options to a spec options
func ParseServices ¶
ParseServices parses the given intermediate manifest to a schema
func ResolveErrors ¶
func ResolveErrors(flows specs.FlowListInterface, err *specs.ParameterMap)
ResolveErrors clones any previously defined error objects or error handles
func ServicesResolver ¶
func ServicesResolver(path string) providers.ServicesResolver
ServicesResolver constructs a schema resolver for the given path. The HCL schema resolver relies on other schema registries. Those need to be resolved before the HCL schemas are resolved.
Types ¶
type BaseParameterMap ¶
type BaseParameterMap struct { Nested []NestedParameterMap `hcl:"message,block"` Repeated []RepeatedParameterMap `hcl:"repeated,block"` Properties hcl.Body `hcl:",remain"` }
BaseParameterMap contains a set of generic fields.
type BlockOptions ¶
type BlockOptions struct {
Body hcl.Body `hcl:",remain"`
}
BlockOptions holds the raw options.
type Call ¶
type Call struct { BaseParameterMap `hcl:",remain"` Service string `hcl:"service,label"` Method string `hcl:"method,label"` Parameters *BlockOptions `hcl:"params,block"` Options *BlockOptions `hcl:"options,block"` Header *Header `hcl:"header,block"` }
Call intermediate specification.
type Condition ¶
type Condition struct { ResourceBlock `hcl:",remain"` Expression string `hcl:"expression,label"` Conditions []Condition `hcl:"if,block"` }
Condition represents a condition on which the scoped resources should be executed if true.
type Discovery ¶
type Discovery struct { Name string `hcl:"name,label"` Provider string `hcl:"provider,optional"` Address string `hcl:"address"` }
Discovery describes a service discovery client configuration
Examples:
discovery "consul" { address = "http://localhost:8500" } discovery "foobar" { provider = "consul" address = "http://localhost:8500" }
type Endpoint ¶
type Endpoint struct { Flow string `hcl:"flow,label"` Listener string `hcl:"listener,label"` Options hcl.Body `hcl:",remain"` }
Endpoint intermediate specification.
type ErrPathNotFound ¶
type ErrPathNotFound struct { Path string // contains filtered or unexported fields }
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 ErrUnkownPropertyType ¶
type ErrUnkownPropertyType string
ErrUnkownPropertyType is thrown when the given property type is unkown
func (ErrUnkownPropertyType) Error ¶
func (e ErrUnkownPropertyType) Error() string
type Expression ¶
type Expression struct{ hcl.Expression }
Expression is a wrapper over hcl.Expression providing extra functionality.
func (Expression) Position ¶
func (expr Expression) Position() string
Position returns the position for tracer.
type Flow ¶
type Flow struct { Condition `hcl:",remain"` Name string `hcl:"name,label"` Error *ParameterMap `hcl:"error,block"` Input *InputParameterMap `hcl:"input,block"` OnError *OnError `hcl:"on_error,block"` Before *Before `hcl:"before,block"` Output *ParameterMap `hcl:"output,block"` }
Flow intermediate specification.
type GRPC ¶
type GRPC struct {
Address string `hcl:"address"`
}
GRPC represent the gRPC option definitions.
type GraphQL ¶
type GraphQL struct {
Address string `hcl:"address"`
}
GraphQL represents the GraphQL option definitions
type HTTP ¶
type HTTP struct { Address string `hcl:"address"` Origin []string `hcl:"origin,optional"` CertFile string `hcl:"cert_file,optional"` KeyFile string `hcl:"key_file,optional"` ReadTimeout string `hcl:"read_timeout,optional"` WriteTimeout string `hcl:"write_timeout,optional"` }
HTTP represent the HTTP option definitions.
type Header ¶
type Header struct {
Body hcl.Body `hcl:",remain"`
}
Header represents a collection of key values.
type InputParameterMap ¶
type InputParameterMap struct { Schema string `hcl:"schema,label"` Options *BlockOptions `hcl:"options,block"` Header []string `hcl:"header,optional"` }
InputParameterMap is the initial map of parameter names (keys) and their (templated) values (values).
type InputRepeatedParameterMap ¶
type InputRepeatedParameterMap struct { Name string `hcl:"name,label"` Nested []NestedParameterMap `hcl:"message,block"` Repeated []InputRepeatedParameterMap `hcl:"repeated,block"` Properties hcl.Body `hcl:",remain"` }
InputRepeatedParameterMap is a map of repeated message blocks/values.
type Manifest ¶
type Manifest struct { LogLevel string `hcl:"log_level,optional"` GraphQL *GraphQL `hcl:"graphql,block"` HTTP *HTTP `hcl:"http,block"` GRPC *GRPC `hcl:"grpc,block"` Prometheus *Prometheus `hcl:"prometheus,block"` Protobuffers []string `hcl:"protobuffers,optional"` Avro []string `hcl:"avro,optional"` Openapi3 []string `hcl:"openapi3,optional"` Include []string `hcl:"include,optional"` Error *ParameterMap `hcl:"error,block"` Flows []Flow `hcl:"flow,block"` Proxy []Proxy `hcl:"proxy,block"` Endpoints []Endpoint `hcl:"endpoint,block"` Services []Service `hcl:"service,block"` ServiceSelector []Services `hcl:"services,block"` DiscoveryServers []Discovery `hcl:"discovery,block"` }
Manifest intermediate specs
func ResolvePath ¶
ResolvePath resolves the given path and returns the available manifests. All defined includes are followed and their manifests are included
type Method ¶
type Method struct { Name string `hcl:"name,label"` Input string `hcl:"request,optional"` Output string `hcl:"response,optional"` Options *BlockOptions `hcl:"options,block"` }
Method represents a service method
type NestedParameterMap ¶
type NestedParameterMap struct { BaseParameterMap `hcl:",remain"` Name string `hcl:"name,label"` }
NestedParameterMap is a map of parameter names (keys) and their (templated) values (values).
type OnError ¶
type OnError struct { Schema string `hcl:"schema,optional"` Params *BlockOptions `hcl:"params,block"` Body hcl.Body `hcl:",remain"` }
OnError intermediate specification.
type Options ¶
type Options struct { LogLevel string Includes []string Protobuffers []string Avro []string Openapi3 []string GraphQL *GraphQL HTTP *HTTP GRPC *GRPC Prometheus *Prometheus Discovery *Discovery }
Options represents the available options that could be defined inside a HCL definition
type ParameterMap ¶
type ParameterMap struct { BaseParameterMap `hcl:",remain"` Schema string `hcl:"schema,label"` Options *BlockOptions `hcl:"options,block"` Header *Header `hcl:"header,block"` }
ParameterMap is the initial map of parameter names (keys) and their (templated) values (values).
type Prometheus ¶
type Prometheus struct {
Address string `hcl:"address"`
}
Prometheus represent the prometheus option definitions.
type Proxy ¶
type Proxy struct { Condition `hcl:",remain"` Name string `hcl:"name,label"` Error *ParameterMap `hcl:"error,block"` Input *ProxyInput `hcl:"input,block"` OnError *OnError `hcl:"on_error,block"` Before *Before `hcl:"before,block"` Forward ProxyForward `hcl:"forward,block"` Rewrite []ProxyRewrite `hcl:"rewrite,block"` }
Proxy specification.
type ProxyForward ¶
type ProxyForward struct { Service string `hcl:"service,label"` Header *Header `hcl:"header,block"` }
ProxyForward specification.
type ProxyInput ¶
type ProxyInput struct { Options *BlockOptions `hcl:"options,block"` Header []string `hcl:"header,optional"` Params string `hcl:"params,optional"` }
ProxyInput represents the proxy input block.
type ProxyRewrite ¶
type ProxyRewrite struct { Pattern string `hcl:"pattern,label"` Template string `hcl:"template,label"` Options hcl.Body `hcl:",remain"` }
ProxyRewrite describes rewrite rules. Allows rewriting/replacement URL segments
Example:
endpoint "test" "http" { method = "GET" endpoint = "/prefix/*tail" } proxy "test" { forward "com.semaphore.TestService" {} rewrite "/prefix/(?P<first>\w+)/(?P<second>\w+)" "/<second>/<first>" {} // swap URL segments rewrite "/prefix/(?P<tail>.*)" "/<tail>" {} // strip static `/prefix` }
NOTE: multiple rewrite rules can be specified but only one can be applied (the first one which matches the pattern) so put strict rules first (by priority) and keep wildcards in the bottom
type RepeatedParameterMap ¶
type RepeatedParameterMap struct { BaseParameterMap `hcl:",remain"` Name string `hcl:"name,label"` Template string `hcl:"template,label"` }
RepeatedParameterMap is a map of repeated message blocks/values.
type Resource ¶
type Resource struct { Name string `hcl:"name,label"` DependsOn []string `hcl:"depends_on,optional"` Request *Call `hcl:"request,block"` Rollback *Call `hcl:"rollback,block"` OnError *OnError `hcl:"on_error,block"` ExpectStatus []int `hcl:"expect_status,optional"` Error *ParameterMap `hcl:"error,block"` }
Resource intermediate specification.
type ResourceBlock ¶
type ResourceBlock struct { References []Resources `hcl:"resources,block"` Resources []Resource `hcl:"resource,block"` }
ResourceBlock contains resources and references.
type Resources ¶
type Resources struct {
Properties hcl.Body `hcl:",remain"`
}
Resources represent a collection of resources which are references or custom defined functions.
type Service ¶
type Service struct { Package string `hcl:"package,label"` Name string `hcl:"name,label"` Transport string `hcl:"transport,optional"` Codec string `hcl:"codec,optional"` Host string `hcl:"host,optional"` Methods []Method `hcl:"method,block"` Options *BlockOptions `hcl:"options,block"` Resolver string `hcl:"resolver,optional"` }
Service specification.
type ServiceSelector ¶
type ServiceSelector struct { Pattern string `hcl:"pattern,label"` Host string `hcl:"host,optional"` Transport string `hcl:"transport,optional"` Codec string `hcl:"codec,optional"` RequestCodec string `hcl:"request_codec,optional"` ResponseCodec string `hcl:"response_codec,optional"` Resolver string `hcl:"resolver,optional"` Options hcl.Body `hcl:",remain"` }
ServiceSelector targets any service match in the given service selector.
type Services ¶
type Services struct {
Selectors []ServiceSelector `hcl:"select,block"`
}
Services specification.