NETRAVE/docker/netrave-protohandler/db/protohandler_dbmanager.rb
VetheonGames 5df588674e There's a lot here...
So, let's get into it.
First, we are straying from the in-memory ideation of storing all our pcap chunks in the memory
I fear that we might bottle up the ram if we depend solely on it.
So, i've made things default to sqlite flatfile, with the option for both remote and in memory
This way, dependant on the users needs, they can use a different implementation.

That's why the creation of a great deal of files and an entire new directory space
I've almost finished implementing the database system into itself, but I want the DB system
to be largely independent of the rest of the system. Because, you know me,
I am a fan of encapsulation. and I like making software coded to be independent.

Yes, if the rest of the system isn't working, the database has nothing to docker
but at least it makes the system more robust, if even a major system can collapse,
and the system as a whole remains functional.

Philisophically, I find this is largely lacking in modern software, and I believe
that these practices will see the protohandler performing much better than we would expect
Since this system as a whole will be independent of the main NETRAVE system,
it opens the door for further expanding, or perhaps even completely repurposing
this protocol going forward.
2023-10-02 15:31:36 -06:00

48 lines
926 B
Ruby

# frozen_string_literal: true
require 'sequel'
class ProtohandlerDBManager
attr_reader :db
def initialize
setup_database
end
def setup_database
@db = Sequel.sqlite # In-memory database
create_processors_table unless table_exists?(:processors)
create_orchestrators_table unless table_exists?(:orchestrators)
create_blacklist_table unless table_exists?(:blacklist)
end
def table_exists?(table_name)
@db.table_exists?(table_name)
end
def create_processors_table
@db.create_table :processors do
primary_key :proto_handler_id
String :uuid
String :domain
Integer :port
end
end
def create_orchestrators_table
@db.create_table :orchestrators do
primary_key :id
String :domain
Integer :port
end
end
def create_blacklist_table
@db.create_table :blacklist do
primary_key :id
String :uuid
end
end
end