tree

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTreeMemory

func GetTreeMemory() memory.Manager

GetTreeMemory returns a memory manager interface

func SelectBrokerFromPriorityList

func SelectBrokerFromPriorityList(brokerList []string) (string, error)

SelectBrokerFromPriorityList takes a broker priority list and returns the first broker that is available

func SetMockedTree

func SetMockedTree(root *meta.App, appErr error, mockC, mockA, mockT bool)

SetMockedTree receives a mock manager that has the configs of the tree structure to be mocked and used in tests where tree access is needed

Types

type AliasMemoryManager

type AliasMemoryManager struct {
	*MemoryManager
}

AliasMemoryManager implements the Alias interface and provides methos for operating on Aliass

func (*AliasMemoryManager) Create

func (amm *AliasMemoryManager) Create(scope, targetBoundary string, alias *meta.Alias) error

Create receives a scope that defines a path to the dApp. The new alias will be created inside this dApp's parent.

func (*AliasMemoryManager) Delete

func (amm *AliasMemoryManager) Delete(scope, aliasKey string) error

Delete receives a scope and a alias key. The scope defines the path to the dApp that cointains the Alias to be deleted. If the dApp has an alias that has the same key as the key passed as an argument, that alias is removed from the dApp Aliases only if it's not being used

func (*AliasMemoryManager) Get

func (amm *AliasMemoryManager) Get(scope, aliasKey string) (*meta.Alias, error)

Get receives a scope and an alias key. The scope defines the path to a dApp. If this dApp has a pointer to a alias that has the same key as the key passed as an argument, the pointer to that alias is returned

func (*AliasMemoryManager) Update

func (amm *AliasMemoryManager) Update(scope, aliasKey string, alias *meta.Alias) error

Update receives a scope a alias key and a alias. The scope defines the path to the dApp that contains the Alias. If the dApp has a alias that has the given alias key passed as an argument, that alias will be replaced by the new alias

type AliasRootGetter

type AliasRootGetter struct {
}

AliasRootGetter returns a getter that gets alias from the root structure of the app, without the current changes. The getter does not allow changes in the structure, just visualization.

func (*AliasRootGetter) Get

func (amm *AliasRootGetter) Get(scope, aliasKey string) (*meta.Alias, error)

Get receives a scope and a alias key. The scope defines the path to an App. If this App has a pointer to a alias that has the same key as the key passed as an argument, the pointer to that alias is returned This method is used to get the structure as it is in the cluster, before any modifications.

type AppMemoryManager

type AppMemoryManager struct {
	*MemoryManager
}

AppMemoryManager implements the App interface and provides methos for operating on dApps

func (*AppMemoryManager) Create

func (amm *AppMemoryManager) Create(scope string, app *meta.App) error

Create instantiates a new dApp in the given scope. If the dApp's information is invalid, returns an error. The same goes for an invalid scope. In case of scope being an empty string, the dApp is created inside the root dApp.

func (*AppMemoryManager) Delete

func (amm *AppMemoryManager) Delete(query string) error

Delete receives a query and searches for the specified dApp through the tree. If the dApp is found and it doesn't have any dApps insite of it, it's deleted. If it has other dApps inside of itself, those dApps are deleted recursively. Channels and Types inside the dApps to be deleted are also deleted dApp's reference inside of it's parent is also deleted. In case of dApp not found an error is returned.

func (*AppMemoryManager) Get

func (amm *AppMemoryManager) Get(query string) (*meta.App, error)

Get receives a query string (format = 'x.y.z') and iterates through the memory tree until it finds the dApp which name is equal to the last query element. The root dApp is returned if the query string is an empty string. If the specified dApp is found, it is returned. Otherwise, returns an error.

func (*AppMemoryManager) ResolveBoundary

func (amm *AppMemoryManager) ResolveBoundary(app *meta.App) (map[string]string, error)

ResolveBoundary is the recursive method that resolves connections for dApp boundaries returns a map of boundary to their respective resolved channel query

func (*AppMemoryManager) Update

func (amm *AppMemoryManager) Update(query string, app *meta.App) error

Update receives a pointer to a dApp and the path to where this dApp is inside the memory tree. If the current dApp is found and the new structure is valid, it's updated. Otherwise, returns an error.

type AppRootGetter

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

AppRootGetter returns a getter that gets apps from the root structure of the app, without the current changes. The getter does not allow changes in the structure, just visualization.

func (*AppRootGetter) Get

func (amm *AppRootGetter) Get(query string) (*meta.App, error)

Get receives a query string (format = 'x.y.z') and iterates through the memory tree until it finds the dApp which name is equal to the last query element. The tree root dApp is returned if the query string is an empty string. If the specified dApp is found, it is returned. Otherwise, returns an error. This method is used to get the structure as it is in the cluster, before any modifications.

type ChannelMemoryManager

type ChannelMemoryManager struct {
	*MemoryManager
}

ChannelMemoryManager implements the channel interface and provides methods for operating on Channels

func (*ChannelMemoryManager) Create

func (chh *ChannelMemoryManager) Create(scope string, ch *meta.Channel) error

Create receives a scope that defines a path to the App in which to add a pointer to the channel passed as an argument

func (*ChannelMemoryManager) Delete

func (chh *ChannelMemoryManager) Delete(scope, name string) error

Delete receives a scope and a channel name. The scope defines the path to the App that will have the Delete. If the App has a pointer to a channel that has the same name as the name passed as an argument, that pointer is removed from the list of App channels

func (*ChannelMemoryManager) Get

func (chh *ChannelMemoryManager) Get(scope, name string) (*meta.Channel, error)

Get receives a scope and a channel name. The scope defines the path to an App. If this App has a pointer to a channel that has the same name as the name passed as an argument, the pointer to that channel is returned

func (*ChannelMemoryManager) Update

func (chh *ChannelMemoryManager) Update(scope string, ch *meta.Channel) error

Update receives a scope and a channel pointer. The scope defines the path to the App that will have the Update. If the App has a channel pointer that has the same name as that passed as an argument, this pointer will be replaced by the new one

type ChannelMockManager

type ChannelMockManager struct {
	*MockManager
}

ChannelMockManager mocks a channel interface for testing

func (*ChannelMockManager) Create

func (cmm *ChannelMockManager) Create(scope string, ch *meta.Channel) error

Create mocks a channel method for testing

func (*ChannelMockManager) Delete

func (cmm *ChannelMockManager) Delete(scope, name string) error

Delete mocks a channel method for testing

func (*ChannelMockManager) Get

func (cmm *ChannelMockManager) Get(scope, name string) (*meta.Channel, error)

Get mocks a channel method for testing

func (*ChannelMockManager) Update

func (cmm *ChannelMockManager) Update(query string, ch *meta.Channel) error

Update mocks a channel method for testing

type ChannelRootGetter

type ChannelRootGetter struct {
}

ChannelRootGetter returns a getter that gets channels from the root structure of the app, without the current changes. The getter does not allow changes in the structure, just visualization.

func (*ChannelRootGetter) Get

func (amm *ChannelRootGetter) Get(scope, name string) (*meta.Channel, error)

Get receives a query string (format = 'x.y.z') and iterates through the memory tree until it finds the Channel which name is equal to the last query element. If the specified Channel is found, it is returned. Otherwise, returns an error. This method is used to get the structure as it is in the cluster, before any modifications.

type MemoryManager

type MemoryManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MemoryManager defines a memory manager interface

func (*MemoryManager) Alias

func (tmm *MemoryManager) Alias() memory.AliasMemory

Alias is a MemoryManager method that provides an access point for Alias

func (*MemoryManager) Apps

func (tmm *MemoryManager) Apps() memory.AppMemory

Apps is a MemoryManager method that provides an access point for Apps

func (*MemoryManager) Cancel

func (mm *MemoryManager) Cancel()

Cancel discarts changes made in the last transaction

func (*MemoryManager) Channels

func (tmm *MemoryManager) Channels() memory.ChannelMemory

Channels return a pointer to ChannelMemoryManager

func (*MemoryManager) Commit

func (mm *MemoryManager) Commit()

Commit applies changes from a transaction in to the tree structure

func (*MemoryManager) GetTransactionChanges

func (mm *MemoryManager) GetTransactionChanges() (diff.Changelog, error)

GetTransactionChanges returns the changelog resulting from the current transaction.

func (*MemoryManager) InitTransaction

func (mm *MemoryManager) InitTransaction()

InitTransaction copies and reserves the current tree structure so that changes can be reversed

func (*MemoryManager) Root

func (mm *MemoryManager) Root() memory.GetInterface

Root returns a getter for objects on the root of the tree, without the current changes.

func (*MemoryManager) Types

func (mm *MemoryManager) Types() memory.TypeMemory

Types is a MemoryManager method that provides an access point for Types

type MockAppManager

type MockAppManager struct {
	*MockManager
	// contains filtered or unexported fields
}

MockAppManager to Mock App Manager

func (*MockAppManager) Create

func (mock *MockAppManager) Create(scope string, app *meta.App) error

Create Mock

func (*MockAppManager) Delete

func (mock *MockAppManager) Delete(scope string) error

Delete Mock

func (*MockAppManager) Get

func (mock *MockAppManager) Get(scope string) (*meta.App, error)

Get Mock

func (*MockAppManager) ResolveBoundary

func (mock *MockAppManager) ResolveBoundary(app *meta.App) (map[string]string, error)

ResolveBoundary Mock

func (*MockAppManager) Update

func (mock *MockAppManager) Update(scope string, app *meta.App) error

Update Mock

type MockManager

type MockManager struct {
	*MemoryManager
	// contains filtered or unexported fields
}

MockManager mocks a tree structure for testing

func (*MockManager) Apps

func (tmm *MockManager) Apps() memory.AppMemory

Apps mocks an app interface for testing

func (*MockManager) Cancel

func (tmm *MockManager) Cancel()

Cancel mock interface structure

func (*MockManager) Channels

func (tmm *MockManager) Channels() memory.ChannelMemory

Channels mocks a channel interface for testing

func (*MockManager) Commit

func (tmm *MockManager) Commit()

Commit mock interface structure

func (*MockManager) GetTransactionChanges

func (tmm *MockManager) GetTransactionChanges() (diff.Changelog, error)

GetTransactionChanges mock structure

func (*MockManager) InitTransaction

func (tmm *MockManager) InitTransaction()

InitTransaction mock interface structure

func (*MockManager) Root

func (tmm *MockManager) Root() memory.GetInterface

Root mock interface structure

func (*MockManager) Types

func (tmm *MockManager) Types() memory.TypeMemory

Types mocks a Type interface for testing

type RootGetter

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

RootGetter is a structure that gets components from the root, without the current changes.

func (*RootGetter) Alias

func (t *RootGetter) Alias() memory.AliasGetInterface

Alias returns a getter for alias on the root

func (*RootGetter) Apps

func (t *RootGetter) Apps() memory.AppGetInterface

Apps returns a getter for apps on the root.

func (*RootGetter) Channels

func (t *RootGetter) Channels() memory.ChannelGetInterface

Channels returns a getter for channels on the root.

func (*RootGetter) Types

func (t *RootGetter) Types() memory.TypeGetInterface

Types returns a getter for Types on the root

type TypeMemoryManager

type TypeMemoryManager struct {
	*MemoryManager
}

TypeMemoryManager implements the Type interface and provides methos for operating on Types

func (*TypeMemoryManager) Create

func (tmm *TypeMemoryManager) Create(scope string, insprType *meta.Type) error

Create creates, if it doesn't already exist, a new Type for a given app. insprType: Type to be created. scope: Path to reference app (x.y.z...)

func (*TypeMemoryManager) Delete

func (tmm *TypeMemoryManager) Delete(scope, name string) error

Delete deletes, if it exists, a Type from a given app. name: Name of desired Type. scope: Path to reference app (x.y.z...)

func (*TypeMemoryManager) Get

func (tmm *TypeMemoryManager) Get(scope, name string) (*meta.Type, error)

Get returns, if it exists, a specific Type from a given app. name: Name of desired Type. scope: Path to reference app (x.y.z...)

func (*TypeMemoryManager) Update

func (tmm *TypeMemoryManager) Update(scope string, insprType *meta.Type) error

Update updates, if it exists, a Type of a given app. insprType: Updated ChannetType to be updated on app scope: Path to reference app (x.y.z...)

type TypeMockManager

type TypeMockManager struct {
	*MockManager
}

TypeMockManager mocks a Type interface for testing

func (*TypeMockManager) Create

func (ctm *TypeMockManager) Create(scope string, ct *meta.Type) error

Create mocks a Type method for testing

func (*TypeMockManager) Delete

func (ctm *TypeMockManager) Delete(scope, name string) error

Delete mocks a Type method for testing

func (*TypeMockManager) Get

func (ctm *TypeMockManager) Get(scope, name string) (*meta.Type, error)

Get mocks a Type method for testing

func (*TypeMockManager) Update

func (ctm *TypeMockManager) Update(query string, ct *meta.Type) error

Update mocks a Type method for testing

type TypeRootGetter

type TypeRootGetter struct{}

TypeRootGetter returns a getter that gets Types from the root structure of the app, without the current changes. The getter does not allow changes in the structure, just visualization.

func (*TypeRootGetter) Get

func (trg *TypeRootGetter) Get(scope, name string) (*meta.Type, error)

Get receives a query string (format = 'x.y.z') and iterates through the memory tree until it finds the Type which name is equal to the last query element. If the specified Type is found, it is returned. Otherwise, returns an error. This method is used to get the structure as it is in the cluster, before any modifications.

Jump to

Keyboard shortcuts

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