Example #1
0
def create_table(context, table):
    """Create a table suitable for storing monitoring events."""
    if not validate_table_name(table):
        logger.critical("Invalid PostgreSQL table name: %s", table)
        sys.exit(1)

    db = DatabaseHandler(context.obj["db"]["config"])
    db.create_table(table)
    logger.info("Created table %s", table)
Example #2
0
def process(context, **kwargs):
    """Stream results from Kafka into a database."""
    for table_name in kwargs["tables"]:
        if not validate_table_name(table_name):
            logger.critical("Invalid PostgreSQL table name: %s", table_name)
            sys.exit(1)
    context.obj.update(kwargs)

    event_processor = EventProcessor(**context.obj)
    logger.info("Starting event processing service")
    event_processor.run()
Example #3
0
 def test_too_long(self):
     self.assertFalse(validate_table_name("table_" + 64 * "a"))
Example #4
0
 def test_starting_underscore(self):
     self.assertTrue(validate_table_name("_table1"))
Example #5
0
 def test_starting_numeral(self):
     self.assertFalse(validate_table_name("1table"))
Example #6
0
 def test_starting_dollar_sign(self):
     # Completely disallowed with PostgreSQL.
     self.assertFalse(validate_table_name("$table1"))
Example #7
0
 def test_cjk(self):
     self.assertFalse(validate_table_name("table_有り"))
Example #8
0
 def test_alphanumerical_with_underscore(self):
     self.assertTrue(validate_table_name("table_2"))
Example #9
0
 def test_alphanumerical_with_nonlatin(self):
     # Actually possible with PostgreSQL, but disallowed for the time being.
     self.assertFalse(validate_table_name("täble"))
Example #10
0
 def test_alphanumerical(self):
     self.assertTrue(validate_table_name("table1"))