tree

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectBrokerFromPriorityList

func SelectBrokerFromPriorityList(brokerList []string, brokers *apimodels.BrokersDI) (string, error)

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

Types

type AliasGetInterface added in v0.1.1

type AliasGetInterface interface {
	Get(scope, aliasKey string) (*meta.Alias, error)
}

AliasGetInterface is an interface to get alias types from memory

type AliasMemory added in v0.1.1

type AliasMemory interface {
	TransactionInterface
	AliasGetInterface
	Create(scope, targetBoundary string, alias *meta.Alias) error
	Update(scope, aliasKey string, alias *meta.Alias) error
	Delete(scope, aliasKey string) error
}

AliasMemory is an interface to get alias types from memory

type AliasMemoryManager

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

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

func (AliasMemoryManager) Alias added in v0.1.1

func (tmm AliasMemoryManager) Alias() AliasMemory

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

func (AliasMemoryManager) Apps added in v0.1.1

func (tmm AliasMemoryManager) Apps() AppMemory

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

func (AliasMemoryManager) Cancel added in v0.1.1

func (tmm AliasMemoryManager) Cancel()

Cancel discarts changes made in the last transaction

func (AliasMemoryManager) Channels added in v0.1.1

func (tmm AliasMemoryManager) Channels() ChannelMemory

Channels return a pointer to ChannelMemoryManager

func (AliasMemoryManager) Commit added in v0.1.1

func (tmm AliasMemoryManager) Commit()

Commit applies changes from a transaction in to the tree structure

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) GetTransactionChanges added in v0.1.1

func (tmm AliasMemoryManager) GetTransactionChanges() (diff.Changelog, error)

GetTransactionChanges returns the changelog resulting from the current transaction.

func (AliasMemoryManager) InitTransaction added in v0.1.1

func (tmm AliasMemoryManager) InitTransaction()

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

func (AliasMemoryManager) Perm added in v0.1.1

func (tmm AliasMemoryManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (AliasMemoryManager) Types added in v0.1.1

func (mm AliasMemoryManager) Types() TypeMemory

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

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 AliasPermTreeGetter added in v0.1.1

type AliasPermTreeGetter struct {
	*PermTreeGetter
	// contains filtered or unexported fields
}

AliasPermTreeGetter 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 (*AliasPermTreeGetter) Get added in v0.1.1

func (amm *AliasPermTreeGetter) 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 AppGetInterface added in v0.1.1

type AppGetInterface interface {
	Get(query string) (*meta.App, error)
}

AppGetInterface is an interface to get apps from memory

type AppMemory added in v0.1.1

type AppMemory interface {
	TransactionInterface
	AppGetInterface
	Create(scope string, app *meta.App, brokers *apimodels.BrokersDI) error
	Delete(query string) error
	Update(query string, app *meta.App, brokers *apimodels.BrokersDI) error
	ResolveBoundary(app *meta.App, usePermTree bool) (map[string]string, error)
}

AppMemory is the interface that allows to obtain or change information related to the current state of the DApps in the cluster

type AppMemoryManager

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

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

func (AppMemoryManager) Alias added in v0.1.1

func (tmm AppMemoryManager) Alias() AliasMemory

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

func (AppMemoryManager) Apps added in v0.1.1

func (tmm AppMemoryManager) Apps() AppMemory

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

func (AppMemoryManager) Cancel added in v0.1.1

func (tmm AppMemoryManager) Cancel()

Cancel discarts changes made in the last transaction

func (AppMemoryManager) Channels added in v0.1.1

func (tmm AppMemoryManager) Channels() ChannelMemory

Channels return a pointer to ChannelMemoryManager

func (AppMemoryManager) Commit added in v0.1.1

func (tmm AppMemoryManager) Commit()

Commit applies changes from a transaction in to the tree structure

func (*AppMemoryManager) Create

func (amm *AppMemoryManager) Create(scope string, app *meta.App, brokers *apimodels.BrokersDI) 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) GetTransactionChanges added in v0.1.1

func (tmm AppMemoryManager) GetTransactionChanges() (diff.Changelog, error)

GetTransactionChanges returns the changelog resulting from the current transaction.

func (AppMemoryManager) InitTransaction added in v0.1.1

func (tmm AppMemoryManager) InitTransaction()

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

func (AppMemoryManager) Perm added in v0.1.1

func (tmm AppMemoryManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (*AppMemoryManager) ResolveBoundary

func (amm *AppMemoryManager) ResolveBoundary(app *meta.App, usePermTree bool) (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) Types added in v0.1.1

func (mm AppMemoryManager) Types() TypeMemory

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

func (*AppMemoryManager) Update

func (amm *AppMemoryManager) Update(query string, app *meta.App, brokers *apimodels.BrokersDI) 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 AppPermTreeGetter added in v0.1.1

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

AppPermTreeGetter 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 (*AppPermTreeGetter) Get added in v0.1.1

func (amm *AppPermTreeGetter) 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 ChannelGetInterface added in v0.1.1

type ChannelGetInterface interface {
	Get(scope, name string) (*meta.Channel, error)
}

ChannelGetInterface is an interface to get channels from memory

type ChannelMemory added in v0.1.1

type ChannelMemory interface {
	TransactionInterface
	ChannelGetInterface
	Create(scope string, ch *meta.Channel, brokers *apimodels.BrokersDI) error
	Delete(scope, name string) error
	Update(scope string, ch *meta.Channel) error
}

ChannelMemory is the interface that allows to obtain or change information related to the stored state of the Channels in the cluster

type ChannelMemoryManager

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

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

func (ChannelMemoryManager) Alias added in v0.1.1

func (tmm ChannelMemoryManager) Alias() AliasMemory

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

func (ChannelMemoryManager) Apps added in v0.1.1

func (tmm ChannelMemoryManager) Apps() AppMemory

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

func (ChannelMemoryManager) Cancel added in v0.1.1

func (tmm ChannelMemoryManager) Cancel()

Cancel discarts changes made in the last transaction

func (ChannelMemoryManager) Channels added in v0.1.1

func (tmm ChannelMemoryManager) Channels() ChannelMemory

Channels return a pointer to ChannelMemoryManager

func (ChannelMemoryManager) Commit added in v0.1.1

func (tmm ChannelMemoryManager) Commit()

Commit applies changes from a transaction in to the tree structure

func (*ChannelMemoryManager) Create

func (chh *ChannelMemoryManager) Create(scope string, ch *meta.Channel, brokers *apimodels.BrokersDI) 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) GetTransactionChanges added in v0.1.1

func (tmm ChannelMemoryManager) GetTransactionChanges() (diff.Changelog, error)

GetTransactionChanges returns the changelog resulting from the current transaction.

func (ChannelMemoryManager) InitTransaction added in v0.1.1

func (tmm ChannelMemoryManager) InitTransaction()

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

func (ChannelMemoryManager) Perm added in v0.1.1

func (tmm ChannelMemoryManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (ChannelMemoryManager) Types added in v0.1.1

func (mm ChannelMemoryManager) Types() TypeMemory

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

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) Alias added in v0.1.1

func (tmm ChannelMockManager) Alias() AliasMemory

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

func (*ChannelMockManager) Create

func (cmm *ChannelMockManager) Create(scope string, ch *meta.Channel, brokers *apimodels.BrokersDI) 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) Perm added in v0.1.1

func (tmm ChannelMockManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (*ChannelMockManager) Update

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

Update mocks a channel method for testing

type ChannelPermTreeGetter added in v0.1.1

type ChannelPermTreeGetter struct {
	*PermTreeGetter
	// contains filtered or unexported fields
}

ChannelPermTreeGetter 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 (*ChannelPermTreeGetter) Get added in v0.1.1

func (cmm *ChannelPermTreeGetter) 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 GetInterface added in v0.1.1

type GetInterface interface {
	Apps() AppGetInterface
	Channels() ChannelGetInterface
	Types() TypeGetInterface
	Alias() AliasGetInterface
}

GetInterface is an interface to get components from memory

type Manager added in v0.1.1

type Manager interface {
	TransactionInterface
	Apps() AppMemory
	Channels() ChannelMemory
	Types() TypeMemory
	Alias() AliasMemory
	Perm() GetInterface
}

Manager is the interface that allows the management of the current state of the cluster. Permiting the modification of Channels, DApps and Types

func GetTreeMemory

func GetTreeMemory() Manager

GetTreeMemory returns a tree memory manager interface

type MockAppManager

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

MockAppManager to Mock App Manager

func (MockAppManager) Alias added in v0.1.1

func (tmm MockAppManager) Alias() AliasMemory

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

func (*MockAppManager) Create

func (mock *MockAppManager) Create(scope string, app *meta.App, brokers *apimodels.BrokersDI) 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) Perm added in v0.1.1

func (tmm MockAppManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (*MockAppManager) ResolveBoundary

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

ResolveBoundary Mock

func (*MockAppManager) Update

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

Update Mock

type MockManager

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

MockManager mocks a tree structure for testing

func (MockManager) Alias added in v0.1.1

func (tmm MockManager) Alias() AliasMemory

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

func (*MockManager) Apps

func (tmm *MockManager) Apps() 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() 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) Perm added in v0.1.1

func (tmm MockManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (*MockManager) Tree added in v0.1.1

func (tmm *MockManager) Tree() GetInterface

Tree mock interface structure

func (*MockManager) Types

func (tmm *MockManager) Types() TypeMemory

Types mocks a Type interface for testing

type PermTreeGetter added in v0.1.1

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

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

func (*PermTreeGetter) Alias added in v0.1.1

func (ptg *PermTreeGetter) Alias() AliasGetInterface

Alias returns a getter for alias on the root

func (*PermTreeGetter) Apps added in v0.1.1

func (ptg *PermTreeGetter) Apps() AppGetInterface

Apps returns a getter for apps on the root.

func (*PermTreeGetter) Channels added in v0.1.1

func (ptg *PermTreeGetter) Channels() ChannelGetInterface

Channels returns a getter for channels on the root.

func (*PermTreeGetter) Types added in v0.1.1

func (ptg *PermTreeGetter) Types() TypeGetInterface

Types returns a getter for Types on the root

type TransactionInterface added in v0.1.1

type TransactionInterface interface {
	Commit()
	GetTransactionChanges() (diff.Changelog, error)
	InitTransaction()
	Cancel()
}

TransactionInterface makes transactions on a Memory manager

type TypeGetInterface added in v0.1.1

type TypeGetInterface interface {
	Get(scope, name string) (*meta.Type, error)
}

TypeGetInterface is an interface to get Types from memory

type TypeMemory added in v0.1.1

type TypeMemory interface {
	TransactionInterface
	TypeGetInterface
	Create(scope string, ct *meta.Type) error
	Delete(scope, name string) error
	Update(scope string, ct *meta.Type) error
}

TypeMemory is the interface that allows to obtain or change information related to the current state of the Types in the cluster

type TypeMemoryManager

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

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

func (TypeMemoryManager) Alias added in v0.1.1

func (tmm TypeMemoryManager) Alias() AliasMemory

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

func (TypeMemoryManager) Apps added in v0.1.1

func (tmm TypeMemoryManager) Apps() AppMemory

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

func (TypeMemoryManager) Cancel added in v0.1.1

func (tmm TypeMemoryManager) Cancel()

Cancel discarts changes made in the last transaction

func (TypeMemoryManager) Channels added in v0.1.1

func (tmm TypeMemoryManager) Channels() ChannelMemory

Channels return a pointer to ChannelMemoryManager

func (TypeMemoryManager) Commit added in v0.1.1

func (tmm TypeMemoryManager) Commit()

Commit applies changes from a transaction in to the tree structure

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) GetTransactionChanges added in v0.1.1

func (tmm TypeMemoryManager) GetTransactionChanges() (diff.Changelog, error)

GetTransactionChanges returns the changelog resulting from the current transaction.

func (TypeMemoryManager) InitTransaction added in v0.1.1

func (tmm TypeMemoryManager) InitTransaction()

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

func (TypeMemoryManager) Perm added in v0.1.1

func (tmm TypeMemoryManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (TypeMemoryManager) Types added in v0.1.1

func (mm TypeMemoryManager) Types() TypeMemory

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

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) Alias added in v0.1.1

func (tmm TypeMockManager) Alias() AliasMemory

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

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) Perm added in v0.1.1

func (tmm TypeMockManager) Perm() GetInterface

Perm returns a getter for objects on the tree without the current changes.

func (*TypeMockManager) Update

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

Update mocks a Type method for testing

type TypePermTreeGetter added in v0.1.1

type TypePermTreeGetter struct {
	*PermTreeGetter
	// contains filtered or unexported fields
}

TypePermTreeGetter 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 (*TypePermTreeGetter) Get added in v0.1.1

func (trg *TypePermTreeGetter) 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