Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

kytos-ng/storehouse

 
 

Repository files navigation

Tag License Build status Code coverage Code-quality score

storehouse has been deprecated⚠️

MongoDB has been chosen as a default document-oriented database, so if your NApp needs this type of storage check out this documentation. If you're looking for additional code samples you can also check out flow_manager, topology and mef_eline.

kytos/storehouse

NApp that provides backends for persistent data storage

Overview

This NApp is responsible for data persistence, saving and retrieving information. It can be acessed by external agents through the REST API or by other NApps, using the event-based methods.

Each box of data can be saved in a different namespace, with support for nested namespaces.

The NApp is designed to support many options of back-end persistence solutions. Currently it features filesystem operations, but alternatives such as SQL or NoSQL databases will be implemented.

Installing

To install this NApp, first, make sure to have the same venv activated as you have kytos installed on:

$ git clone https://github.com/kytos-ng/storehouse.git
$ cd storehouse
$ python setup.py develop

Events

Subscribed

The NApp listens to events requesting operations. Every event must have a callback function to be executed right after the internal method returns. The signature of the callback function is described with each event.

kytos.storehouse.create

Event requesting to save data to a box in a namespace.

Content:

{
    data: <any data to be saved>,
    namespace: <namespace name>,
    callback: <callback function> # To be executed after the method returns.
}

Callback function:

def callback_function_name(box, error=False):
    # box: copy of the Box instance stored with data and metadata.
    # error: False when the operation is successful, True otherwise.

kytos.storehouse.retrieve

Event requesting to load data from a box in a namespace.

Content:

{
    box_id: <ID of the Box to retrieve data from>,
    namespace: <namespace name>,
    callback: <callback function> # To be executed after the method returns.
}

Callback function:

def callback_function_name(box, error=False):
    # box: the retrieved Box instance.
    # error: False when the operation is successful, True otherwise.

kytos.storehouse.update

Event requesting to update data to a box in a namespace.

Content:

{
    box_id: <ID of the Box to retrieve data from>,
    data: <any data to be saved>,
    namespace: <namespace name>,
    callback: <callback function> # To be executed after the method returns.
}

Callback function:

def callback_function_name(event, box, error=False):
    # event: copy of the original event data
    # box: copy of the Box instance stored with data and metadata.
    # error: False when the operation is successful, True otherwise.

kytos.storehouse.list

Event requesting to list all boxes in a namespace.

Content:

{
    namespace: <namespace name>,
    callback: <callback function> # To be executed after the method returns.
}

Callback function:

def callback_function_name(box_list, error=False):
    # box_list: the retrieved list of Box.box_id.
    # error: False when the operation is successful, True otherwise.

kytos.storehouse.delete

Event requesting to remove a box from a namespace.

Content:

{
    box_id: <ID of the Box to be deleted>,
    namespace: <namespace name>,
    callback: <callback function> # To be executed after the method returns.
}

Callback function:

def callback_function_name(result, error=False):
    # result: True if the box was deleted, False otherwise .
    # error: False when the operation is successful, True otherwise.

About

Persistence NApp with support for multiple backends

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%