references

package
v0.0.0-...-3cc3ff2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMethod

func GetMethod(path string) string

GetMethod returns the method from the given endpoint

func GetService

func GetService(path string) string

GetService returns the service from the given endpoint

func Index

func Index(path string, index int) string

Index returns the path and the provided index as a path

func InsideProperty

func InsideProperty(source *specs.Property, target *specs.Property) bool

InsideProperty checks whether the given property is insde the source property

func LookupReference

func LookupReference(ctx *broker.Context, breakpoint string, reference *specs.PropertyReference, flow specs.FlowInterface) (*specs.Property, error)

LookupReference looks up the given reference

func NewRepeating

func NewRepeating(store Store, tracker Tracker, path string, values []interface{})

NewRepeating appends the given repeating values to the given reference

func NewRepeatingMessages

func NewRepeatingMessages(store Store, tracker Tracker, path string, values []map[string]interface{})

NewRepeatingMessages appends the given repeating messages to the given reference

func ReferencedParameterMapPaths

func ReferencedParameterMapPaths(referenced ReferencedCollection, property *specs.ParameterMap) *specs.ParameterMap

ReferencedParameterMapPaths constructs a new parameter map containing only the paths provided inisde the references collection. All properties not found iniside the collection will be ignored.

func ReferencedPathsProperty

func ReferencedPathsProperty(referenced ReferencedCollection, property *specs.Property) *specs.Property

ReferencedPathsProperty constructs a new property containing only the paths provided inisde the references collection. All properties not found iniside the collection will be ignored.

func Resolve

func Resolve(ctx *broker.Context, flows specs.FlowListInterface) (err error)

Resolve all references inside the given flow list

func ResolveCall

func ResolveCall(ctx *broker.Context, node *specs.Node, call *specs.Call, flow specs.FlowInterface) (err error)

ResolveCall resolves all references made within the given call

func ResolveFlow

func ResolveFlow(ctx *broker.Context, flow specs.FlowInterface) (err error)

ResolveFlow all references made within the given flow

func ResolveNode

func ResolveNode(ctx *broker.Context, node *specs.Node, flow specs.FlowInterface) (err error)

ResolveNode resolves all references made within the given node

func ResolveOnError

func ResolveOnError(ctx *broker.Context, node *specs.Node, params *specs.OnError, flow specs.FlowInterface) (err error)

ResolveOnError resolves references made inside the given on error specs

func ResolveParameterMap

func ResolveParameterMap(ctx *broker.Context, node *specs.Node, params *specs.ParameterMap, flow specs.FlowInterface) (err error)

ResolveParameterMap resolves all references made within the given parameter map

func ResolveParams

func ResolveParams(ctx *broker.Context, node *specs.Node, params map[string]*specs.Property, flow specs.FlowInterface) error

ResolveParams resolves all references made within the given parameters

func ResolveProperty

func ResolveProperty(ctx *broker.Context, node *specs.Node, property *specs.Property, flow specs.FlowInterface) error

ResolveProperty resolves all references made within the given property

func ScopeNestedReferences

func ScopeNestedReferences(resource, path string, source, target *specs.Template)

ScopeNestedReferences clones all properties on the left side to the target on the right side.

func StoreValues

func StoreValues(store Store, tracker Tracker, path string, values map[string]interface{})

StoreValues stores the given values to the reference store

Types

type Collection

type Collection map[string]*specs.PropertyReference

Collection represents a map of property references

func ParameterReferences

func ParameterReferences(params *specs.ParameterMap) Collection

ParameterReferences returns all the available references inside the given parameter map

func PropertyReferences

func PropertyReferences(property *specs.Property) Collection

PropertyReferences returns the available references within the given property

func (Collection) MergeLeft

func (references Collection) MergeLeft(incoming ...Collection)

MergeLeft merges the references into the given reference

type EnumVal

type EnumVal struct {
	// contains filtered or unexported fields
}

EnumVal represents a enum value

func Enum

func Enum(key string, pos int32) *EnumVal

Enum value type

func (*EnumVal) Key

func (val *EnumVal) Key() string

Key returns the key of the given enum value

func (*EnumVal) MarshalJSON

func (val *EnumVal) MarshalJSON() ([]byte, error)

MarshalJSON custom marshal implementation mainly used for testing purposes

func (*EnumVal) Pos

func (val *EnumVal) Pos() int32

Pos returns the enum position of the given enum value

func (*EnumVal) UnmarshalJSON

func (val *EnumVal) UnmarshalJSON([]byte) error

UnmarshalJSON custom unmarshal implementation mainly used for testing purposes

type ErrUndefinedReference

type ErrUndefinedReference struct {
	Property   *specs.Property
	Breakpoint string
	// contains filtered or unexported fields
}

ErrUndefinedReference occurs when resolving meets unknown reference.

func NewErrUndefinedReference

func NewErrUndefinedReference(inner error, property *specs.Property, breakpoint string) ErrUndefinedReference

NewErrUndefinedReference constructs a new error thrown when a undefined reference is given.

func (ErrUndefinedReference) Error

func (e ErrUndefinedReference) Error() string

Error returns a description of the given error as a string

func (ErrUndefinedReference) Prettify

func (e ErrUndefinedReference) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUndefinedReference) Unwrap

func (i ErrUndefinedReference) Unwrap() error

type ErrUndefinedResource

type ErrUndefinedResource struct {

	// Reference points to the reference which caused the error
	Reference  *specs.PropertyReference
	Breakpoint string
	// AvailableReferences contains the whole list of known references
	AvailableReferences map[string]lookup.ReferenceMap
	// contains filtered or unexported fields
}

ErrUndefinedResource occurs when resolving meets unknown resource

func (ErrUndefinedResource) Error

func (e ErrUndefinedResource) Error() string

Error returns a description of the given error as a string

func (ErrUndefinedResource) Prettify

func (e ErrUndefinedResource) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUndefinedResource) Unwrap

func (i ErrUndefinedResource) Unwrap() error

type ErrUnresolvedCall

type ErrUnresolvedCall struct {
	Call *specs.Call
	// contains filtered or unexported fields
}

ErrUnresolvedCall is thrown when Semaphore is unable to resolve a reference inside the given call.

func (ErrUnresolvedCall) Error

func (e ErrUnresolvedCall) Error() string

func (ErrUnresolvedCall) Prettify

func (e ErrUnresolvedCall) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUnresolvedCall) Unwrap

func (i ErrUnresolvedCall) Unwrap() error

type ErrUnresolvedFlow

type ErrUnresolvedFlow struct {
	Name string
	// contains filtered or unexported fields
}

ErrUnresolvedFlow occurs when the whole flow cannot be resolved. It's the root error in this package.

func (ErrUnresolvedFlow) Error

func (e ErrUnresolvedFlow) Error() string

Error returns a description of the given error as a string

func (ErrUnresolvedFlow) Prettify

func (e ErrUnresolvedFlow) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUnresolvedFlow) Unwrap

func (i ErrUnresolvedFlow) Unwrap() error

type ErrUnresolvedNode

type ErrUnresolvedNode struct {
	Node *specs.Node
	// contains filtered or unexported fields
}

ErrUnresolvedNode is thrown when Semaphore is unable to resolve a reference inside the given node.

func (ErrUnresolvedNode) Error

func (e ErrUnresolvedNode) Error() string

Error returns a description of the given error as a string

func (ErrUnresolvedNode) Prettify

func (e ErrUnresolvedNode) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUnresolvedNode) Unwrap

func (i ErrUnresolvedNode) Unwrap() error

type ErrUnresolvedOnError

type ErrUnresolvedOnError struct {
	OnError *specs.OnError
	// contains filtered or unexported fields
}

ErrUnresolvedOnError is thrown when Semaphore is unable to resolve a reference inside the given on error.

func (ErrUnresolvedOnError) Error

func (e ErrUnresolvedOnError) Error() string

Error returns a description of the given error as a string

func (ErrUnresolvedOnError) Prettify

func (e ErrUnresolvedOnError) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUnresolvedOnError) Unwrap

func (i ErrUnresolvedOnError) Unwrap() error

type ErrUnresolvedParameterMap

type ErrUnresolvedParameterMap struct {
	Parameter *specs.ParameterMap
	// contains filtered or unexported fields
}

ErrUnresolvedParameterMap is thrown when Semaphore is unable to resolve a reference in the given parameter map.

func (ErrUnresolvedParameterMap) Error

Error returns a description of the given error as a string

func (ErrUnresolvedParameterMap) Prettify

Prettify returns the prettified version of the given error

func (ErrUnresolvedParameterMap) Unwrap

func (i ErrUnresolvedParameterMap) Unwrap() error

type ErrUnresolvedParams

type ErrUnresolvedParams struct {
	Params map[string]*specs.Property
	// contains filtered or unexported fields
}

ErrUnresolvedParams is thrown when Semaphore is unable to resolve a reference inside the given parameters.

func (ErrUnresolvedParams) Error

func (e ErrUnresolvedParams) Error() string

func (ErrUnresolvedParams) Prettify

func (e ErrUnresolvedParams) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUnresolvedParams) Unwrap

func (i ErrUnresolvedParams) Unwrap() error

type ErrUnresolvedProperty

type ErrUnresolvedProperty struct {
	Property *specs.Property
	// contains filtered or unexported fields
}

ErrUnresolvedProperty is thrown when Semaphore is unable to resolve a reference inside the given property.

func NewErrUnresolvedProperty

func NewErrUnresolvedProperty(inner error, property *specs.Property) ErrUnresolvedProperty

NewErrUnresolvedProperty is thrown when the given property has not been resolved

func (ErrUnresolvedProperty) Error

func (e ErrUnresolvedProperty) Error() string

func (ErrUnresolvedProperty) Prettify

func (e ErrUnresolvedProperty) Prettify() prettyerr.Error

Prettify returns the prettified version of the given error

func (ErrUnresolvedProperty) Unwrap

func (i ErrUnresolvedProperty) Unwrap() error

type Reference

type Reference struct {
	Value interface{}
	Enum  *int32
}

Reference represents a value reference

type ReferencedCollection

type ReferencedCollection map[string]struct{}

ReferencedCollection contains a collection of paths

func ReferencedResourcePaths

func ReferencedResourcePaths(flow specs.FlowInterface, resource string) ReferencedCollection

ReferencedResourcePaths defines all paths references to the given resource inside the given flow. These references could be used to only include the properties used and referenced inside a given flow.

func (ReferencedCollection) Has

func (collection ReferencedCollection) Has(path string) bool

Has verifies whether the given path is available inside the given collection.

func (ReferencedCollection) Set

func (collection ReferencedCollection) Set(path string)

Set deconstructs the given paths to ensure that all parts to the given paths are available. This is used to allow for easy comparisons against property paths.

ex: "meta.info.name" results in: "meta", "meta.info", "meta.info.name"

type Store

type Store interface {
	// Store stores the reference using the given path as key
	Store(path string, reference *Reference)
	// Load attempts to load the reference for the given path.
	// If no reference has been found is a nil value returned.
	Load(path string) *Reference
	// Define defines the length of a array or object at the given path.
	// Any previously defined lengths for the given path will be overridden.
	Define(path string, length int)
	// Length returns the length of the given object or array at the given path
	Length(path string) int
}

Store is a key/value store capable of holding reference values. Reference values could be fetched by providing the absolute path of a property. The reference store is used inside flows and codecs to track properties and their values. Property keys are delimited with a simple dot-notation (ex: meta.key).

Arrays are stored by defining the index and property path (ex: items[0].key). When defining an array or object make sure to define the length. The length of objects and properties are used inside implementations as a reference.

func NewPrefixStore

func NewPrefixStore(store Store, prefix string) Store

NewPrefixStore fixes all writes and reads from the given store on the set resource and prefix path

func NewStore

func NewStore(size int) Store

NewStore constructs a new store and allocates the references for the given length

type Tracker

type Tracker interface {
	// Track includes the given path and index to be tracked.
	// Trackers could be nested to track multiple or nested arrays on different indexes.
	Track(path string, index int)
	// Resolve resolves the given path to include all tracked array indexes found inside the given path.
	// ex: "items.key" - "items[0].key"
	Resolve(path string) string
	// Next increases the index of the counter at the given path
	Next(path string) int
}

Tracker tracks the index positions of arrays. Paths represent arrays or objects stored inside a reference store. Paths defined inside references could be resolved to include the current items index. These indexes are required since paths inside the reference store are absolute. Trackers could be nested to track multiple arrays on different or nested paths.

The tracker does not perform any mutex locking. Most usecases/implementations are not concurrent.

example: track := tracker.Track("items", 0) // sets the current index of "items" at 0 path := track.Resolve("items.key") // returns: "items[0].key" track.Next("items") // increases the index of "items" by one

func NewTracker

func NewTracker() Tracker

NewTracker constructs a new position tracker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL