storage

package
v0.0.0-...-9d1ce3d Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFlowCannotBeRetrieved error = fmt.Errorf("Could not retrieve Flow from storage")
	ErrPathCannotBeRetrieved error = fmt.Errorf("Could not retrieve Path from storage")
	ErrResolvingKey          error = fmt.Errorf("Error resolving key in database")
)
View Source
var Logger = logrus.New()

Logger logs but can be replaced

Functions

func NewFlowDTO

func NewFlowDTO(id quad.IRI, name string, description string, path quad.IRI) flowDTO

NewFlowDTO returns a new flowDTO

func NewPathDTO

func NewPathDTO(id quad.IRI, route string, pathType string, flows []quad.IRI) pathDTO

Types

type Flow

type Flow struct {
	UUID        uuid.UUID       `json:"uuid,omitempty"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Path        *messenger.Path `json:"path"`
}

type Flows

type Flows struct {
	Flows []Flow `json:"flows"`
}

func AddKeyToFlows

func AddKeyToFlows(flows []Flow, keys []Key) Flows

AddKeyToFlows adds/replace keys in the optional UUID field

type GraphStorage

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

func NewGraphStorage

func NewGraphStorage(config GraphStorageConfig) (*GraphStorage, error)

NewGraphStorage returns a new Storage that uses Cayley and CockroachDB

func NewGraphStorageBolt

func NewGraphStorageBolt(filepath string) (*GraphStorage, error)

NewGraphStorageBolt allows graph to be stored in a file instead sql above. This is to dodge the issue with inserting a struct of optional or empty array in to the graph (postgres issue: https://github.com/cayleygraph/cayley/issues/563)

func (*GraphStorage) ChainNextFlowToPath

func (gs *GraphStorage) ChainNextFlowToPath(flowKey Key, pathKey Key) error

ChainNextFlowToPath connects Flows to be triggered by a Path

func (*GraphStorage) Close

func (gs *GraphStorage) Close()

Close ends graph database session. Currently, it will delete temporary database file if used

func (*GraphStorage) GetFlowByKey

func (gs *GraphStorage) GetFlowByKey(key Key) (Flow, error)

GetFlowByKey returns a Flow of the sepcified uuid from the graph

func (*GraphStorage) GetKeyOfPath

func (gs *GraphStorage) GetKeyOfPath(path messenger.Path) (Key, error)

GetKeyOfPath returns the Key of a given Path if it exists

func (*GraphStorage) GetNextFlows

func (gs *GraphStorage) GetNextFlows(key Key) ([]Flow, []Key, error)

GetNextFlows returns a list of Flows that are triggers by the Flow

func (*GraphStorage) GetPathByKey

func (gs *GraphStorage) GetPathByKey(key Key) (messenger.Path, error)

GetPathByKey returns Path based on uuid.

func (*GraphStorage) SaveFlow

func (gs *GraphStorage) SaveFlow(flow Flow) (Key, error)

SaveFlow adds a new Flow to the graph. If the Path does not exist, it will be added, else it will be made

func (*GraphStorage) SavePath

func (gs *GraphStorage) SavePath(path messenger.Path) (Key, error)

SavePath adds path to graph if new, else it will return the id of the existing path. Path are unique based on route and type combined

type GraphStorageConfig

type GraphStorageConfig struct {
	Host         string
	Port         int
	User         string
	DatabaseName string
	DatabaseType string
}

func (GraphStorageConfig) GetDatabaseConnectionPath

func (gsc GraphStorageConfig) GetDatabaseConnectionPath() string

GetDatabaseConnectionPath returns a constructed URL from the database details in config

type Key

type Key struct {
	UUID uuid.UUID `json:"uuid"`
}

Key is the type to identify elements in the graph

func NewKeyFromQuadIRI

func NewKeyFromQuadIRI(v quad.IRI) (Key, error)

NewKeyFromQuadIRI returns a Key from a Quad Value

func NewKeyFromQuadValue

func NewKeyFromQuadValue(v quad.Value) (Key, error)

NewKeyFromQuadValue returns a Key from a Quad Value

func NewKeyFromString

func NewKeyFromString(v string) (Key, error)

NewKeyFromString returns a Key from a Quad Value

func NewRandomKey

func NewRandomKey() Key

NewRandomKey returns a random Key based on random numbers (RFC 4122)

func (Key) Equals

func (k Key) Equals(k2 Key) bool

Equals returns whether or not the Keys are equal

func (Key) QuadIRI

func (k Key) QuadIRI() quad.IRI

QuadIRI returns key in Quad IRI format

func (Key) QuadValue

func (k Key) QuadValue() quad.Value

QuadValue return key in Quad Value format. The <, > makes the type quad.IRI instead of quad.String

func (Key) String

func (k Key) String() string

String returns key in string format

type Storage

type Storage interface {
	SaveFlow(flow Flow) (Key, error)
	GetFlowByKey(key Key) (Flow, error)

	SavePath(path messenger.Path) (Key, error)
	GetPathByKey(key Key) (messenger.Path, error)
	GetKeyOfPath(path messenger.Path) (Key, error)

	ChainNextFlowToPath(flowKey Key, pathKey Key) error
	GetNextFlows(key Key) ([]Flow, []Key, error)
}

Jump to

Keyboard shortcuts

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