The titan Package Manager

The titan Package Manager is in charge of storing and providing brick configurations. It can be reached via a REST API that serves under the port number HOST:8087 (per default).

UseCaseDiagram

Building/ running

To run the service simply navigate to the root of flowengine-go and use go run ./cmd/packagemanager

or to create an executable file go build ./cmd/packagemanager.

The command line interface features following arguments;

Name Options (default) Purpose
port (8087) Port on which the Package Manager serves
log-level info/debug/warning/error (info) Log level
config-file (internal/app/packagemanager/config.yaml) Configuration file

The default configuration file contains the following items:

Name Type Doc (default value) Constraints
database string URL of the Database (127.0.0.1:27017)
user-manager string URL of the User Service (http://127.0.0.1:9000)
allowed-origins list List of allowed origins for CORS request [not null]
package-folder string Local folder where brick packages are stored (./brickPackages)
package-description string File name of a packge description (package.yaml)
brick-description string File name of a brick description (description.yaml)
python string Absolute path to the installation of python3.7 (/usr/bin/python3.7)

Generally, all settings listed above can be done also via environment
variables, whereby the variables are composed of a prefix (TITAN_PM) and
the argument using snake case:

TITAN_PM_ARGUMENT, e.g. TITAN_PM_LOG_LEVEL

Usage

Get all available bricks

API function:

endpoint: /packagemanager/bricks/ Type: GET

Request data: No data needs to be send

Response data: List of Available Bricks in json format

Get meta data of all packages

API function:

endpoint: /packagemanager/packages/ Type: GET

Request data: No data needs to be send

Response data: List of Package Metadata in json format

Installing a brick package

API function:

endpoint: /packagemanager/packages/ Type: POST

Request data: A brick package as multipart form data with the key "package"

Response data: List of Available Bricks in json format

Users with admin rights can post

Note, If you provide the same package again, bricks with names that are identical to the names in the previous version get updated. New bricks will be appended, old bricks will not be deleted.

Delete Package(s)

API function:

endpoint: /packagemanager/packages?name=<Name1>&name=<Name2> Type: DELETE

Users with admin rights can delete

Response data: Count of deleted Bricks inside each package

Get brick code

API function:

endpoint: /packagemanager/bricks/<string:BrickId>> Type: GET

Request data: No data needs to be send

Response data: content of the compressed brick code

Get time when brick code was last modified

API function:

endpoint: /packagemanager/bricks/<string:BrickId>>/lastmodified Type: GET

Request data: No data needs to be send

Response data: Time when brick code was last modified in unix format

A brick package

Brick packages can be send in the form of zip, tar, tar.gz archives.

It must include a folder named by the package with the following files and folders:

package.yaml : A package description file

Name: "ExamplePackage"
Author: "author name"
Description: "concise package description"

If this file is missing the package name is set to the base name of the archive provided.

ExampleBrick1/, ExampleBrick2/ .. brick folders, named by the bricks they contain.

Each brick folder must contain:

description.yaml the brick description file:

Name: ExampleBrick # the brick name
Family: General   # the brick family
Parameters:      # list of parameters
  - Name: ExampleParameter  # name of the parameter
    Value: 42.2             # default value of the parameter
    Type: float64          # type of the parameter
Description: "A concise description of the bricks functionality"
Package: ExamplePackage   # package name
AutoscaleQueueLevel: 25   # number of unprocessed packets in the queue that trigger autoscaling
AutoscaleMaxInstances: 1  # maximum number of allowed instances for autoscaling
ExitAfterIdleSeconds: 10  # idle time in seconds that triggers automatic teardown
Ports:
  SchemaFile: "ports.ujs"
  Input:
    IN : Input
  Output:
    OUT: Output

The Brick familiy is used in the UI to identify the symbol used for brick. Unsupported entries will result in the symbol of a general brick. A custom image(Optional) for a brick can also be added as <brick name>.svg file. If "Type" of a parameter is not set, the implied type will be string. Parameter values and autoscaling features, and the automatic teardown time can be reset by the brick user for each instance of a brick in the UI.

Note, the name of the brick code, module folder, respectively, must be identical to the brick name.

In total a possible package structure is:

example/
example/package.yaml
example/ExampleBrick1/
example/ExampleBrick1/examplebrick1.py
example/ExampleBrick1/description.yaml
example/ExampleBrick1/examplebrick1.svg
example/ExampleBrick2/
example/ExampleBrick2/examplebrick2/
example/ExampleBrick2/examplebrick2/__init__.py
example/ExampleBrick2/examplebrick2/examplebrick2.py
example/ExampleBrick2/examplebrick2/someothercode.py
example/ExampleBrick2/examplebrick2/examplebrick2.svg
example/ExampleBrick2/description.yaml

Register a ControlPeer

API function:

/packagemanager/controlpeers/ Type: POST

Request data: ControlPeer Address string.

Response data: No data is returned.

Deregister a ControlPeer

API function:

/packagemanager/controlpeers/ Type: DELETE

Request data: ControlPeer Address string.

Response data: No data is returned.