Lookups

In-memory lookups of past interactions, indexed by keywords.

What it does

Lookups may be read from and written to using LookupWriters, LookupReaders and LookupExterminators.

Multiple lookups may exist in a single instance of ApolloGeese at any given time, and are universally accessible among Services resident in a single instance of ApolloGeese. 

Lookups can be told apart by the lookupname, provided upon initialization of each Lookup-related service.

The Lookup system may be compared to a very simple in-memory database, it may be compared to more familiar SQL database concepts as follows:

LookupReader SELECT-query
LookupWriter INSERT-query
LookupExterminator DELETE-query

The similarities end here, largely; the database-connection and disk-storage are both skipped and indexing using Lookups is done directly and only to RAM. (In fact, it only occured to me to make the read/write/delete comparison at the time of writing these docs.)

Behind the scenes

A single lookup consists of a two hashmaps;

The first hasmap is used for doing the quick lookups by combinations of keywords; a search with two keywords produces two lists that will be combined into one by means of an 'AND' or 'OR' contained in the lookup query.

The second hashmap is used for quickly finding stored interactions by their identity (meta) field and is at the time of writing this only neccesary for quickly removing items. (Like the LookupExterminator does).

How it works

Source code below is also available on github including required html files.

{
    plugins = [
        // Lookup*
        f"Data.dll",            
        // PostFieldReader
        f"InputProcessing.dll",
        // HttpService
        f"BasicHttpServer.dll",  
        // Template
        f"OutputComposing.dll",  
        // SiteSubsection
        f"Navigation.dll"        
    ];

    instances = {
        forms = Template(f"lookups/forms.html");

        search = PostFieldReader(
            field_keywords = "^[\\w|\\s]+$"
        ) {
            form->instances.forms;
            successful->Template(f"lookups/found.html") {
                list->LookupReader(
                    lookupname = "example",
                    lookupkeyname = "keywords"
                ) {
                    iterator->Template(f"lookups/entry.html");
                };
            };
        };

        save = BodyReader(
            field_meta = "^[\\w]+$",
            field_keywords = "^[\\w|\\s]+$",
            field_content = ".*"
        ) {
            form->instances.forms;
            successful->Template(
                f"lookups/added.html"
            ) {
                entry->Template(
                    f"lookups/entry.html");
                writer->LookupWriter(
                    lookupname = "example",
                    lookupkeyname = "keywords",
                    metaname = "meta");
            };
        };

        remove = BodyReader(
            field_meta = "^[\\w]+$"
        ) {
            form->instances.forms;
            successful->Template(f"lookups/removed.html") {
                remover->LookupExterminator(
                    lookupname = "example",
                    metaname = "meta"
                );
            };
        };

        example = Template(
            f"lookups/skeleton.html"
        ) {
            content->SiteSubsection() {
                main->instances.forms;
                search->instances.search;
                save->instances.save;
                remove->instances.remove;
            };
        };

        server = HttpService(
            prefixes = ["http://*:8080/"]) {
            http->instances.example;
        };
    };
}